1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[python] 主成分分析の主成分数と累積寄与率の関係を描画するスニペット

Last updated at Posted at 2020-12-07

表題通りです。とりあえず、sklearn の load_boston の結果を表示する様にしてあります。

from sklearn.datasets import load_boston
X = load_boston(return_X_y=True)[0]

from sklearn import decomposition
pca=decomposition.PCA()
pca.fit(X)
y = np.add.accumulate(pca.explained_variance_ratio_)
x = np.arange(y.size)+1
plt.plot(x, y, ls='--', marker='o')
plt.ylabel("cumulative contribution ratio")
plt.xlabel("number of principal components")
plt.show()

スクリーンショット 2020-12-08 午前1.04.19.png

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?