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

Skip to content

[MRG] DOC Clarify RobustScaler behavior with sparse input #8858

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

Merged
merged 1 commit into from
Jul 29, 2017

Conversation

naoyak
Copy link
Contributor

@naoyak naoyak commented May 11, 2017

Fixes #8796.

@naoyak naoyak changed the title Clarify RobustScaler behavior with sparse input [MRG] DOC Clarify RobustScaler behavior with sparse input May 11, 2017
Copy link
Member

@lesteve lesteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small comments.

@@ -191,7 +191,7 @@ matrices as input, as long as ``with_mean=False`` is explicitly passed
to the constructor. Otherwise a ``ValueError`` will be raised as
silently centering would break the sparsity and would often crash the
execution by allocating excessive amounts of memory unintentionally.
:class:`RobustScaler` cannot be fited to sparse inputs, but you can use
:class:`RobustScaler` cannot be fitted to sparse inputs, but you can use
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that was the typo, good catch

@@ -863,7 +863,7 @@ class RobustScaler(BaseEstimator, TransformerMixin):
----------
with_centering : boolean, True by default
If True, center the data before scaling.
This does not work (and will raise an exception) when attempted on
This will cause ``transform`` to raise an exception when attempted on
Copy link
Member

@lesteve lesteve May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think .fit raises an exception if X is sparse Edit: scratch this as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fiton sparse raises regardless of any option. You can transform on sparse after fitting on dense, apparently?

@@ -930,7 +930,8 @@ def _check_array(self, X, copy):
return X

def fit(self, X, y=None):
"""Compute the median and quantiles to be used for scaling.
"""Compute the median and quantiles to be used for scaling. Note that
Copy link
Member

@lesteve lesteve May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is only true if with_centering=True Edit: scratch that it will always raise an exception with fit.

I think because the docstring of the X parameter does not mention that X can be sparse we don't have to modify anything in the fit docstring.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also PEP257: first line of docstring should be standalone short description

@lesteve
Copy link
Member

lesteve commented May 11, 2017

Maybe we should update the docstring of RobustScaler.transform to mention that it can be called on sparse inputs as long as with_centering is False.

@naoyak naoyak force-pushed the robustscaler-docs branch from 064168b to ffe771f Compare May 11, 2017 14:57
@naoyak
Copy link
Contributor Author

naoyak commented May 11, 2017

Thanks for the input - reflected now

@naoyak
Copy link
Contributor Author

naoyak commented May 12, 2017

Any other feedback @lesteve?

@naoyak naoyak force-pushed the robustscaler-docs branch from ffe771f to 4bcd5c6 Compare June 10, 2017 21:08
@naoyak naoyak force-pushed the robustscaler-docs branch from 4bcd5c6 to 8c50446 Compare July 12, 2017 05:23
@naoyak
Copy link
Contributor Author

naoyak commented Jul 12, 2017

Rebased.

"""Center and scale the data.

Can be called on sparse input, provided that ``RobustScaler`` has been
fitted to dense input and ``with_centering=False``.

Parameters
----------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type description for X here site mention sparse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@naoyak naoyak force-pushed the robustscaler-docs branch from 8c50446 to 2ccf793 Compare July 12, 2017 09:09

Parameters
----------
X : array-like
X : {array-like, sparse matrix}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jnothman if I read your feedback correctly, does this address the comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Sorry for the autocorrect typo.

@jnothman
Copy link
Member

Thanks

@jnothman jnothman added this to the 0.19 milestone Jul 29, 2017
@jnothman jnothman merged commit f6c7080 into scikit-learn:master Jul 29, 2017
@naoyak naoyak deleted the robustscaler-docs branch July 29, 2017 16:00
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Aug 6, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants