Skip to content
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

MNT Speed up plot_sparse_logistic_regression_20newsgroups.py #21773

Conversation

mrleu
Copy link
Contributor

@mrleu mrleu commented Nov 24, 2021

Hello! First time contributing. Please tell me if I have done something wrong! Thank you!

Reference Issues/PRs

Fixes #21598

What does this implement/fix? Explain your changes.

Specifically, speed up examples/linear_model/plot_sparse_logistic_regression_20newsgroups.py from 18.05 seconds to 4.59 seconds.

I've updated the number of epochs and training labels to speed it up. Also confirmed the expected result where multinomial logistic regression is more accurate and faster than 1 vs all L1 logistic regression.

Any other comments?

@mrleu
Copy link
Contributor Author

mrleu commented Nov 24, 2021

Here's the graph for before:
image
speed test -

Here's after:
image
speed test -
image

@adrinjalali adrinjalali mentioned this pull request Nov 24, 2021
41 tasks
@glemaitre
Copy link
Member

On the CI, the change does not show the improvement but actually a slowdown (30 seconds instead of 20 seconds). I assume that here there is some convergence issue that reducing the number of samples does not mean necessarily that we will speed up the convergence. Quite fun as well that scaling data make things worse.

@glemaitre
Copy link
Member

It might only be bad luck regarding the node that we got on the CI thought. Locally, I can observe the speed up

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

It might be enough then.

@glemaitre glemaitre changed the title Speed up plot_sparse_logistic_regression_20newsgroups.py MNT Speed up plot_sparse_logistic_regression_20newsgroups.py Nov 25, 2021
@mrleu
Copy link
Contributor Author

mrleu commented Nov 25, 2021

image

Jokes aside, I've observed the speedup running multiple times locally.

@mrleu mrleu requested a review from glemaitre November 25, 2021 19:16
Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM.

@ogrisel ogrisel merged commit 0852d7b into scikit-learn:main Nov 26, 2021
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Nov 29, 2021
samronsin pushed a commit to samronsin/scikit-learn that referenced this pull request Nov 30, 2021
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Dec 24, 2021
glemaitre pushed a commit that referenced this pull request Dec 25, 2021
mathijs02 pushed a commit to mathijs02/scikit-learn that referenced this pull request Dec 27, 2022
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.

Accelerate slow examples
3 participants