cd /news/machine-learning/cross-validation-why-one-train-test-… · home topics machine-learning article
[ARTICLE · art-41806] src=dev.to ↗ pub= topic=machine-learning verified=true sentiment=· neutral

Cross-Validation: Why One Train/Test Split Lies

A developer demonstrates why a single train/test split can be misleading in machine learning, advocating for k-fold cross-validation to obtain a more reliable performance estimate. The interactive visualization shows how k-fold cross-validation rotates through folds, providing a mean accuracy with standard deviation, compared to the variance of a single split. The project is part of the MachineLearningFromZero series.

read1 min views1 publishedJun 27, 2026

You split your data 80/20, get 91% accuracy, and ship it. But was that 91% luck or skill? A single split can fool you. Cross-validation gives you a trustworthy number. Here's k-fold, visualized.

🔁 Watch the folds rotate: https://dev48v.infy.uk/ml/day18-cross-validation.html One train/test split is high-variance: a lucky test set flatters your model, an unlucky one trashes it. You're judging on a single roll of the dice.

Split the data into k equal folds. Then, k times: train on k−1 folds, validate on the held-out one. You get k scores — report the mean ± std. Every data point gets used for both training and validation (in different rounds), so the estimate is stable.

The demo rotates each fold through validation, fits a real model per fold, fills in the per-fold scores, and shows the average — next to a single split you can reshuffle to watch it swing.

Cost: k× the training. Worth it for an honest score.

🔨 Built from scratch (split into folds → train/score each → mean±std → grid-search) on the page: https://dev48v.infy.uk/ml/day18-cross-validation.html

Part of MachineLearningFromZero. 🌐 https://dev48v.infy.uk

── more in #machine-learning 4 stories · sorted by recency
── more on @machinelearningfromzero 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/cross-validation-why…] indexed:0 read:1min 2026-06-27 ·