Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] IncrementalPCA: transform() call fails when using whitening #3183

Closed
lowener opened this issue Nov 24, 2020 · 3 comments
Closed

[BUG] IncrementalPCA: transform() call fails when using whitening #3183

lowener opened this issue Nov 24, 2020 · 3 comments
Assignees
Labels
4 - Waiting on Reviewer Waiting for reviewer to review or respond ? - Needs Triage Need team to review and classify bug Something isn't working

Comments

@lowener
Copy link
Contributor

lowener commented Nov 24, 2020

Describe the bug
Trying to use transform() on IPCA when using whitening fails.

Stacktrace:

Traceback (most recent call last):
  File "a.py", line 11, in <module>
    cu_t = cu_ipca.transform(X)
  File "/opt/conda/envs/rapids/lib/python3.8/site-packages/cuml/internals/api_decorators.py", line 587, in inner_get
    ret_val = func(*args, **kwargs)
  File "/opt/conda/envs/rapids/lib/python3.8/site-packages/cuml/experimental/decomposition/incremental_pca.py", line 408, in transform
    return super().transform(X)
  File "/opt/conda/envs/rapids/lib/python3.8/site-packages/cuml/internals/api_decorators.py", line 587, in inner_get
    ret_val = func(*args, **kwargs)
  File "cuml/decomposition/pca.pyx", line 664, in cuml.decomposition.pca.PCA.transform
  File "/opt/conda/envs/rapids/lib/python3.8/site-packages/cuml/internals/api_decorators.py", line 596, in inner
    ret_val = func(*args, **kwargs)
  File "cuml/decomposition/pca.pyx", line 626, in cuml.decomposition.pca.PCA._sparse_transform
  File "cuml/decomposition/pca.pyx", line 629, in cuml.decomposition.pca.PCA._sparse_transform
  File "cuml/common/base.pyx", line 262, in cuml.common.base.Base.__getattr__
AttributeError

Steps/Code to reproduce bug

import cupy as cp
import cupyx
from cuml.datasets import make_blobs
from cuml.experimental.decomposition import IncrementalPCA as cuIPCA

X, _ = make_blobs(n_samples=500, n_features=15, random_state=10)
cu_ipca = cuIPCA(n_components=2, whiten=True, batch_size=100)
cu_ipca.fit(X)
cu_t = cu_ipca.transform(X)

This happens when whiten=True.

Expected behavior
The call to transform() is successful with cuml PCA and sklearn IncrementalPCA.

Environment details (please complete the following information):

  • Docker image used: rapidsai/rapidsai-dev-nightly:0.17-cuda11.0-devel-ubuntu18.04-py3.8
@lowener lowener added ? - Needs Triage Need team to review and classify bug Something isn't working labels Nov 24, 2020
@JohnZed
Copy link
Contributor

JohnZed commented Nov 25, 2020

@divyegala can you take a look and/or share some pointers with @lowener so he could dig further?

@divyegala
Copy link
Member

@lowener looks like it's occurring because attribute n_rows

self.components_ *= cp.sqrt(self.n_rows - 1)
is not being set for IncrementalPCA. It will likely be fixed if you set that attribute during IncrementalPCA.fit, if you want to try?

lowener added a commit to lowener/cuml that referenced this issue Nov 25, 2020
@JohnZed JohnZed added the 4 - Waiting on Reviewer Waiting for reviewer to review or respond label Nov 30, 2020
rapids-bot bot pushed a commit that referenced this issue Dec 1, 2020
This PR is fixing the attribute error of #3183, and additional bugs on the input type of PCA (`sparse_scipy_to_cp()` function call missed an argument) and on the shape of `self.singular_values_`.

I am also adding additional tests on the bug fixed here.

Authors:
  - Mickael Ide <ide.mickael@gmail.com>
  - John Zedlewski <904524+JohnZed@users.noreply.github.com>

Approvers:
  - Divye Gala
  - John Zedlewski

URL: #3190
@lowener
Copy link
Contributor Author

lowener commented Dec 2, 2020

Solved with #3190

@lowener lowener closed this as completed Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - Waiting on Reviewer Waiting for reviewer to review or respond ? - Needs Triage Need team to review and classify bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants