Testing Your AIK-Fold Cross-Validation
Instead of hoping for a fair split, let every farm take a turn in the validation set. That is k-fold cross-validation.
Here is the recipe:
- Cut the data into equal parts, called folds.
- Hold out one fold for validation, train on all the others, and score the model on the held-out fold.
- Repeat with each fold in turn, starting a fresh model every time, until every fold has been held out once.
- Average the scores. That average is the cross-validation score.
Each row below is one round: the teal squares are the farms held out, the blue ones the farms the model trains on. The chart under the button keeps the average error of every k you run. Choose k, run the folds and complete both missions.
Number of folds: k =
With 5 folds the five scores were 0.72, 0.30, 0.08, 0.34 and 0.48 — as wide a spread as the random splits. But their average, 0.38, uses every farm once for validation, so it does not depend on one lucky or unlucky fold. The catch: k-fold trains a new model