Skip to content

DEP start deprecation of attributes in LogisticRegressionCV - #32114

Merged
adrinjalali merged 15 commits into
scikit-learn:mainfrom
lorentzenchr:dep_logistic_attributes
Nov 18, 2025
Merged

adrinjalali merged 15 commits into
scikit-learn:mainfrom
lorentzenchr:dep_logistic_attributes

Conversation

@lorentzenchr

Copy link
Copy Markdown
Member

Reference Issues/PRs

Fixes #32075.

Ideally, #32073 gets merged first.

What does this implement/fix? Explain your changes.

This PR adds the parameter LogisticRegressionCV(use_legacy_attributes=True) and implements the logic in case it is False.
A warning is raised that announces the future change of default value and the future deprecation of this new parameter.

Any other comments?

@github-actions

github-actions Bot commented Sep 5, 2025 •

Copy link
Copy Markdown

✔️ Linting Passed

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

Generated for commit: 86878c0. Link to the linter CI: here

@lorentzenchr lorentzenchr added this to the 1.8 milestone Sep 6, 2025
@lorentzenchr

Copy link
Copy Markdown
Member Author

Dear reviewers, feel free to finish in case I am unresponsive.

@adrinjalali

Copy link
Copy Markdown
Member

Oh boy, this is kinda dirty. I wish we'd simply do a v2 instead of all this deprecation. Technically, this correctly follows our policy though.

@lorentzenchr CI fails here.

I don't think there's any other way to do this. cc @jeremiedbb

@lorentzenchr

Copy link
Copy Markdown
Member Author

The failing CD is Ubuntu Jammy Jellyfish, see our file azure-pipelines.yml. It runs with the env variable SKLEARN_WARNINGS_AS_ERRORS = 1 and that's what I see, FutureWarnings turned into errors.
Could someone tell me how to circumvent this to get a green CD?

@adrinjalali

Copy link
Copy Markdown
Member

Could someone tell me how to circumvent this to get a green CD?

I don't think we should ignore those warnings, we should be fixing them making sure they're not raised in our docs and tests.

@lorentzenchr

lorentzenchr commented Nov 6, 2025 •

Copy link
Copy Markdown
Member Author

Could someone tell me how to circumvent this to get a green CD?

I don't think we should ignore those warnings, we should be fixing them making sure they're not raised in our docs and tests.

I did as I was adviced and did in #29097.
e853794 implements what you asked for. I would say it costs you 2 🍺

@glemaitre
glemaitre self-requested a review November 14, 2025 10:27

@glemaitre glemaitre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The rendering in the changelog looks broken. Locally adding a new line was solving the problem. Let's see if it would be the case on the CI.

@adrinjalali
adrinjalali merged commit a672760 into scikit-learn:main Nov 18, 2025
@lesteve

lesteve commented Nov 18, 2025

Copy link
Copy Markdown
Member

Ideally, #32073 gets merged first.

😓

@adrinjalali

Copy link
Copy Markdown
Member

Oopsi.

@lesteve

lesteve commented Nov 18, 2025 •

Copy link
Copy Markdown
Member

@lorentzenchr out of curiosity coef_paths_ is the attribute that changed the most, can you explain how you decided on the new output?

AFAICT:

  • with use_legacy_attributes=True, coefs_paths_ is a dict whose keys are classes and each value is an array with shape (n_folds, n_l1_ratios, n_cs, n_features)
  • with use_legacy_attributes=False, coefs_paths_ is an array with shape (n_folds, n_l1_ratios, n_cs, n_classes, n_features)

In other words, how did you decide to change it from a dict to an array, and why put classes in the second to last dimension?

Not sure how much we expect coefs_paths_ to be used in the wild ... if we expect to be used a bit I think it would be nice to clarify the change in the doc and the changelog, because this may trip people up. Personally I did not find this obvious at all when adapting a test in #32073 😅.

@lorentzenchr
lorentzenchr deleted the dep_logistic_attributes branch November 18, 2025 18:49
@lorentzenchr

Copy link
Copy Markdown
Member Author

LogisticRegression.coef_ has shape (n_classes, n_features) and one usually wants to slice for a "complete set of coefficients", therefore last 2 dimensions of LogisticRegressionCV.coefs_paths_ have shape (n_classes, n_features).
This really simplifies computation of the penalty term in the objective function.
I simply kept the order of (n_folds, n_l1_ratios, n_cs) for the first dimensions.

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.

RFC new fitted attributes for LogisticRegressionCV

4 participants