-
Notifications
You must be signed in to change notification settings - Fork 41
ENH - add support for intercept in SqrtLasso
#214
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
ENH - add support for intercept in SqrtLasso
#214
Conversation
SqrtLasso
Badr-MOUFAD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @PascalCarrivain for the PR!
Here are some remarks
mathurinm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Badr-MOUFAD merge if happy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks @PascalCarrivain for the hard work 💪
Just a small bit before merging
We didn't add tests for the intercept (we might be vulnerable to bugs later)
I'm not aware of any package to check against it the new feature, any suggestions @mathurinm?
With that being said, we can leverage the equivalence between the problem with intercept and without as the datafit is a norm_2 hence setting its gradient w.r.t. the intercept to zero implies setting the residual to zero
| if sqrt_lasso.fit_intercept: | ||
| np.testing.assert_equal(sqrt_lasso.coef_[:-1], 0) | ||
| else: | ||
| np.testing.assert_equal(sqrt_lasso.coef_, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT about this refactoring?
| if sqrt_lasso.fit_intercept: | |
| np.testing.assert_equal(sqrt_lasso.coef_[:-1], 0) | |
| else: | |
| np.testing.assert_equal(sqrt_lasso.coef_, 0) | |
| np.testing.assert_equal(sqrt_lasso.coef_[:n_features], 0) |
|
@PascalCarrivain thanks for bringing this up again ; there's a conflict that needs to be solved Also @Badr-MOUFAD how could we test against a Lasso solver ? Do you remember some formula linking the regularization strentgth of the Lasso to that of the sqrt Lasso ? |
|
Yes indeed @mathurinm there is a equivalence between SqrtLasso and Lasso if we solve the latter should be divided by |
|
Using this works: this is not the usual equivalence (one would expect a sqrt(n) not a n, so that @floriankozikowski when an intercept is fitted the scaling factor should just be |
|
Ok this works on the PR: but we have a problem, sqrt.coef_ is 1 coefficient too long, because we still store the intercept as last value. This is easy to fix @PascalCarrivain |
skglm/experimental/sqrt_lasso.py
Outdated
| self.coef_ = self.path(X, y, alphas=[self.alpha])[1][0] | ||
| self.intercept_ = 0. # TODO handle fit_intercept | ||
| if self.fit_intercept: | ||
| self.intercept_ = self.coef_[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PascalCarrivain you also need to make self.coef_ shorter by one element in that case, otherwise it still contains the itnercept as last value
Co-authored-by: Carrivain Pascal <[email protected]>
…trib#210) Signed-off-by: Julien Jerphanion <[email protected]>
…n-contrib#209) * skip upload to gh-pages if it branch not main
* add code of conduct * include code of conduct in doc * build doc options
* release 0.3.1 * update what's new * bump version to ``0.3.2dev`` * v0.3 ---> v0.4 * add release date --------- Co-authored-by: Badr-MOUFAD <[email protected]>
…it-learn-contrib#253) Co-authored-by: Badr-MOUFAD <[email protected]>
Co-authored-by: Badr-MOUFAD <[email protected]>
…arn-contrib#258) Co-authored-by: mathurinm <[email protected]> Co-authored-by: QB3 <[email protected]>
Co-authored-by: mathurinm <[email protected]> Co-authored-by: Badr-MOUFAD <[email protected]>
…earn-contrib#137) Co-authored-by: Badr-MOUFAD <[email protected]> Co-authored-by: Badr MOUFAD <[email protected]> Co-authored-by: Quentin Bertrand <[email protected]> Co-authored-by: mathurinm <[email protected]> Co-authored-by: mathurinm <[email protected]>
…learn-contrib#274) Co-authored-by: Badr-MOUFAD <[email protected]>
…sion (scikit-learn-contrib#278) Co-authored-by: mathurinm <[email protected]>
Co-authored-by: mathurinm <[email protected]>
Co-authored-by: mathurinm <[email protected]>
Co-authored-by: mathurinm <[email protected]>
…contrib#270) Co-authored-by: mathurinm <[email protected]>
…if correct, clean up, pot. add support for sparse X (not sure if that works), enhance docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@floriankozikowski remove these 3 files
|
This has become hard to read due to git errors, closing in favor of the restart #298 |
Context of the PR
This PR adds support for intercept in
SqrtLassoestimator.Closes #96
Checks before merging PR