1 回答

TA貢獻1757條經驗 獲得超7個贊
我認為動態時間扭曲 (dtw) 可能適合您。我已經將它用于類似的事情。本質上,它允許您評估時間序列的相似性。
以下是我所知道的 python 實現:
快速dtw
dtw
dtw-python
這是它如何工作的一個體面的解釋
您可以使用它來比較傳入時間序列與紅框中數據的相似程度。
例如:
# Event were looking for
event = np.array([10, 100, 50, 60, 50, 70])
# A matching event occurring
event2 = np.array([0, 7, 12, 4, 11, 100, 51, 62, 53, 72])
# A non matching event
non_event = np.array([0, 5, 10, 5, 10, 20, 30, 20, 11, 9])
distance, path = fastdtw(event, event2)
distance2, path2 = fastdtw(event, non_event)
這將產生一組指數,其中兩個時間序列最匹配。在這一點上,您可以通過您喜歡的任何方法進行評估。我粗略地查看了值的相關性
def event_corr(event,event2, path):
d = []
for p in path:
d.append((event2[p[1]] * event[p[0]])/event[p[0]]**2)
return np.mean(d)
print("Our event re-occuring is {:0.2f} correlated with our search event.".format(event_corr(event, event2, path)))
print("Our non-event is {:0.2f} correlated with our search event.".format(event_corr(event, non_event, path2)))
產生:
Our event re-occurring is 0.85 correlated with our search event.
Our non-event is 0.45 correlated with our search event.
添加回答
舉報