← All tutorials

GoCareerGo Tutorials

Machine Learning Tutorial

Supervised learning, classification, neural networks and core ML algorithms.

Cross-Validation

k-fold cross-validation splits data into k parts, trains on k-1 and tests on the remaining fold, rotating through all k combinations — giving a more reliable performance estimate than one train/test split.

from sklearn.model_selection import cross_val_score

scores = cross_val_score(model, X, y, cv=5)
print(scores.mean())