Skip to content

Conversation

@lorentzenchr
Copy link
Member

@lorentzenchr lorentzenchr commented Dec 5, 2025

Reference Issues/PRs

Warnings for alpha=0 / l1_ratio=0 where introduced in #620. A note that Enet with dual gap as stopping criterion does not converge was mentioned in #19620 (comment).

What does this implement/fix? Explain your changes.

This PR makes the coordinate descent solver of Lasso and ElasticNet etc. converge for Ridge regression.

Details

What prevents the CD solver in the main branch is that the dual gap is not valid for alpha=0 / l1_ratio=0. Fortunately, there is an alternative dual gap available, see #22836.

Any other comments?

There are some surprising results, see the new test_enet_ols_consistency.

@lorentzenchr
Copy link
Member Author

@OmarManzoor @virchan @ogrisel you might be interested

@lorentzenchr
Copy link
Member Author

As teaser: I need this for a larger surprise PR...

assert se_ols <= 1e-20
assert se_enet <= 1e-20
else:
assert se_enet <= se_ols <= 1e-20 # Who would have thought that?
Copy link
Member Author

Choose a reason for hiding this comment

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

I find this quite surprising.

Copy link
Member

Choose a reason for hiding this comment

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

Can we use assert_allclose here, since we want to check that ElasticNet(alpha=0.0) converges to Ridge? Also, I'm curious. --- what surprised you, aside from floating-point effects?

Copy link
Member

@virchan virchan left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks, @lorentzenchr!

I just have a few questions for my own understanding.

Comment on lines +179 to +181
# This is Ridge regression, we use formulation B for the dual gap.
gap = R_norm2 + 0.5 * beta * w_l2_norm2 - Ry
gap += 1 / (2 * beta) * dual_norm_XtA
Copy link
Member

Choose a reason for hiding this comment

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

I understand that this is an implementation detail. However, would it be useful to include this mathematical detail in the user guide, given that Formulation A is already covered?

assert se_ols <= 1e-20
assert se_enet <= 1e-20
else:
assert se_enet <= se_ols <= 1e-20 # Who would have thought that?
Copy link
Member

Choose a reason for hiding this comment

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

Can we use assert_allclose here, since we want to check that ElasticNet(alpha=0.0) converges to Ridge? Also, I'm curious. --- what surprised you, aside from floating-point effects?

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.

2 participants