【发布时间】:2020-10-14 14:28:48
【问题描述】:
我对我的数据执行了 PCA。数据如下所示:
df
Out[60]:
Drd1_exp1 Drd1_exp2 Drd1_exp3 ... M7_pppp M7_puuu Brain_Region
0 -1.0 -1.0 -1.0 ... 0.0 0.0 BaGr
3 -1.0 -1.0 -1.0 ... 0.0 0.0 BaGr
4 -1.0 -1.0 -1.0 ... 0.0 0.0 BaGr
... ... ... ... ... ... ...
150475 -1.0 -1.0 -1.0 ... 0.0 0.0 BaGr
150478 -1.0 -1.0 -1.0 ... 0.0 0.0 BaGr
150479 -1.0 -1.0 -1.0 ... 0.0 0.0 BaGr
我知道在“大脑区域”之前的每一行都用作特征。我也将它们标准化。 这些特征是不同的实验,它们为我提供了关于大脑 3D 图像的信息。 我会告诉你我的代码:
from sklearn.preprocessing import StandardScaler
x = df.loc[:, listend1].values
y= df.loc[:, 'Brain_Region'].values
x = StandardScaler().fit_transform(x)
from sklearn.decomposition import PCA
pca = PCA(n_components=2)
principalComponents = pca.fit_transform(x)
principalDf = pd.DataFrame(data = principalComponents
, columns = ['principal component 1', 'principal component 2'])
finalDf = pd.concat([principalDf, df[['Brain_Region']]], axis = 1)
然后我绘制了 finalDF:
我现在的问题是:我怎样才能知道哪些功能有助于我的组件?我怎样才能找出、解释数据?
【问题讨论】:
标签: python pandas scikit-learn statistics pca