LightMySky
En anglais

Cross-Validation and Honest Model Selection

Every choice made by looking at a set of data uses that set up, so the score on it stops being an estimate of future performance. Splitting into folds, and holding a final set back untouched, is how a reported number stays believable.

Commence ce sujetPas besoin de compte. La progression est enregistrée dans ce navigateur.

Ce que l'enfant saura faire ensuite

  • Run k-fold cross-validation to choose a penalty strength
  • Explain what leaks when the test set is used to pick anything
  • Say why a time-ordered dataset must not be split at random

1 · Lis

Every choice made by looking at a set of data uses that set up, so the score on it stops being an estimate of future performance. That is why honest analysts use cross-validation: split the data into folds, train on some, check on others, and repeat so every row gets a fair turn as the check. The average score tells you how the model behaves on data it has not memorised.

Try it together

Take 1000 rows and 5 folds. The rows split evenly, so each validation fold holds 1000 divided by 5, which is 200 rows. Each fold takes a turn as the check while the other four train, so the model is trained from scratch 5 times. To choose a penalty strength, pick the one with the best average score across the validation folds.

fold 1 checks, rest trainfold 2 checks, rest traineach fold takes one turnaverage the 5 scores

Each fold takes one turn as the check, so five folds mean five trainings and one average score.

There is a final rule that keeps everything honest: hold one set of data back completely. Do not touch it while choosing settings or comparing models. Score it once, at the very end. If you keep testing candidates on it while deciding, you quietly teach your choices to please that set, and its number stops telling the truth about the future.

When rows have no time order, assign each row to a fold at random rather than by position in the file, so the folds do not follow the file's order. But a time-ordered dataset must never be split at random: train on the older rows and validate on the rows that come after them. Random splits would put future rows into training, letting the model cheat by peeking ahead.

Choose with folds and averages, judge once on untouched data, and keep time order on the correct side of the split.

2 · Regarde

En anglais

Sans écran

Imprimer une fiche d'exercicesFormat A4, avec une page de corrigés pour les adultes. Sans écran, sans internet.

Où se situe ce sujet

Puis s'entraîner

16 questions attendent derrière cette leçon, chacune avec sa réponse expliquée. Chaque réponse nourrit le ciel : les étoiles s'allument à mesure qu'elles sont apprises, et pâlissent quand vient le moment de revenir.

Commence ce sujet