Skip to content

LogisticRegression's regularization is scaled by the dataset size #30308

Closed

Description

@louisabraham

Describe the workflow you want to enable

Other linear models on https://scikit-learn.org/1.5/modules/linear_model.html have regularization that doesn't depend on the dataset size

Describe your proposed solution

It would be good to either change the behavior or document it very very very clearly, not only in the user guide as it is now but also in the model documentation.

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Activity

  1. added and removed
    Needs Triage
    on Nov 19, 2024
  2. glemaitre commented on Nov 19, 2024

    @glemaitre
    Member

    I don't think that we are ready to pay for the change of behaviour cost. However, I don't mind that we had a note in the docstring of the estimator.

    Just pinging @lorentzenchr if he has additional thoughts.

  3. virchan commented on Nov 20, 2024

    @virchan
    Member

    I'm not speaking on @lorentzenchr's behalf, but I came across a similar discussion on Ridge/Lasso regression where he shared an incredibly helpful comment. I believe it’s relevant to this case as well.

    That said, I still think @lorentzenchr is the best person to weigh in on this.

  4. lorentzenchr commented on Nov 22, 2024

    @lorentzenchr
    Member

    Thanks, @virchan, for your nice words and the link(s). So I don't need to repeat those arguments again.

    Documentation:
    If someone wants an improvement, then a PR is welcome.

    Model Change:

    I don't think that we are ready to pay for the change of behaviour cost.

    I see it a bit different than @glemaitre. I'm open to change the penalty parameter of all linear models to be consistent. I find the different ways of different estimators quite annoying and error-prone.
    This is, however, a decision that needs consensus among core contributors, therefore ping @scikit-learn/Core-devs.

  5. adrinjalali commented on Nov 22, 2024

    @adrinjalali
    Member

    I wouldn't mind the change to make them consistent.

  6. thomasjpfan commented on Nov 22, 2024

    @thomasjpfan
    Member

    I'm open to change the penalty parameter of all linear models to be consistent. I find the different ways of different estimators quite annoying and error-prone.

    To be backward compatible, can we add a new parameter first like scale_regularization = {"n_samples", "none"}? Then we can make everything consistent in terms of this parameter (with a deprecation cycle if it is required for that estimator).

  7. GaelVaroquaux commented on Nov 22, 2024

    @GaelVaroquaux
    Member
  8. louisabraham commented on Nov 22, 2024

    @louisabraham
    Author

    Thank you to all for paying so much attention to this problem! (and congrats for the creation of probabl)

    If I may add something, what should the default be? loss.sum() + lambda * reg or loss.mean() + lambda * reg?

    I feel like the answer should be, whichever is more stable when using CV to select the final lambda value, but I'm not sure which one it should be, aka which one selects the best lambda when evaluating on subsets.

  9. lorentzenchr commented on Feb 5, 2026

    @lorentzenchr
    Member

    See also the discussion in #28711.

  10. lorentzenchr commented on Oct 9, 2026

    @lorentzenchr
    Member

    There was an extensive discussion in #32042 and the decision was to leave the scaling of the penalty as is, i.e. 1/n sum(log loss) + alpha/n * (L1 + L2). This is simular to Ridge. Once we even had #821.

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