Skip to content

    Train/Validation/Test Split

    Machine Learning · Beginner

    Definition

    Data is split into training (learn), validation (tune) and test (final evaluation) sets.

    Prevents fooling yourself with scores on data the model has seen.

    Diagram

    Train 70%Val 15%Test 15%

    Flowchart

    Shuffle dataSplit 70/15/15Train on trainTune on validationReport on test once

    Example: Simple split

    data = list(range(10))
    n = int(len(data) * 0.8)
    print(len(data[:n]), len(data[n:]))

    Output: 8 2

    Key points

    • Never tune on the test set
    • Stratify for imbalanced classes

    Interview questions

    What is data leakage?

    When information from the test set leaks into training, inflating scores.

    More Machine Learning topics