ML
    beginner

    Cross-Validation

    algorithms.live

    Cross-Validation Visualizer
    K-Fold CV

    CV Parameters

    Splits data into K equal folds, each used once as test

    5
    FastReliable
    1/5

    Controls

    CV Results

    Mean Score:78.6%
    Std Dev:±6.9%
    Folds:5
    Train Size:40
    Test Size:10

    Fold 1 / 5

    Training Set (40 samples)
    Test Set (10 samples)

    Why Not Just a Single Train/Test Split?

    The same model evaluated on 8 different random 80/20 splits gives wildly different accuracy estimates. Which one would you trust?

    60%70%80%90%100%S194%S276%S380%S495%S579%S677%S795%S882%Range: 19ppStd: ±7.8%

    The problem: a lucky split gives 95% — making you think the model is great. An unlucky split gives 76% — making you think it is terrible. CV gives 78.6% ± 6.9% — a reliable estimate from all the data.

    Scores Across Folds

    0%25%50%75%100%Fold NumberAccuracy (%)
    Red dashed line = mean score (78.6%)

    K-Fold CV

    • Most common method
    • Equal-sized folds
    • Use for balanced data

    Stratified K-Fold

    • Maintains class balance
    • Critical for imbalanced data
    • Use for classification

    Time Series Split

    • Respects temporal order
    • No future data leakage
    • Use for time series only

    Model Evaluation
    Hyperparameter Tuning
    Critical Concept
    sklearn

    Run k-fold correctly

    Sequence

    Order one fold of a k-fold evaluation.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    6. 6Drop a step here
    6 pieces left to place

    Test your knowledge

    20 questions
    Question 1 of 20
    Score: 0

    K-fold cross-validation works by…

    Interview Questions

    Stripe
    Airbnb
    DoorDash
    Two Sigma
    Citadel
    Google
    Microsoft Research
    DeepMind
    IBM
    Google
    Amazon
    Netflix

    Love this visualization?

    Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.

    100% free • No credit card required