写一段高维数据降维聚类的代码
时间: 2023-03-11 21:53:53 浏览: 190
matplotlib-3.6.3-cp39-cp39-linux_armv7l.whl
代码:from sklearn.cluster import KMeans
from sklearn.decomposition import PCA# 加载高维数据
data = ...# 降维
pca = PCA(n_components=2)
data_low_dim = pca.fit_transform(data)# 聚类
kmeans = KMeans(n_clusters=3, random_state=0).fit(data_low_dim)
print(kmeans.labels_)
阅读全文