Skip to content

Commit 223fd80

Browse files
Improve docstring: add math objective to SparseLogisticRegression
1 parent b5b9eef commit 223fd80

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

skglm/estimators.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,19 +959,28 @@ class SparseLogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstim
959959
960960
The optimization objective for sparse Logistic regression is:
961961
962-
.. math:: 1 / n_"samples" sum_(i=1)^(n_"samples") log(1 + exp(-y_i x_i^T w))
963-
+ alpha ||w||_1
962+
.. math::
963+
\frac{1}{n_{\text{samples}}} \sum_{i=1}^{n_{\text{samples}}}
964+
\log\left(1 + \exp(-y_i x_i^T w)\right)
965+
+ \alpha \cdot \left( \text{l1_ratio} \cdot \|w\|_1 +
966+
(1 - \text{l1_ratio}) \cdot \|w\|_2^2 \right)
967+
968+
By default, ``l1_ratio=1.0`` corresponds to Lasso (pure L1 penalty).
969+
When ``0 < l1_ratio < 1``, the penalty is a convex combination of L1 and L2
970+
(i.e., ElasticNet). ``l1_ratio=0.0`` corresponds to Ridge (pure L2), but note
971+
that pure Ridge is not typically used with this class.
964972
965973
Parameters
966974
----------
967975
alpha : float, default=1.0
968976
Regularization strength; must be a positive float.
969977
970978
l1_ratio : float, default=1.0
971-
The ElasticNet mixing parameter, with ``0 <= l1_ratio <= 1``. For
972-
``l1_ratio = 0`` the penalty is an L2 penalty. ``For l1_ratio = 1`` it
973-
is an L1 penalty. For ``0 < l1_ratio < 1``, the penalty is a
974-
combination of L1 and L2.
979+
The ElasticNet mixing parameter, with ``0 <= l1_ratio <= 1``.
980+
Only used when ``penalty="l1_plus_l2"``.
981+
For ``l1_ratio = 0`` the penalty is an L2 penalty.
982+
``For l1_ratio = 1`` it is an L1 penalty.
983+
For ``0 < l1_ratio < 1``, the penalty is a combination of L1 and L2.
975984
976985
tol : float, optional
977986
Stopping criterion for the optimization.

0 commit comments

Comments
 (0)