-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG+2] add MaxAbsScaler #4828
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
[MRG+2] add MaxAbsScaler #4828
Conversation
@amueller : I hope this is what you had in mind |
lie between a given minimum and maximum value, often between zero and one. | ||
This can be achieved using :class:`MinMaxScaler`. | ||
lie between a given minimum and maximum value, often between zero and one, | ||
or so that the maximum value of each feature is scaled to unit size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolute value?
Apart from nitpicks and sparse matrix testing LGTM |
676d201
to
22074da
Compare
|
||
|
||
As with :func:`scale`, the module further provides a | ||
convenience function function :func:`maxabs_scale` if you don't want to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated word?
Looks good :) |
Since it is not in RobustScaler anymore, do we want to use |
Thanks for that 2nd review. I've implemented the changes you've suggested and squashed the commits. |
@@ -146,6 +148,61 @@ full formula is:: | |||
|
|||
X_scaled = X_std / (max - min) + min | |||
|
|||
:class:`MaxAbsScaler` works in a very similar fashion, but scales data so | |||
it lies within the range ``[-1, 1]``, and is meant for data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet this is not true of the following example. Either qualify the statement or add a trim option to the scaler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the text a bit, please have a look to see if you like the new wording better.
Remove backticks, add what's new entry, squash commits, and you can haz merge. LGTM! |
Thanks @untom, for your contribution and your perseverance! |
Thanks for your review and in general for helping out with this! |
I found a small problem (?) with MaxAbsScaler and not sure whether I should file a bug report for this (because 0.17 is not officially released) So I have my collection of data scaled with MinMaxScaler. Then I need to transform a new sparse matrix with one row (sparse vector?), eg.
However, if I attempt to transform the 1-row sparse matrix above (so I can do comparison with the collection), I get this assertion error
The workaround to the problem is to use a matrix that has more than 1 row, due to this part of the code (if I am not mistaken)
|
Could you please file this as a separate issue, and also report: X.shape On 19 October 2015 at 14:15, Jeffrey04 [email protected] wrote:
|
done, thanks (: |
Just wanted to say thanks for this feature! I've already tested it out on several datasets and have found it super useful with sparse arrays. Thanks for all the hard work you've put into this, everyone! |
This PR adds the
MaxAbsScaler
andmaxabs_scale
tosklearn.preprocessing
. This scaler scales its inputs by the maximum absolute value of each feature. This scaler is especially useful for sparse data, but is probably also always a better alternative toMinMaxScaler
when the data is already centered.The scaler itself was previously discussed in #1799 and #2514.