Concept

Cross-Validation in scikit-learn

from sklearn.model_selection import cross_val_score cv_scores = cross_val_score(clf, X, y, cv)

clf is the model we want to evaluate, X is the data set, y is the corresponding ground truth target labels or values, cv is the number of folds.

By default, cross_val_score does threefold cross-validation, which will return a list of three accuracy scores, one for each of the three folds. We can take the mean value as the accuracy of the model on average.

0

3

Updated 2021-09-19

Tags

Helpful Scikit-Learn functions

Data Science