optimum eigen value for pca python

Solutions on MaxInterview for optimum eigen value for pca python by the best coders in the world

showing results for - "optimum eigen value for pca python"
Abdoulaye
04 Sep 2019
1pca = PCA().fit(data_rescaled)
2
3% matplotlib inline
4import matplotlib.pyplot as plt
5plt.rcParams["figure.figsize"] = (12,6)
6
7fig, ax = plt.subplots()
8xi = np.arange(1, 11, step=1)
9y = np.cumsum(pca.explained_variance_ratio_)
10
11plt.ylim(0.0,1.1)
12plt.plot(xi, y, marker='o', linestyle='--', color='b')
13
14plt.xlabel('Number of Components')
15plt.xticks(np.arange(0, 11, step=1)) #change from 0-based array index to 1-based human-readable label
16plt.ylabel('Cumulative variance (%)')
17plt.title('The number of components needed to explain variance')
18
19plt.axhline(y=0.95, color='r', linestyle='-')
20plt.text(0.5, 0.85, '95% cut-off threshold', color = 'red', fontsize=16)
21
22ax.grid(axis='x')
23plt.show()
24
similar questions
queries leading to this page
optimum eigen value for pca python