Skip to content

MNT - fix regression introduced in #270 #304

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 2 commits into from
Apr 30, 2025

Conversation

Badr-MOUFAD
Copy link
Collaborator

@Badr-MOUFAD Badr-MOUFAD commented Apr 29, 2025

Context of the PR

fixes #302,
The regression is caused (after #270) by executing an extra initialization of the datafit with uncompiled datafit

Contributions of the PR

  • remove unnecessary initialization of the datafit

Check it fixed

import time
from skglm import Lasso
from libsvmdata import fetch_libsvm

X, y = fetch_libsvm("news20.binary")
alpha = abs(X.T @ y).max() / len(y) / 2
model = Lasso(alpha=alpha, fit_intercept=False, tol=1e-12)

# cache compilation
t0 = time.time()
model.fit(X, y)
print("Initial fit:", time.time() - t0)

for _ in range(2):
    t0 = time.time()
    model.fit(X, y)
    print("Time to fit:", time.time() - t0)

# output
# Initial fit: 2.6478769779205322
# Time to fit: 0.20598602294921875
# Time to fit: 0.22588682174682617

Checks before merging PR

  • [ ] added documentation for any new feature
  • [ ] added unit tests
  • [ ] edited the what's new (if applicable)

@Badr-MOUFAD
Copy link
Collaborator Author

back to top 💪

Screenshot 2025-04-29 at 23 07 00

@mathurinm
Copy link
Collaborator

Thanks heaps @Badr-MOUFAD, super nice catch

Side note: If you find a way to automatically test for non regression in every PR (eg exactly on this example, check that solving time does not increase), that may be super nice

@mathurinm mathurinm merged commit 3de9a7a into scikit-learn-contrib:main Apr 30, 2025
4 checks passed
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.

DOC - skglm is slow on news20.binary
2 participants