计算DTW metri的轮廓分数

2024-04-19 09:37:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一些时间序列数据,我想使用DTW度量对它们进行聚类。 首先我需要计算它的轮廓分数。 我用这段代码来计算不同数量的簇的轮廓分数:

 for n_cluster in n_cluster_list:
     dtw = TimeSeriesKMeans(n_clusters = n_cluster, metric="dtw")
     cluster_found = dtw.fit_predict(X) #in X I have my data
     silhouette_score(X, dtw.labels_, metric="dtw"))

但这对我没用。 我得到这个错误:

ValueError: Unknown metric dtw. Valid metrics are ['euclidean', 
'l2', 'l1', 'manhattan', 'cityblock', 'braycurtis', 'canberra',         
'chebyshev', 'correlation', 'cosine', 'dice', 'hamming', 'jaccard', 
'kulsinski', 'mahalanobis', 'matching', 'minkowski', 
'rogerstanimoto', 'russellrao', 'seuclidean', 'sokalmichener', 
'sokalsneath', 'sqeuclidean', 'yule', 'wminkowski', 'haversine'], 
or 'precomputed', or a callable

我在这里找到了代码:https://tslearn.readthedocs.io/en/latest/gen_modules/clustering/tslearn.clustering.silhouette_score.html

有人知道这里的问题吗?你知道吗


Tags: or数据代码in时间序列metric分数