diff --git a/doc/modules/linear_model.rst b/doc/modules/linear_model.rst index e8bd1845628d0..b860e30fc7903 100644 --- a/doc/modules/linear_model.rst +++ b/doc/modules/linear_model.rst @@ -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 ------- diff --git a/sklearn/linear_model/_logistic.py b/sklearn/linear_model/_logistic.py index 5e51a2db6982d..788f09fdf52f4 100644 --- a/sklearn/linear_model/_logistic.py +++ b/sklearn/linear_model/_logistic.py @@ -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 @@ -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' + 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 `. Parameters @@ -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 @@ -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 ` + Refer to the :ref:`User Guide ` for more + information regarding :class:`LogisticRegression` and more specifically the + :ref:`Table ` summarizing solver/penalty supports. .. versionadded:: 0.17 @@ -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