WeCodeAcademy

Cross-Validation

One train/test split can be lucky or unlucky. Cross-validation repeats the test: it cuts the data into k parts (folds), trains on k-1 of them, tests on the one left out, and rotates until each part has been the test set. You get k scores and their average is a steadier estimate.

Examplepython
Open in editor »
Quick check

With `cv=5`, how many scores does `cross_val_score` return?

Your turn: write the code

Run 3-fold cross-validation and print how many scores come back.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.