如何在tslearn中提取群集元素

我是XX的初学者。我使用tslearn时间集群,我根据文档完成了聚类,但是我不知道如何提取集群中的元素,tslearn数据格式要求是三维数组(n,sz,维),并且可以有一个字符串,我认为适合预测功能,它告诉我返回每个样本所属的簇的索引。但是我不明白输出结果,我想向您咨询,因为数据格式不能包含字符串,我也考虑过使用4维数组来标记,但是根据格式要求制作的TXT似乎没有能够实现此功能。现在我显示了120个国家/地区的9天,一维​​数据,代码数据集和运行结果。此处输入图像说明[此处输入图像说明] [此处输入图像说明] 2输入图像说明这里

from tslearn.utils import save_time_series_txt, load_time_series_txt
import numpy as np
import numpy
import matplotlib.pyplot as plt

from tslearn.clustering import KShape
from tslearn.datasets import CachedDatasets
from tslearn.preprocessing import TimeSeriesScalerMeanVariance
from tslearn.clustering import GlobalAlignmentKernelKMeans
from tslearn.metrics import sigma_gak
from tslearn.clustering import TimeSeriesKMeans
time_series_dataset = load_time_series_txt("monday - 副本.txt")
X_train=time_series_dataset
X_train.shape
#np.random.shuffle(X_train)
# For this method to operate properly, prior scaling is required
#seed = 0
#numpy.random.seed(seed)
sz = X_train.shape[1]
# DBA-k-means
print("DBA k-means")
dba_km = TimeSeriesKMeans(n_clusters=3,
                          n_init=2,
                          metric="dtw",
                          verbose=True,
                          max_iter_barycenter=10)
y_pred = dba_km.fit_predict(X_train)
for yi in range(3):
    #plt.subplot(3, 3, 4 + yi)
    for xx in X_train[y_pred == yi]:
        plt.plot(xx.ravel(), "k-", alpha=.2)
    plt.plot(dba_km.cluster_centers_[yi].ravel(), "-")
    plt.xlim(0, sz)
    #plt.ylim(-1.2,1.5)
    plt.text(0.55, 0.85,'Cluster %d' % (yi + 1),
             transform=plt.gca().transAxes)
    if yi == 1:
        plt.title("DBA $k$-means")

plt.figure()
for yi in range(3):
    #plt.subplot(4, 1, 1 + yi)
    #for xx in X_train[y_pred == yi]:
        #plt.plot(xx.ravel(), "k-", alpha=.2)
    plt.plot(dba_km.cluster_centers_[yi].ravel(), "-")
    plt.xlim(0, sz)
    #plt.ylim(-1.2,1.5)
    plt.title("Cluster %d" % (yi + 1))

plt.tight_layout()
plt.show()

for yi in range(3):
    #plt.subplot(3, 3, 4 + yi)
    #for xx in X_train[y_pred == yi]:
        #plt.plot(xx.ravel(), "k-", alpha=.2)
    plt.plot(dba_km.cluster_centers_[yi].ravel(), "-")