Repository navigation
[MRG] ENH: Improves speed of one hot encoding - #15762
Merged
Merged
Conversation
amueller
reviewed
Dec 3, 2019
| indptr[0] = 0 | ||
| np.sum(X_mask, axis=1, out=indptr[1:]) | ||
| np.cumsum(indptr[1:], out=indptr[1:]) | ||
| data = np.ones(indptr[-1]) |
Member
There was a problem hiding this comment.
The last line is the only significant change, right? Or do the other changes also matter?
Member
Author
There was a problem hiding this comment.
They all matter. If I revert the last line, I get:
wall_time cpu_time
n_samples n_features
100000 50 0.575167 1.999209
100 1.244284 2.790776
200000 50 1.424922 2.935314
100 3.083203 4.711901
500000 50 3.762984 5.473710
100 7.914155 10.137310
Member
|
Thanks @thomasjpfan |
panpiort8
pushed a commit
to panpiort8/scikit-learn
that referenced
this pull request
Mar 3, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the time it takes to run one hot encoding by about 24%.
Benchmark script
This PR
Master
CC @jorisvandenbossche