AI Train, Validation and Test Sets
Reserve final evaluation data before choosing a model.
How it works
Training estimates parameters. Validation helps choose settings or model families. The final test set should remain untouched until those choices are fixed. A chronological split is appropriate when the task is to predict later sessions from earlier ones; a random split can answer a different question. Small examples illustrate the separation, not a sufficient sample size.
Run the code
Try in playground loads this complete standard-library Python example without executing it. Choose Run when ready. Local review uses Python 3.12.14; the existing browser editor uses Pyodide 0.27.7. These small fictional examples need no account, external data, model-provider key or database service.
Example
days = list(range(1, 11))
train, validation, test = days[:6], days[6:8], days[8:]
assert set(train).isdisjoint(validation)
assert set(train).isdisjoint(test)
assert set(validation).isdisjoint(test)
print("train:", train)
print("validation:", validation)
print("test:", test)
Expected result
train: [1, 2, 3, 4, 5, 6] validation: [7, 8] test: [9, 10]
The latest days are held back. If several rows describe the same independent entity, a grouped split may also be necessary. Decide whether the deployment asks about future records at a familiar site or entirely new sites before choosing a splitter.