Thanks to visit codestin.com
Credit goes to github.com

Skip to content

RobustScaler does not allow sparse matrix input #8796

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

Closed
masongallo opened this issue Apr 25, 2017 · 5 comments
Closed

RobustScaler does not allow sparse matrix input #8796

masongallo opened this issue Apr 25, 2017 · 5 comments

Comments

@masongallo
Copy link

RobustScaler raises a TypeError when calling fit with a sparse matrix as input, despite the docs indicating that using a sparse matrix is feasible as long as with_centering=False. Looks like the fit method is blocking any sparse matrix input with an if statement:

Link to line of code that raises: https://github.com/scikit-learn/scikit-learn/blob/14031f6/sklearn/preprocessing/data.py#L1004

I can provide some code to reproduce if necessary, but I want to make sure this makes sense first. Thanks!

@glemaitre
Copy link
Member

What you are saying seems to be right. Can you provide an minimal example to be certain of the behavior.

@jnothman
Copy link
Member

jnothman commented Apr 26, 2017 via email

@masongallo
Copy link
Author

or just submit a fix

I'm assuming it's just removing the lines that raise the exception and adding a test? I should be able to submit a PR in the next day or two.

@naoyak
Copy link
Contributor

naoyak commented May 4, 2017

The issue is clarifying class documentation of RobustScaler as you can only transform() on sparse input after fitting on dense input. Perhaps it makes sense to add a test confirming that exceptions are raised appropriately.

(Note a typo here) http://scikit-learn.org/stable/modules/preprocessing.html#scaling-sparse-data

RobustScaler cannot be fited to sparse inputs, but you can use the transform method on sparse inputs.

See also #4125 (comment) - RobustScaler.fit() on sparse input hasn't been implemented.

@lesteve
Copy link
Member

lesteve commented May 11, 2017

The issue is clarifying class documentation of RobustScaler as you can only transform() on sparse input after fitting on dense input

A PR would be more than welcome.

(Note a typo here) http://scikit-learn.org/stable/modules/preprocessing.html#scaling-sparse-data

@naoyak can you clarify what you mean by typo ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants