Skip to content

[MRG + 1] ENH: preprocess: adding a max-normalization option #4695

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 4 commits into from
May 11, 2015

Conversation

perimosocordiae
Copy link
Contributor

I've found that max-normalization is about as common as l1 or l2 normalization in my work, so I added that option to the preprocessing.normalize() function.

@perimosocordiae
Copy link
Contributor Author

Ah, older scipy versions don't have a .max() method for CSR matrices. Is there a workaround present in sklearn already, or should I write my own?

@amueller
Copy link
Member

amueller commented May 8, 2015

Column-wise max? I guess why not. I think you should use sklearn.utils.min_max_axis.

@perimosocordiae
Copy link
Contributor Author

Thanks! Travis is happy now.

_, norms = min_max_axis(X, 1)
norms = norms.repeat(np.diff(X.indptr))
mask = norms != 0
X.data[mask] /= norms[mask]
Copy link
Member

Choose a reason for hiding this comment

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

I feel like we should raise a ValueError "else". If you could add that and add a test, it would be much appreciated.

Copy link
Member

Choose a reason for hiding this comment

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

Never mind, missed the check above.

@amueller amueller changed the title ENH: preprocess: adding a max-normalization option [MRG + 1] ENH: preprocess: adding a max-normalization option May 11, 2015
@amueller
Copy link
Member

lgtm.

@GaelVaroquaux
Copy link
Member

LGTM. Merging. Thanks!

GaelVaroquaux added a commit that referenced this pull request May 11, 2015
[MRG + 1] ENH: preprocess: adding a max-normalization option
@GaelVaroquaux GaelVaroquaux merged commit 36df860 into scikit-learn:master May 11, 2015
@perimosocordiae perimosocordiae deleted the patch-1 branch August 25, 2016 20:06
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

Successfully merging this pull request may close these issues.

3 participants