Skip to content

linear_model.LogisticRegression's penalty=None case documentation #34090

Closed

Description

@kuraga

Describe the issue linked to the documentation

linear_model.LogisticRegression's penalty documentation says:

Deprecated since version 1.8: penalty was deprecated in version 1.8 and will be removed in 1.10. Use l1_ratio instead. l1_ratio=0 for penalty='l2', l1_ratio=1 for penalty='l1' and l1_ratio set to any float between 0 and 1 for 'penalty='elasticnet'.
  1. What about penalty=None case? It's omitted here.
    But

https://github.com/scikit-learn/scikit-learn/blob/fe2edb3cd/sklearn/linear_model/_logistic.py#L1135-L1145

  1. The code above doesn't contain penalty='elasticnet' case.

  2. Are integers intentional instead of floats here? l1_ratio is : float, when 0, 1 are integers.

Suggest a potential alternative/fix

No response

Activity

  1. parthbhattpy commented on May 22, 2026

    @parthbhattpy

    Hi, I’d be interested in helping with this documentation clarification issue.

    From my understanding, the current documentation explains how l1_ratio maps to the deprecated penalty values for 'l1', 'l2', and 'elasticnet', but does not mention the penalty=None case, which can make the transition guidance incomplete.

    I also noticed the implementation/documentation mismatch mentioned in the issue regarding the elasticnet handling.

    Once the issue is triaged, I’d be happy to work on a documentation clarification PR if that would be helpful.

    Parth Bhatt

  2. StefanieSenger commented on May 24, 2026

    @StefanieSenger
    Member

    Hi @kuraga, thanks for reporting. I agree this is inconsistently documented and we should

    1. mention the no-penalty case in the deprecation message and
    2. how to use elasticnet in the FutureWarning.

    Happy if you or @parthbhattpy want to go forward and open a PR with a doc fix.

  3. removed
    Needs Triage
    on May 24, 2026
  4. baynecheke commented on May 25, 2026

    @baynecheke
    Contributor

    I've opened a PR for this: #34107

  5. kuraga commented on May 26, 2026

    @kuraga
    Author

    @jeremiedbb thanks on merge!

    Are there some thoughts on p. 3 ?

  6. StefanieSenger commented on May 27, 2026

    @StefanieSenger
    Member

    Are integers intentional instead of floats here? l1_ratio is : float, when 0, 1 are integers.

    On point 3, I think we could improve the docs as well. Of cause ints like 0 and 1 as also passable, but I'd suggest users to pass 0.0 and 1.0 in the docs, simply to make it more obvious that you can also pass 0.5, if you like.

  7. jeremiedbb commented on May 27, 2026

    @jeremiedbb
    Member

    tbh I wouldn't care too much. The docstring is already clear about l1_ratio being a float. Here we're talking about a deprecation notice that will be remove for the next release. In addition, the warnings mention "a float between 0 and 1" now so I really don't see where there could be a confusion (I expect that passing 1 is the same as passing 1.0).

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