如何用pca数据绘制kmeans聚类?

时间:2018-06-22 16:16:19

标签: matrix k-means pca sklearn-pandas unsupervised-learning

在执行PCA之后,我想用标准化数据绘制KMeans聚类。但是,我无法真正理解将要执行的步骤。有人可以在这方面指导我吗? 提前致谢。

from sklearn.decomposition import PCA
pca = PCA(n_components=2)
Demography_Data = pca.fit_transform(x)
principalDf = pd.DataFrame(data = Demography_Data
             , columns = ['Demography_Data_1', 'Demography_Data_2'])
principalDf.index=df2[['Customer_Age']].index
finalDf = pd.concat([principalDf, df2[['Customer_Age']]], axis = 1)

finalDf_pic

%matplotlib inline
colors = ['r', 'g', 'b', 'y', 'c', 'm']
ax = finalDf.plot(kind='scatter', x='Demography_Data_1', y='Demography_Data_2', figsize=(10,8))

PCA Result_pic

0 个答案:

没有答案