时间序列聚类算法对比与无监督学习应用
1. 时间序列聚类算法实验
在时间序列聚类分析中,我们对三种算法——k - Shape、k - Means 和 HDBSCAN 进行了全面实验,以比较它们的性能。
1.1 k - Shape 算法实验
首先进行的是 k - Shape 算法实验,其代码如下:
import pandas as pd import time from os import listdir from os.path import isfile, join import numpy as np from sklearn.model_selection import train_test_split from tslearn.utils import to_time_series_dataset from tslearn.preprocessing import TimeSeriesScalerMeanVariance from tslearn.clustering import KShape from sklearn.metrics import adjusted_rand_score # k - Shape Experiment kShapeDF = pd.DataFrame(data=[],index=[v for v in d], columns=["Train ARS","Test ARS"]) # Train and Evaluate k - Shape class ElapsedTimer(object): de