sklearn.model_selection#

Tools for model selection, such as cross validation and hyper-parameter tuning.

User guide. See the Cross-validation: evaluating estimator performance, Tuning the hyper-parameters of an estimator, and Learning curve sections for further details.

Splitters#

GroupKFold

K-fold iterator variant with non-overlapping groups.

GroupShuffleSplit

Shuffle-Group(s)-Out cross-validation iterator.

KFold

K-Fold cross-validator.

LeaveOneGroupOut

Leave One Group Out cross-validator.

LeaveOneOut

Leave-One-Out cross-validator.

LeavePGroupsOut

Leave P Group(s) Out cross-validator.

LeavePOut

Leave-P-Out cross-validator.

PredefinedSplit

Predefined split cross-validator.

RepeatedKFold

Repeated K-Fold cross validator.

RepeatedStratifiedKFold

Repeated Stratified K-Fold cross validator.

ShuffleSplit

Random permutation cross-validator.

StratifiedGroupKFold

Stratified K-Fold iterator variant with non-overlapping groups.

StratifiedKFold

Stratified K-Fold cross-validator.

StratifiedShuffleSplit

Stratified ShuffleSplit cross-validator.

TimeSeriesSplit

Time Series cross-validator.

check_cv

Input checker utility for building a cross-validator.

train_test_split

Split arrays or matrices into random train and test subsets.

Hyper-parameter optimizers#

GridSearchCV

Exhaustive search over specified parameter values for an estimator.

HalvingGridSearchCV

Search over specified parameter values with successive halving.

HalvingRandomSearchCV

Randomized search on hyper parameters.

ParameterGrid

Grid of parameters with a discrete number of values for each.

ParameterSampler

Generator on parameters sampled from given distributions.

RandomizedSearchCV

Randomized search on hyper parameters.

Post-fit model tuning#

FixedThresholdClassifier

Binary classifier that manually sets the decision threshold.

TunedThresholdClassifierCV

Classifier that post-tunes the decision threshold using cross-validation.

Model validation#

cross_val_predict

Generate cross-validated estimates for each input data point.

cross_val_score

Evaluate a score by cross-validation.

cross_validate

Evaluate metric(s) by cross-validation and also record fit/score times.

learning_curve

Learning curve.

permutation_test_score

Evaluate the significance of a cross-validated score with permutations.

validation_curve

Validation curve.

Visualization#

LearningCurveDisplay

Learning Curve visualization.

ValidationCurveDisplay

Validation Curve visualization.