Bläddra i källkod

feat: add _nonoverlap_mean()

Take the mean of non-overlapping windows of scores

    Input:  list of tuples in the format (time, score)
    Output: list of tuples in the format (time, mean_score)
            (reduced set)
main
Rob Hallam 3 månader sedan
förälder
incheckning
54257f80aa
1 ändrade filer med 22 tillägg och 0 borttagningar
  1. +22
    -0
      pipeline/feature_extractors.py

+ 22
- 0
pipeline/feature_extractors.py Visa fil

@@ -282,6 +282,28 @@ class VideoActivityFeatureExtractor(FeatureExtractor):
)
return scores

def _nonoverlap_mean(self, scores, window_size=0.500) -> list:
"""Take the mean of non-overlapping windows of scores

Input: list of tuples in the format (time, score)
Output: list of tuples in the format (time, mean_score) (reduced set)
"""
means = []
current_window = []
current_window_start = 0.0

for time, score in scores:
if time - current_window_start > window_size:
# calculate mean of current window
mean_score = sum([s for _, s in current_window]) / len(current_window)
means.append((current_window_start, round(mean_score, 3)))
# reset window
current_window = []
current_window_start = time
current_window.append((time, score))

return means

def _drop_lowest(self, scores, percent=33):
"""Drop the lowest n% scores from the list"""
scores = sorted(scores, key=lambda x: x[1], reverse=True)


Laddar…
Avbryt
Spara