Skip to content

RFC new fitted attributes for LogisticRegressionCV #32075

Closed

Description

@lorentzenchr

Contributes to #11865.

Fitted Attributes

After the removal of multi_class and any OvR-logic in LogisticRegressionCV in #32073, there are a few fitted attributes that have now (or always had) a strange data format (I neglect l1_ratios in the following for ease of reading):

  • coefs_paths_ is a dictionary with class labels as keys and arrays of shape (n_folds, n_cs, n_features) or similar as values.
    As coef_ is an array of shape (n_classes, n_features), coefs_paths_ should be an array of shape (n_folds, n_cs, n_classes, n_features), such that coefs_paths_[idx_fold, idx_cs, :, :] gives comparable coefficients. Maybe the intercept should be separated as intercepts_paths_.
  • scores_ is a dictionary with class labels as keys and arrays of shape (n_folds, n_cs) or similar as values. All values are the same regardless of the key (class label). This is a relict from OvR.
    A good value would be just an array of shape (n_folds, n_cs)
  • C_ is an array of shape (n_classes)
    As the different penalties for classes are gone with the removal of OvR, C_ should be a single float: the single best penalty parameter.
  • l1_ratio_ same as C_
  • n_iter_ is an array of shape (1, n_folds, n_cs) or similar
    The first dimension should be removed, i.e. shape (n_folds, n_cs)

Deprecation strategy

It is unclear to me how to accomplish the above. Options:

  1. Deprecate old attributes and introduce new ones with new names. (time = 2 releases)
  2. Same as 1. but then deprecate new ones and reintroduce the old names. (time = 4 releases)
  3. Deprecate old attributes and switch behavior in after the deprecation cycle (time = 2 releases)
  4. Another option?

Usually, we avoided deprecations options like 3.
@scikit-learn/core-devs recall for comments

Activity

  1. added
    Needs Triage
    on Sep 2, 2025
  2. jeremiedbb commented on Sep 3, 2025

    @jeremiedbb
    Member

    After the removal of multi-class, it doesn't make sense to keep the fitted attributes as arrays with repeated columns or arrays with an extra dimension.
    Regarding coefs_paths_ I agree that a shape of (n_folds, n_cs, n_classes, n_features) feels a lot more natural and ease indexing so I'm +1.

    Regarding the deprecation cycle, ideally we would have started it at the same time as the deprecation of multi-class but we (at least I) didn't anticipate that at the time.

    The strategy we usually use in that case is

    4. Introduce a new init parameter like `use_legacy_attributes` or something which dictates the behavior of the fitted attributes.
        It's True by default at the beginning, with a warning saying that the default will change to False and that the legacy behavior will be removed in 2 releases.
        In 2 releases, we change the default and deprecate the parameter. We also remove the legacy behavior.
        In 4 releases, we remove the deprecated parameter.
    

    It's a 4 releases cycle but the 2nd cycle is just about a useless parameter so very light.

  3. added and removed
    Needs Triage
    on Sep 3, 2025
  4. lorentzenchr commented on Sep 5, 2025

    @lorentzenchr
    MemberAuthor

    @jeremiedbb I opened #32114 to implement your option 4. Best if it gets shipped with the next (minor) release 1.8.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions