You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RFC new fitted attributes for LogisticRegressionCV #32075
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:
Deprecate old attributes and introduce new ones with new names. (time = 2 releases)
Same as 1. but then deprecate new ones and reintroduce the old names. (time = 4 releases)
Deprecate old attributes and switch behavior in after the deprecation cycle (time = 2 releases)
Another option?
Usually, we avoided deprecations options like 3.
@scikit-learn/core-devs recall for comments
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.
Activity
jeremiedbb commentedon Sep 3, 2025
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-classbut we (at least I) didn't anticipate that at the time.The strategy we usually use in that case is
It's a 4 releases cycle but the 2nd cycle is just about a useless parameter so very light.
lorentzenchr commentedon Sep 5, 2025
@jeremiedbb I opened #32114 to implement your option 4. Best if it gets shipped with the next (minor) release 1.8.