decomposition.PCA has no attribute 'singular_values_'
See original GitHub issueDescription
The singular_values_
attribute of PCA
is broken.
Steps/Code to Reproduce
The docstring for PCA
contains the following example:
import numpy as np
from sklearn.decomposition import PCA
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])
pca = PCA(n_components=2)
pca.fit(X)
print(pca.singular_values_)
Expected Results
From the docstring:
[ 6.30061... 0.54980...]
Actual Results
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-340-afb570ab70cc> in <module>()
4 pca = PCA(n_components=2)
5 pca.fit(X)
----> 6 print(pca.singular_values_)
AttributeError: 'PCA' object has no attribute 'singular_values_'
Versions
Darwin-16.7.0-x86_64-i386-64bit
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
NumPy 1.13.0
SciPy 0.19.1
Scikit-Learn 0.18.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
sklearn.decomposition.PCA — scikit-learn 1.2.0 documentation
PCA : A demo of K-Means clustering on the handwritten digits data A demo of ... and then divided by the singular values...
Read more >In sklearn.decomposition.PCA, why are components_ negative?
As you figured out in your answer, the results of a singular value decomposition (SVD) are not unique in terms of singular vectors....
Read more >'PCA' object has no attribute 'explained_variance_'
Elbow Method - Finding the number of components required to preserve maximum variance. My code: pca = decomposition.PCA() vectorizer = ...
Read more >8.5.1. sklearn.decomposition.PCA - GitHub Pages
This implementation uses the scipy.linalg implementation of the singular value decomposition. It only works for dense arrays and is not scalable to large ......
Read more >dask_ml.decomposition.PCA - Dask-ML
Linear dimensionality reduction using Singular Value Decomposition of the data ... then divided by the singular values to ensure uncorrelated outputs with ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
PCA.singular_values_
attribute was added in 0.19 (in https://github.com/scikit-learn/scikit-learn/pull/7685), it doesn’t exist in 0.18.1. Please update your scikit-learn version.My apologies! I didn’t realise I was out of date 😃