【发布时间】:2020-10-16 00:45:38
【问题描述】:
我正在尝试从Kaggle 运行此代码。用于使用 DTW 对时间序列进行聚类。 更具体的部分: 在[24/25]:
"""
From a list of series, compute a distance matrix by computing the
DTW distance of all pairwise combinations of series.
"""
diff_matrix = {}
cross = itertools.product(cols, cols)
for (col1, col2) in cross:
series1 = daily_sales_item_lookup_scaled_weekly[col1]
series2 = daily_sales_item_lookup_scaled_weekly[col2]
diff = dtw(
series1,
series2,
keep_internals=True,
step_pattern=rabinerJuangStepPattern(2, "c")
)\
.normalizedDistance
diff_matrix[(col1, col2)] = [diff]
return diff_matrix
作为参数之一,作者声称“step_pattern=rabinerJuangStepPattern(2, "c"))”但是,当我运行它时,我得到了提到的错误。 有谁知道可能出了什么问题?
谢谢!
【问题讨论】:
-
你不应该复制你并不真正理解的代码。这里
rabinerJuangStepPattern似乎是一个函数,但你没有创建或导入它。 -
很可能是因为这是作为笔记本运行的,您忘记在它之前运行定义此函数的 sn-p。
标签: python time-series cluster-analysis nameerror dtw