DTECT / backend /inference /peak_detector.py
AdhyaSuman's picture
Initial commit with Git LFS for large files
11c72a2
raw
history blame contribute delete
572 Bytes
import numpy as np
from scipy.signal import find_peaks
def detect_peaks(trend, prominence=0.001, distance=2):
"""
Detect peaks in a word's trend over time.
Args:
trend: List or np.array of floats (word importance over time)
prominence: Required prominence of peaks (tune based on scale)
distance: Minimum distance between peaks
Returns:
List of indices (timestamps) where peaks occur
"""
trend = np.array(trend)
peaks, _ = find_peaks(trend, prominence=prominence, distance=distance)
return peaks.tolist()