10000 [MRG] Created 'cross-validation estimator' entry in glossary (#11661) · lithuak/scikit-learn@b725921 · GitHub
[go: up one dir, main page]

Skip to content

Commit b725921

Browse files
NicolasHugamueller
authored andcommitted
[MRG] Created 'cross-validation estimator' entry in glossary (scikit-learn#11661)
* Created 'cross-validation estimator' in glossary and referenced it where needed * Addressed adrinjalali comments * updated glossary entry * updaed docstrings according to commets
1 parent 58228cb commit b725921

File tree

9 files changed

+52
-10
lines changed

9 files changed

+52
-10
lines changed

doc/glossary.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,22 @@ such as:
955955
and do not provide :term:`set_params` or :term:`get_params`.
956956
Parameter validation may be performed in ``__init__``.
957957

958+
cross-validation estimator
959+
An estimator that has built-in cross-validation capabilities to
960+
automatically select the best hyper-parameters (see the :ref:`User
961+
Guide <grid_search>`). Some example of cross-validation estimators
962+
are :class:`ElasticNetCV <linear_model.ElasticNetCV>` and
963+
:class:`LogisticRegressionCV <linear_model.LogisticRegressionCV>`.
964+
Cross-validation estimators are named `EstimatorCV` and tend to be
965+
roughly equivalent to `GridSearchCV(Estimator(), ...)`. The
966+
advantage of using a cross-validation estimator over the canonical
967+
`Estimator` class along with :ref:`grid search <grid_search>` is
968+
that they can take advantage of warm-starting by reusing precomputed
969+
results in the previous steps of the cross-validation process. This
970+
generally leads to speed improvements. An exception is the
971+
:class:`RidgeCV <linear_model.RidgeCV>` class, which can instead
972+
perform efficient Leave-One-Out CV.
973+
958974
scorer
959975
A non-estimator callable object which evaluates an estimator on given
960976
test data, returning a number. Unlike :term:`evaluation metrics`,

sklearn/calibration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
class CalibratedClassifierCV(BaseEstimator, ClassifierMixin):
3131
"""Probability calibration with isotonic regression or sigmoid.
3232
33+
See glossary entry for :term:`cross-validation estimator`.
34+
3335
With this class, the base_estimator is fit on the train set of the
3436
cross-validation generator and the test set is used for calibration.
3537
The probabilities for each of the folds are then averaged

sklearn/covariance/graph_lasso_.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ def graphical_lasso_path(X, alphas, cov_init=None, X_test=None, mode='cd',
467467

468468

469469
class GraphicalLassoCV(GraphicalLasso):
470-
"""Sparse inverse covariance w/ cross-validated choice of the l1 penalty
470+
"""Sparse inverse covariance w/ cross-validated choice of the l1 penalty.
471+
472+
See glossary entry for :term:`cross-validation estimator`.
471473
472474
Read more in the :ref:`User Guide <sparse_inverse_covariance>`.
473475
@@ -875,7 +877,9 @@ class GraphLasso(GraphicalLasso):
875877
@deprecated("The 'GraphLassoCV' was renamed to 'GraphicalLassoCV' "
876878
"in version 0.20 and will be removed in 0.22.")
877879
class GraphLassoCV(GraphicalLassoCV):
878-
"""Sparse inverse covariance w/ cross-validated choice of the l1 penalty
880+
"""Sparse inverse covariance w/ cross-validated choice of the l1 penalty.
881+
882+
See glossary entry for :term:`cross-validation estimator`.
879883
880884
This class implements the Graphical Lasso algorithm.
881885

sklearn/feature_selection/rfe.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ class RFECV(RFE, MetaEstimatorMixin):
325325
"""Feature ranking with recursive feature elimination and cross-validated
326326
selection of the best number of features.
327327
328+
See glossary entry for :term:`cross-validation estimator`.
329+
328330
Read more in the :ref:`User Guide <rfe>`.
329331
330332
Parameters

sklearn/linear_model/coordinate_descent.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,9 @@ def fit(self, X, y):
12461246

12471247

12481248
class LassoCV(LinearModelCV, RegressorMixin):
1249-
"""Lasso linear model with iterative fitting along a regularization path
1249+
"""Lasso linear model with iterative fitting along a regularization path.
1250+
1251+
See glossary entry for :term:`cross-validation estimator`.
12501252
12511253
The best model is selected by cross-validation.
12521254
@@ -1411,9 +1413,9 @@ def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
14111413

14121414

14131415
class ElasticNetCV(LinearModelCV, RegressorMixin):
1414-
"""Elastic Net model with iterative fitting along a regularization path
1416+
"""Elastic Net model with iterative fitting along a regularization path.
14151417
1416-
The best model is selected by cross-validation.
1418+
See glossary entry for :term:`cross-validation estimator`.
14171419
14181420
Read more in the :ref:`User Guide <elastic_net>`.
14191421
@@ -1823,7 +1825,7 @@ def fit(self, X, y):
18231825

18241826

18251827
class MultiTaskLasso(MultiTaskElasticNet):
1826-
"""Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer
1828+
"""Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer.
18271829
18281830
The optimization objective for Lasso is::
18291831
@@ -1944,6 +1946,8 @@ def __init__(self, alpha=1.0, fit_intercept=True, normalize=False,
19441946
class MultiTaskElasticNetCV(LinearModelCV, RegressorMixin):
19451947
"""Multi-task L1/L2 ElasticNet with built-in cross-validation.
19461948
1949+
See glossary entry for :term:`cross-validation estimator`.
1950+
19471951
The optimization objective for MultiTaskElasticNet is::
19481952
19491953
(1 / (2 * n_samples)) * ||Y - XW||^Fro_2
@@ -2130,7 +2134,9 @@ def __init__(self, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
21302134

21312135

21322136
class MultiTaskLassoCV(LinearModelCV, RegressorMixin):
2133-
"""Multi-task L1/L2 Lasso with built-in cross-validation.
2137+
"""Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer.
2138+
2139+
See glossary entry for :term:`cross-validation estimator`.
21342140
21352141
The optimization objective for MultiTaskLasso is::
21362142

sklearn/linear_model/least_angle.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,9 @@ def _lars_path_residues(X_train, y_train, X_test, y_test, Gram=None,
970970

971971

972972
class LarsCV(Lars):
973-
"""Cross-validated Least Angle Regression model
973+
"""Cross-validated Least Angle Regression model.
974+
975+
See glossary entry for :term:`cross-validation estimator`.
974976
975977
Read more in the :ref:`User Guide <least_angle_regression>`.
976978
@@ -1194,7 +1196,9 @@ def alpha(self):
11941196

11951197

11961198
class LassoLarsCV(LarsCV):
1197-
"""Cross-validated Lasso, using the LARS algorithm
1199+
"""Cross-validated Lasso, using the LARS algorithm.
1200+
1201+
See glossary entry for :term:`cross-validation estimator`.
11981202
11991203
The optimization objective for Lasso is::
12001204

sklearn/linear_model/logistic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,8 @@ class LogisticRegressionCV(LogisticRegression, BaseEstimator,
14381438
LinearClassifierMixin):
14391439
"""Logistic Regression CV (aka logit, MaxEnt) classifier.
14401440
1441+
See glossary entry for :term:`cross-validation estimator`.
1442+
14411443
This class implements logistic regression using liblinear, newton-cg, sag
14421444
of lbfgs optimizer. The newton-cg, sag and lbfgs solvers support only L2
14431445
regularization with primal formulation. The liblinear solver supports both

sklearn/linear_model/omp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,9 @@ def _omp_path_residues(X_train, y_train, X_test, y_test, copy=True,
754754

755755

756756
class OrthogonalMatchingPursuitCV(LinearModel, RegressorMixin):
757-
"""Cross-validated Orthogonal Matching Pursuit model (OMP)
757+
"""Cross-validated Orthogonal Matching Pursuit model (OMP).
758+
759+
See glossary entry for :term:`cross-validation estimator`.
758760
759761
Read more in the :ref:`User Guide <omp>`.
760762

sklearn/linear_model/ridge.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,8 @@ def fit(self, X, y, sample_weight=None):
11701170
class RidgeCV(_BaseRidgeCV, RegressorMixin):
11711171
"""Ridge regression with built-in cross-validation.
11721172
1173+
See glossary entry for :term:`cross-validation estimator`.
1174+
11731175
By default, it performs Generalized Cross-Validation, which is a form of
11741176
efficient Leave-One-Out cross-validation.
11751177
@@ -1279,6 +1281,8 @@ class RidgeCV(_BaseRidgeCV, RegressorMixin):
12791281
class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV):
12801282
"""Ridge classifier with built-in cross-validation.
12811283
1284+
See glossary entry for :term:`cross-validation estimator`.
1285+
12821286
By default, it performs Generalized Cross-Validation, which is a form of
12831287
efficient Leave-One-Out cross-validation. Currently, only the n_features >
12841288
n_samples case is handled efficiently.

0 commit comments

Comments
 (0)
0