소스 검색

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 2 달 전
부모
커밋
54257f80aa
1개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  1. +22
    -0
      pipeline/feature_extractors.py

+ 22
- 0
pipeline/feature_extractors.py 파일 보기

@@ -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)


불러오는 중...
취소
저장