Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

FIX use objective instead of loss for convergence in SGD #30031

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
Loading
from

Conversation

glemaitre
Copy link
Member

@glemaitre glemaitre commented Oct 8, 2024

closes #30027

When no early-stopping is used in SGD estimator, the stopping criterion should be based on the value of the objective function (loss function + regularization terms). However, currently only the loss function is used to decide whether or not the estimator converged.

So as a solution here, I proposed to modify the WeightVector Cython class such that it also compute the L1-norm on the fly and then in the case that early-stopping is not activated, then we compute the objective function instead of solely the loss function and use it as a stopping criterion.

Things that I'm not sure at this stage:

  • I did not check if I properly handle the intercept
  • I am not sure to know what is the interaction with the tolerance: is the parameter super sensitive and should always be tweak depending of the problem at hand (i.e. regression or classifiation)?

Copy link

github-actions bot commented Oct 8, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 8c38943. Link to the linter CI: here

@glemaitre
Copy link
Member Author

@ogrisel @jeremiedbb @antoinebaker

I'm not myself super familiar with the SGD and I would be happy to have some eyes on this PR if you thinking that this would go in the right direction or it does not make any sense.

@jeremiedbb
Copy link
Member

To me it makes sense to set the stopping criterion on the objective function instead of the loss, at least because of the way convergence is checked here, i.e. small enough decrease.

Indeed, the objective function is guaranteed to decrease at each epoch which is not the case for the loss. So there are 2 ways to fix this: use the objective function or check on a small enough change instead of decrease. I think the first option chose in this PR is fine.

Looking at the diff here, it looks like the tol is compared with the absolute difference of the loss/objective. It's not user friendly because scaling the dataset by some factor will lead to a different result if you keep the same tol. I really think that we should compare the tol against a relative diff of the objective function.

@glemaitre
Copy link
Member Author

I really think that we should compare the tol against a relative diff of the objective function.

This is a good point and we should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SGDOneClassSVM model does not converge with default stopping criteria(stops prematurely)
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.