Skip to content

RFC New parameters for penalties in LogisticRegression #28711

Closed

Description

@lorentzenchr

Based on the comment #28706 (comment):

Currently, LogisticRegression uses C as inverse penalization strength, penalty to select the type of penalty and l1_ratio to control the ration between l1 and l2 penalties.
I propose the following:

  1. Add alpha (as in Ridge, ElasticNet, PoissonRegressor ...) instead of C.
    Fail if both are given at the same time.
  2. Deprecate C.
  3. Deprecate penalty which is redundant. alpha and l1_ratio are enough.
    Update: penalty is deprecated in DEP parameter penalty in LogisticRegression and LogisticRegressionCV #32659.

Activity

  1. added
    Needs Triage
    on Mar 27, 2024
  2. changed the title [-]New parameters for penalties in LogisticRegression[/-] [+]RFC New parameters for penalties in LogisticRegression[/+] on Mar 27, 2024
  3. jeremiedbb commented on Mar 27, 2024

    @jeremiedbb
    Member

    ping @scikit-learn/core-devs for more visibility.

  4. added and removed
    Needs Triage
    on Mar 27, 2024
  5. ogrisel commented on Mar 28, 2024

    @ogrisel
    Member

    If we are to do such a big renaming, wouldn't it make sense to use a more explicit name such as l2_regularization or l2_reg?

    Also note: the alpha in lasso / GLMs and the one in ridge do not have the same meaning. One is scaled by the sum of sample weights (or n_samples) while the other is not. If we are to use a more explicit name such as l2_reg(ularization) we could use that opportunity to also make that more uniform across all linear models.

    We had a discussion in the past about whether this is intentional or not because it could lead to make efficient parametrization for parameter tuning but I think we could decouple the choice of the default parameter value (which can stay estimator specific) from the choice of the parametrization which we could choose to make uniform across all linear models to simplify the message in the narrative doc, the reference doc and the various examples.

    We could also decide to move progressively and first rename C by l2_reg and defer the decision to do a renaming/uniformization for alpha to a later time (if ever).

  6. jeremiedbb commented on Mar 28, 2024

    @jeremiedbb
    Member

    But C controls both l1 and l2 regularization (as alpha does for ElasticNet), their relative strength being controlled by l1_ratio. I'd find it confusing to rename it l2_reg and then enable l1 regularization by setting l2_reg=<some value> and l1_ratio=1.

  7. ogrisel commented on Mar 28, 2024

    @ogrisel
    Member

    Indeed l2_reg(ularization) would be a bad name: reg(ularization)_strength or just regularization might be a better name.

  8. lorentzenchr commented on Apr 1, 2024

    @lorentzenchr
    MemberAuthor

    Indeed l2_reg(ularization) would be a bad name: reg(ularization)_strength or just regularization might be a better name.

    I would prefer a consistent name among all linear models and alpha seems to be used most often as penalty strength.

    As of version 1.4:

    estimator type penalty strength parameter additional penalty parameter
    LogisticRegression classifier C penalty, l1_ratio
    PassiveAggressiveClassifier deprecated classifier C different meaning
    RidgeClassifier classifier alpha
    SGDClassifier classifier alpha penalty, l1_ratio
    Ridge regressor alpha
    SGDRegressor regressor alpha penalty, l1_ratio
    ElasticNet regressor alpha l1_ratio
    Lasso regressor alpha
    LassoLars regressor alpha
    OrthogonalMatchingPursuit regressor n_nonzero_coefs
    HuberRegressor regressor alpha
    QuantileRegressor regressor alpha
    PoissonRegressor regressor alpha
    TweedieRegressor regressor alpha
    GammaRegressor regressor alpha
    PassiveAggressiveRegressor deprecated regressor C different meaning

    See also #15657 and #30308.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions