Cross-validation tests a model several times on different slices of the data. It gives a more reliable picture than a single train-test split, especially when the dataset is small.
How k-fold cross-validation works
The data is split into k equal parts. The model trains on k minus one parts and is tested on the remaining part. This repeats k times, so each part is used once for testing. The scores are then averaged.
Why it helps
- It uses all the data for both training and testing.
- It shows whether the score is stable or depends on one lucky split.
- It helps you compare models fairly.
A caution for time data
For data in time order, such as monthly sales, do not shuffle. Use a time-based split, where the model always trains on earlier data and tests on later data.
Next step: see our data science course at ScholarLogic, or book a free demo class. A counsellor will share the fee and the next batch dates.
