8000 MNT Removed deprecated logistic_regression_path (#15791) · scikit-learn/scikit-learn@5573abb · GitHub
[go: up one dir, main page]

Skip to content

Commit 5573abb

Browse files
NicolasHugthomasjpfan
authored andcommitted
MNT Removed deprecated logistic_regression_path (#15791)
1 parent 4cdbde3 commit 5573abb

File tree

4 files changed

+1
-184
lines changed

4 files changed

+1
-184
lines changed

doc/modules/classes.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,5 +1623,4 @@ To be removed in 0.23
16231623
utils.delayed
16241624
metrics.calinski_harabaz_score
16251625
metrics.jaccard_similarity_score
1626-
linear_model.logistic_regression_path
16271626
utils.safe_indexing

sklearn/linear_model/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
from ._stochastic_gradient import SGDClassifier, SGDRegressor
2121
from ._ridge import (Ridge, RidgeCV, RidgeClassifier, RidgeClassifierCV,
2222
ridge_regression)
23-
from ._logistic import (LogisticRegression, LogisticRegressionCV,
24-
logistic_regression_path)
23+
from ._logistic import LogisticRegression, LogisticRegressionCV
2524
from ._omp import (orthogonal_mp, orthogonal_mp_gram,
2625
OrthogonalMatchingPursuit, OrthogonalMatchingPursuitCV)
2726
from ._passive_aggressive import PassiveAggressiveClassifier
@@ -71,7 +70,6 @@
7170
'lars_path',
7271
'lars_path_gram',
7372
'lasso_path',
74-
'logistic_regression_path',
7573
'orthogonal_mp',
7674
'orthogonal_mp_gram',
7775
'ridge_regression',

sklearn/linear_model/_logistic.py

Lines changed: 0 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -476,178 +476,6 @@ def _check_multi_class(multi_class, solver, n_classes):
476476
return multi_class
477477

478478

479-
@deprecated('logistic_regression_path was deprecated in version 0.21 and '
480-
'will be removed in version 0.23.0')
481-
def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True,
482-
max_iter=100, tol=1e-4, verbose=0,
483-
solver='lbfgs', coef=None,
484-
class_weight=None, dual=False, penalty='l2',
485-
intercept_scaling=1., multi_class='auto',
486-
random_state=None, check_input=True,
487-
max_squared_sum=None, sample_weight=None,
488-
l1_ratio=None):
489-
"""Compute a Logistic Regression model for a list of regularization
490-
parameters.
491-
492-
This is an implementation that uses the result of the previous model
493-
to speed up computations along the set of solutions, making it faster
494-
than sequentially calling LogisticRegression for the different parameters.
495-
Note that there will be no speedup with liblinear solver, since it does
496-
not handle warm-starting.
497-
498-
.. deprecated:: 0.21
499-
``logistic_regression_path`` was deprecated in version 0.21 and will
500-
be removed in 0.23.
501-
502-
Read more in the :ref:`User Guide <logistic_regression>`.
503-
504-
Parameters
505-
----------
506-
X : array-like or sparse matrix, shape (n_samples, n_features)
507-
Input data.
508-
509-
y : array-like, shape (n_samples,) or (n_samples, n_targets)
510-
Input data, target values.
511-
512-
pos_class : int, None
513-
The class with respect to which we perform a one-vs-all fit.
514-
If None, then it is assumed that the given problem is binary.
515-
516-
Cs : int | array-like, shape (n_cs,)
517-
List of values for the regularization parameter or integer specifying
518-
the number of regularization parameters that should be used. In this
519-
case, the parameters will be chosen in a logarithmic scale between
520-
1e-4 and 1e4.
521-
522-
fit_intercept : bool
523-
Whether to fit an intercept for the model. In this case the shape of
524-
the returned array is (n_cs, n_features + 1).
525-
526-
max_iter : int
527-
Maximum number of iterations for the solver.
528-
529-
tol : float
530-
Stopping criterion. For the newton-cg and lbfgs solvers, the iteration
531-
will stop when ``max{|g_i | i = 1, ..., n} <= tol``
532-
where ``g_i`` is the i-th component of the gradient.
533-
534-
verbose : int
535-
For the liblinear and lbfgs solvers set verbose to any positive
536-
number for verbosity.
537-
538-
solver : {'lbfgs', 'newton-cg', 'liblinear', 'sag', 'saga'}
539-
Numerical solver to use.
540-
541-
coef : array-like, shape (n_features,), default None
542-
Initialization value for coefficients of logistic regression.
543-
Useless for liblinear solver.
544-
545-
class_weight : dict or 'balanced', optional
546-
Weights associated with classes in the form ``{class_label: weight}``.
547-
If not given, all classes are supposed to have weight one.
548-
549-
The "balanced" mode uses the values of y to automatically adjust
550-
weights inversely proportional to class frequencies in the input data
551-
as ``n_samples / (n_classes * np.bincount(y))``.
552-
553-
Note that these weights will be multiplied with sample_weight (passed
554-
through the fit method) if sample_weight is specified.
555-
556-
dual : bool
557-
Dual or primal formulation. Dual formulation is only implemented for
558-
l2 penalty with liblinear solver. Prefer dual=False when
559-
n_samples > n_features.
560-
561-
penalty : str, 'l1', 'l2', or 'elasticnet'
562-
Used to specify the norm used in the penalization. The 'newton-cg',
563-
'sag' and 'lbfgs' solvers support only l2 penalties. 'elasticnet' is
564-
only supported by the 'saga' solver.
565-
566-
intercept_scaling : float, default 1.
567-
Useful only when the solver 'liblinear' is used
568-
and self.fit_intercept is set to True. In this case, x becomes
569-
[x, self.intercept_scaling],
570-
i.e. a "synthetic" feature with constant value equal to
571-
intercept_scaling is appended to the instance vector.
572-
The intercept becomes ``intercept_scaling * synthetic_feature_weight``.
573-
574-
Note! the synthetic feature weight is subject to l1/l2 regularization
575-
as all other features.
576-
To lessen the effect of regularization on synthetic feature weight
577-
(and therefore on the intercept) intercept_scaling has to be increased.
578-
579-
multi_class : {'ovr', 'multinomial', 'auto'}, default='auto'
580-
If the option chosen is 'ovr', then a binary problem is fit for each
581-
label. For 'multinomial' the loss minimised is the multinomial loss fit
582-
across the entire probability distribution, *even when the data is
583-
binary*. 'multinomial' is unavailable when solver='liblinear'.
584-
'auto' selects 'ovr' if the data is binary, or if solver='liblinear',
585-
and otherwise selects 'multinomial'.
586-
587-
.. versionadded:: 0.18
588-
Stochastic Average Gradient descent solver for 'multinomial' case.
589-
.. versionchanged:: 0.22
590-
Default changed from 'ovr' to 'auto' in 0.22.
591-
592-
random_state : int, RandomState instance or None, optional, default None
593-
The seed of the pseudo random number generator to use when shuffling
594-
the data. If int, random_state is the seed used by the random number
595-
generator; If RandomState instance, random_state is the random number
596-
generator; If None, the random number generator is the RandomState
597-
instance used by `np.random`. Used when ``solver`` == 'sag' or
598-
'liblinear'.
599-
600-
check_input : bool, default True
601-
If False, the input arrays X and y will not be checked.
602-
603-
max_squared_sum : float, default None
604-
Maximum squared sum of X over samples. Used only in SAG solver.
605-
If None, it will be computed, going through all the samples.
606-
The value should be precomputed to speed up cross validation.
607-
608-
sample_weight : array-like, shape(n_samples,) optional
609-
Array of weights that are assigned to individual samples.
610-
If not provided, then each sample is given unit weight.
611-
612-
l1_ratio : float or None, optional (default=None)
613-
The Elastic-Net mixing parameter, with ``0 <= l1_ratio <= 1``. Only
614-
used if ``penalty='elasticnet'``. Setting ``l1_ratio=0`` is equivalent
615-
to using ``penalty='l2'``, while setting ``l1_ratio=1`` is equivalent
616-
to using ``penalty='l1'``. For ``0 < l1_ratio <1``, the penalty is a
617-
combination of L1 and L2.
618-
619-
Returns
620-
-------
621-
coefs : ndarray, shape (n_cs, n_features) or (n_cs, n_features + 1)
622-
List of coefficients for the Logistic Regression model. If
623-
fit_intercept is set to True then the second dimension will be
624-
n_features + 1, where the last item represents the intercept. For
625-
``multiclass='multinomial'``, the shape is (n_classes, n_cs,
626-
n_features) or (n_classes, n_cs, n_features + 1).
627-
628-
Cs : ndarray
629-
Grid of Cs used for cross-validation.
630-
631-
n_iter : array, shape (n_cs,)
632-
Actual number of iteration for each Cs.
633-
634-
Notes
635-
-----
636-
You might get slightly different results with the solver liblinear than
637-
with the others since this uses LIBLINEAR which penalizes the intercept.
638-
639-
.. versionchanged:: 0.19
640-
The "copy" parameter was removed.
641-
"""
642-
643-
return _logistic_regression_path(
644-
X, y, pos_class=None, Cs=10, fit_intercept=True, max_iter=100,
645-
tol=1e-4, verbose=0, solver='lbfgs', coef=None, class_weight=None,
646-
dual=False, penalty='l2', intercept_scaling=1., multi_class='auto',
647-
random_state=None, check_input=True, max_squared_sum=None,
648-
sample_weight=None, l1_ratio=None)
649-
650-
651479
def _logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True,
652480
max_iter=100, tol=1e-4, verbose=0,
653481
solver='lbfgs', coef=None,

sklearn/linear_model/tests/test_logistic.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from sklearn.exceptions import ConvergenceWarning
3434
from sklearn.linear_model._logistic import (
3535
LogisticRegression,
36-
logistic_regression_path,
3736
_logistic_regression_path, LogisticRegressionCV,
3837
_logistic_loss_and_grad, _logistic_grad_hess,
3938
_multinomial_grad_hess, _logistic_loss,
@@ -1738,13 +1737,6 @@ def fit(X, y, **kw):
17381737
solver=solver).coef_)
17391738

17401739

1741-
def test_logistic_regression_path_deprecation():
1742-
1743-
assert_warns_message(FutureWarning,
1744-
"logistic_regression_path was deprecated",
1745-
logistic_regression_path, X, Y1)
1746-
1747-
17481740
@pytest.mark.parametrize('solver', ('lbfgs', 'newton-cg', 'sag', 'saga'))
17491741
def test_penalty_none(solver):
17501742
# - Make sure warning is raised if penalty='none' and C is set to a

0 commit comments

Comments
 (0)
0