One test split can be lucky or unlucky. Several are fairer.
Direct answer
Cross-validation estimates how well a model will perform on new data by training and testing on several different splits. In k-fold cross-validation, data is divided into k parts. Each part is the test set once, and the results are averaged.
Example
from sklearn.model_selection import cross_val_score
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
scores = cross_val_score(DecisionTreeClassifier(max_depth=3), X, y, cv=5)
print(scores.mean(), scores.std())
Why use it
- More reliable than a single split.
- Uses all data for both training and testing.
- Helps compare models and settings.
Cautions
- Keep a final test set aside.
- For time series, use time-aware splits.
Where Teyro fits
Teyro's Machine Learning for Beginners course turns this into short lessons you can play in a few minutes a day. It has 200 lessons, and you can start free.
The bottom line
Average across folds for a steadier estimate.



