Skip to content

DOC Remove mention of deprecated multi_class in LogisticRegression #29998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/modules/linear_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,8 @@ logistic regression, see also `log-linear model
| `ElasticNet` | :math:`\frac{1 - \rho}{2}\|W\|_F^2 + \rho \|W\|_{1,1}` |
+----------------+----------------------------------------------------------------------------------+

.. _logistic_regression_solvers:

Solvers
-------

Expand Down
23 changes: 11 additions & 12 deletions sklearn/linear_model/_logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,6 @@ class LogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
"""
Logistic Regression (aka logit, MaxEnt) classifier.

In the multiclass case, the training algorithm uses the one-vs-rest (OvR)
scheme if the 'multi_class' option is set to 'ovr', and uses the
cross-entropy loss if the 'multi_class' option is set to 'multinomial'.
(Currently the 'multinomial' option is supported only by the 'lbfgs',
'sag', 'saga' and 'newton-cg' solvers.)

This class implements regularized logistic regression using the
'liblinear' library, 'newton-cg', 'sag', 'saga' and 'lbfgs' solvers. **Note
that regularization is applied by default**. It can handle both dense
Expand All @@ -827,6 +821,11 @@ class LogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
the L2 penalty. The Elastic-Net regularization is only supported by the
'saga' solver.

For :term:`multiclass` problems, only 'newton-cg', 'sag', 'saga' and 'lbfgs'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremiedbb Since we are in the long summary and we have an alternative to use OvR, I would advocate from now on to use OneVsRestClassifier. It looks legit to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright then :)

handle multinomial loss. 'liblinear' and 'newton-cholesky' only handle binary
classification but can be extended to handle multiclass by using
:class:`~sklearn.multiclass.OneVsRestClassifier`.

Read more in the :ref:`User Guide <logistic_regression>`.

Parameters
Expand Down Expand Up @@ -904,11 +903,11 @@ class LogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):

- For small datasets, 'liblinear' is a good choice, whereas 'sag'
and 'saga' are faster for large ones;
- For multiclass problems, only 'newton-cg', 'sag', 'saga' and
- For :term:`multiclass` problems, only 'newton-cg', 'sag', 'saga' and
'lbfgs' handle multinomial loss;
- 'liblinear' and 'newton-cholesky' can only handle binary classification
by default. To apply a one-versus-rest scheme for the multiclass setting
one can wrapt it with the `OneVsRestClassifier`.
one can wrap it with the :class:`~sklearn.multiclass.OneVsRestClassifier`.
- 'newton-cholesky' is a good choice for `n_samples` >> `n_features`,
especially with one-hot encoded categorical features with rare
categories. Be aware that the memory usage of this solver has a quadratic
Expand Down Expand Up @@ -936,9 +935,9 @@ class LogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstimator):
a scaler from :mod:`sklearn.preprocessing`.

.. seealso::
Refer to the User Guide for more information regarding
:class:`LogisticRegression` and more specifically the
:ref:`Table <Logistic_regression>`
Refer to the :ref:`User Guide <Logistic_regression>` for more
information regarding :class:`LogisticRegression` and more specifically the
:ref:`Table <logistic_regression_solvers>`
summarizing solver/penalty supports.

.. versionadded:: 0.17
Expand Down Expand Up @@ -1550,7 +1549,7 @@ class LogisticRegressionCV(LogisticRegression, LinearClassifierMixin, BaseEstima
because it does not handle warm-starting.
- 'liblinear' and 'newton-cholesky' can only handle binary classification
by default. To apply a one-versus-rest scheme for the multiclass setting
one can wrapt it with the `OneVsRestClassifier`.
one can wrap it with the :class:`~sklearn.multiclass.OneVsRestClassifier`.
- 'newton-cholesky' is a good choice for `n_samples` >> `n_features`,
especially with one-hot encoded categorical features with rare
categories. Be aware that the memory usage of this solver has a quadratic
Expand Down