Skip to main content

Module model_selection

Module model_selection 

Source
Expand description

Model selection: k-fold and stratified cross-validation, and grid search over hyperparameters.

See the book entry Cross-validation and grid search.

Structs§

GridSearchResult
The outcome of a grid search.

Functions§

cross_validate_classifier
Scores a classifier on each split (see cross_validate_regressor).
cross_validate_regressor
Scores a regressor on each split: make builds a fresh model, which is fitted on the training rows and scored on the test rows by score(truth, predicted).
grid_search
Evaluates every candidate (typically by the mean of a cross-validation) and keeps the best, by largest score with greater_is_better or smallest otherwise. Candidates whose evaluation fails or returns NaN are skipped.
k_fold
folds train/test splits of 0..samples: every sample is tested exactly once, and fold sizes differ by at most one. With a seed the samples are shuffled first.
mean_score
The mean of a slice of scores.
parameter_grid
Every combination of the values on each axis (the Cartesian product), first axis slowest.
stratified_k_fold
Stratified k-fold: each class is dealt round-robin across the folds (after a seeded shuffle within the class), so every fold has nearly the overall class proportions.

Type Aliases§

Split
A train/test split as index lists.