Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lorentzenchr
Copy link
Member

Reference Issues/PRs

Partially solves #28711.

This is the the no-brainer of #32042 (comment).

What does this implement/fix? Explain your changes.

This PR

  • for class LogisticRegression
    deprecates the parameters penalty
    changes the default of l1_ratio from None to 0
  • for class LogisticRegressionCV
    deprecates the parameters penalty
    changes the default of l1_ratios from None to (0,)

Any other comments?

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

✔️ Linting Passed

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

Generated for commit: eab936a. Link to the linter CI: here

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.

Thanks for getting this is in. I just have a concern with the warning strategy for l1_ratios in LogisticRegressionCV (see below).

_raise_for_params(params, self, "fit")

solver = _check_solver(self.solver, self.penalty, self.dual)
if isinstance(self.l1_ratios, str) and self.l1_ratios == "warn":
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure we want to warn by default? I would expect LogisticRegressionCV(Cs=np.logspace(-6, 6, 13)).fit(X_train, y_train) to behave the same in 1.10 and 1.8, and so I don't see the point in warning the user when using the default. The only behavioral change would be sklearn.get_params()["l1_ratios"] which would change from None to (0.0,). I don't know we if we should consider a worse breaking change than from None to "warn".

I think we should only warn when the user explicitly passes LogisticRegressionCV(Cs=np.logspace(-6, 6, 13), l1_ratios=None).fit(X_train, y_train) instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

In that case, same as l1_ratio for LogisticRegression. I will add the changes accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

I'm easy either way, but generally speaking, we don't have the policy of things not warning when using default values. In many cases, the user has to set something to silence the warning.

Copy link
Member Author

Choose a reason for hiding this comment

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

At first, I thought so, too. In this particular case, the behavioral change ist almost none such that a „hard“ change of the default value without warning period seems justified.
As I demonstrated, I can implement either way (simply reverting eab936a eould be enough to switch).

@lorentzenchr
Copy link
Member Author

lorentzenchr commented Nov 10, 2025

I just have a concern with the warning strategy for l1_ratios in LogisticRegressionCV

I am rather indifferent to the possibilities, just say which one:
Change default of l1_ratios from None to (0,)

  1. with proper warning first, i.e. None -> "warn" now (1.8) and "warn" -> (0,) in (1.10) because it changes the shapes of attribues l1_ratios_, coefs_paths_ and scores_
  2. without warning, so just None -> (0,) in (1.8) (like l1_ratio for LogisticRegression
    This is now implemented in eab936a.

In any case, l1_ratio(s) = None should be forbidden as of (1.10).

@glemaitre glemaitre self-requested a review November 14, 2025 13:12
l1_ratio : float, default=0.0
The Elastic-Net mixing parameter, with ``0 <= l1_ratio <= 1``. Only
used if ``penalty='elasticnet'``. Setting ``l1_ratio=0`` is equivalent
Copy link
Member

Choose a reason for hiding this comment

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

I got a bit surprised with the "only used if penalty='elasticnet'".

Could we move it at the end of the paragraph instead and mention that l1_ratio has an effect with penalty is let as its default or that one force penalty="elasticnet" (but it is deprecated).

Comment on lines +43 to +49
is_logreg_l1_penalized = est_name == "LogisticRegression" and (
hasattr(estimator, "l1_ratio") and np.isclose(estimator.l1_ratio, 1.0)
)
is_logregcv_l1_penalized = est_name == "LogisticRegressionCV" and (
hasattr(estimator, "l1_ratio_")
and np.all(np.isclose(estimator.l1_ratio_, 1.0))
)
Copy link
Member

Choose a reason for hiding this comment

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

Those are not used I think.

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.

LGTM. Only 3 tiny changes.

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.

4 participants