Skip to content

decomposition.PCA has no attribute 'singular_values_' #9949

@harryscholes

Description

@harryscholes

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions