AI Foundations for Students | 014. Training, Validation and Testing
AI Foundations for Students · Lesson 14 of 36
Module 3: Machine Learning on Paper
In this lesson
Learning goal: Separate model learning, tuning and final testing; spot information leakage.
Why not test on the practice answers?
Suppose you memorize six vocabulary cards, then correctly repeat those exact six cards. You have shown recall of that set, but not necessarily an ability to handle new words. Machine-learning evaluation has a similar problem: success on examples used to build a model is not sufficient evidence of performance on new examples. We therefore separate the roles played by different data.
Training data helps fit the model. Validation data helps compare choices during development. Test data is reserved for a final evaluation after those choices are fixed. These are roles, not magic percentage formulas. The right split depends on the task, amount of data and how future inputs will arrive. A tiny classroom exercise illustrates the logic but cannot establish real-world reliability.
Use sealed paper packs
For a fictional envelope classifier, prepare three packs. Training contains T1: 6 cm small; T2: 8 cm small; T3: 12 cm large; T4: 14 cm large. Validation contains V1: 9 cm small and V2: 10 cm large. The sealed test pack contains Q1: 7 cm small and Q2: 11 cm large. All labels follow the activity rule: below 10 cm is small; 10 cm or more is large.
Compare candidate models using training and validation, then write down the chosen model before inspecting test results. This fully printed pack and its labeling policy make this activity a worked demonstration, not evidence from an unseen test. To practice the held-out procedure, ask a partner to prepare a separate fictional pack, keep that pack out of model choice, and record predictions before revealing its labels. Even a fresh small pack supplies only limited classroom evidence.
Leakage makes success look easier
Information leakage occurs when information crosses a boundary that the intended task or evaluation depends on. Examples include using reserved test answers to choose the model, or using a feature that would be unavailable when real predictions are needed. Using the training labels to fit a supervised model is expected; using held-out test labels for that fitting is not. A simple example is putting the same physical envelope in training under one ID and testing under another. Another is using the correct target category as an input feature while pretending to predict that category.
Timing can also matter. If predicting whether a club session will be crowded before it starts, the final attendance count is not an available advance feature. Including it could produce a striking score without solving the intended problem. Ask not only whether a column exists in a file, but whether it would be available legitimately at the moment of use.
Validation can guide; testing should not secretly tune
Imagine one candidate uses a threshold of 9 cm and another uses 10 cm. On V1, the 9 cm threshold wrongly labels 9 cm as large; the 10 cm threshold labels it small. V2 is large under both. Validation therefore favors 10 cm on these two examples. This is a development decision, not an independent final result.
After selecting the threshold, test once on the held-out examples and report the result. If you inspect a test error and change the model, you have learned from that test. Keep the result, explain the revision and obtain fresh held-out evidence for a new final claim. Renaming the old test file does not make its examples unseen again.
Match the split to the real question
Randomly splitting related records can give misleading confidence. If several photographs show the same object, separate photographs of it may be too similar to provide a genuinely new-object test. Keep related examples together when the intended challenge is new objects. If the goal concerns future conditions, a time-based evaluation may be more appropriate than mixing earlier and later records.
You do not need advanced statistics to ask the key beginner question: “What is new about this test, and does that match what will be new during use?” Also record sample size. Two held-out envelopes provide a useful classroom demonstration, but two correct predictions are weak evidence for a wide range of future widths, materials and measurement errors.
Worked practice
Worked exercise 1: Choose with validation
Task: A model predicts large at width at least 9 cm. Another predicts large at width at least 10 cm. Score both on V1: 9 small and V2: 10 large.
Worked solution: Threshold 9 predicts large for both, so it gets V1 wrong and V2 right: 1/2. Threshold 10 predicts small for 9 and large for 10: 2/2. Choose threshold 10 based on this validation comparison. Do not call those validation scores the final held-out test results.
Worked exercise 2: Find duplicated-object leakage
Task: Training includes envelope E1 photographed on a blue desk. Test includes the same E1 photographed on a white desk. The goal is performance on new envelopes. What is the problem?
Worked solution: The test contains a previously seen object even though the photograph differs. That can make the new-envelope challenge easier than intended. Keep all views of an object in the same split, then test on genuinely different objects. Record the grouping rule so another person can reproduce the split.
Worked exercise 3: Explain an honest retest
Task: A team changes its threshold after seeing a test mistake and then gets every old test case correct. What should the report say?
Worked solution: Report the original failure and the revision, and describe the old test as now known development evidence. Success on it shows the fix handles those cases, but it is no longer a fresh final evaluation. Use a new held-out pack before making a new generalization claim, and keep both versions’ results.
Check your understanding
MCQ 1: Which set guides model-choice comparisons?
- Validation
- The final test set while choosing the model
- The training set alone after fitting the model
- Whichever set gives the highest score
Check the answer and explanation
Answer: A. Validation supports development choices while test data is held back for final evaluation.
MCQ 2: Which procedure keeps a separate test pack out of model choice?
- Rename the printed pack after using it to choose a threshold
- Have a partner hold back a separate pack, fix the model, then record predictions before revealing labels
- Read the test labels during design but promise not to copy them
- Reorder the known examples before scoring the revised model
Check the answer and explanation
Answer: B. The separate pack must not guide development; the fully printed pack remains a worked demonstration.
MCQ 3: Which input leaks the target for advance crowd prediction?
- Scheduled room size
- Day of week
- Final attendance count
- Planned session duration
Check the answer and explanation
Answer: C. Final attendance is unavailable before the session and effectively gives away the outcome.
MCQ 4: After tuning on a test error, the same test is what?
- A larger sample because the model has been revised
- Independent again if the labels are hidden during the second run
- A fresh final test because the revised model is new
- Known evidence, useful but no longer untouched
Check the answer and explanation
Answer: D. The model choice has been influenced by that test.
MCQ 5: Why group photos of one object in the same split?
- To prevent related-object leakage across splits
- To ensure every label is identical
- To avoid all variation
- To make test scores necessarily lower
Check the answer and explanation
Answer: A. The grouping preserves the intended challenge of evaluating on new objects.
Sources and further reading
- Google: Dividing the original dataset: Roles of training, validation and test data; duplicate leakage and repeated test use. Verified 11 October 2026.