AI GLOSSARY · AI CONCEPTS
Cross-validation
Definition
Cross-validation is a way to estimate how well a model will do on unseen data. The data is split into parts, the model is trained on some and scored on the held-out part, and the process repeats.
Also called: cross validation, CV, rotation estimation.
In plain language
Cross-validation repeatedly fits and evaluates a learning procedure on selected data splits. In common k-fold cross-validation, each fold is held out while the model is fitted on the others, then scores are summarized. Time ordering, groups and preprocessing must match the intended prediction setting. Model selection needs a separate evaluation layer, such as a final untouched test set or outer folds in nested cross-validation.
Technical definition
In k-fold cross-validation, as the scikit-learn user guide describes it, the training set is split into k smaller sets. For each fold a model is trained on k-1 folds and validated on the remaining part, and the reported performance is the average of the values computed in the loop. A separate untouched test set or a suitable outer evaluation procedure is needed to assess the model-selection process. The guide notes that the approach can be computationally expensive, that leave-one-out often gives high variance as an estimator of test error, and that data ordered in time needs a time-series aware scheme because ordinary shuffling can inflate the validation score.
Worked examples in this catalogue
Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.
Skill by Skill Almanac · Illustrative, not executed
split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- The skill checks train, validation and test files for duplicates, shared groups, time and label leakage and prints JSON.
- Why it exercises the concept
- The scikit-learn guide warns that ordered or related data can inflate validation scores. This skill checks the kind of leakage that breaks a split, though it does not run cross-validation. This is illustrative, not executed.
Skill by Skill Almanac · Illustrative, not executed
data-analysis-eda 56/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- The skill is a fixed exploratory-analysis procedure and CSV profiler that keeps findings descriptive, evidenced and caveated.
- Why it exercises the concept
- Inspect the data for time order and repeated groups before choosing a splitting strategy. This skill helps examine the data; it does not perform cross-validation.
Skill by Skill Almanac · Illustrative, not executed
llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score
- What you see
- The skill builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
- Why it exercises the concept
- A contrast case from language-model work: a held-out eval set, not folds of training data. Both ask how a system behaves on cases it was not built on. This is illustrative, not executed.
How it shows up when you use agents
Cross-validation shows up when you ask Claude Code, Codex or Cursor to build or tune a model on a table of data. A typical script imports scikit-learn and calls a helper that scores the model across several splits. The scikit-learn documentation describes cross_val_score as evaluating a score by cross-validation, with 5-fold as the default for its cv argument. The helper returns fold scores; you can summarize their mean and variability.
What breaks when it is misunderstood: leakage. The scikit-learn guide says shuffling data that is ordered by time can give a model that is overfit and an inflated validation score. Interpret scores for the sampling scheme and intended deployment population. The scikit-learn leakage guidance also warns against fitting preprocessing on the full dataset before splitting. An agent that scales or selects features on the full dataset first can report a score that is too good.
A practical next step: ask the agent which split scheme it used, whether any step was fitted before splitting, and whether a final test set was held out. The entries on overfitting and hyperparameter tuning explain why that last set matters. The catalog cards illustrate adjacent checks rather than a cross-validation runner. The following small calculation demonstrates the fold procedure itself.
Worked example (illustrative)
Consider six hypothetical observations, three labeled A and three B. Make three test folds, each containing one A and one B. For each fold, train a majority-label baseline on the other four observations; break the two-versus-two tie by choosing A. The baseline gets one of the two test labels right, so all three fold accuracies and their mean are 0.5. This exact toy calculation illustrates the procedure, not a production model result or a population-performance claim. The split and tie rule are part of the example, not universal cross-validation requirements.
Common confusions
- Cross-validation versus a train/test split. A single split gives one score that can depend on the random choice. Cross-validation repeats the process over folds and averages. A test set should still be held out for final evaluation.
- Cross-validation versus training. Models are fitted within folds. Inner validation folds can guide choices; an outer evaluation or untouched test set assesses the resulting selection process.
- k-fold versus leave-one-out. Leave-one-out builds n models from n samples. The guide notes it often has high variance as an estimator of test error and that 5 or 10 folds is generally preferred.
- Myth: shuffling is harmless. For data ordered in time, the guide says shuffling can inflate the score.
Related terms
Terms that mention Cross-validation
More in AI concepts
Sources
- Cross-validation: evaluating estimator performance, scikit-learn (accessed 2026-11-24)
- cross_val_score, scikit-learn (accessed 2026-11-24)
- Cross-validation (statistics), Wikipedia (accessed 2026-11-24)
- Common pitfalls: data leakage and preprocessing, scikit-learn (accessed 2026-11-24)
- Nested versus non-nested cross-validation, scikit-learn (accessed 2026-11-24)
Definitions are written by Skill Almanac from these sources and were checked against them on 2026-11-24. Wikipedia is never the only source.
Review record
Last verified
Drafted by Claude (original draft) and Codex (automated revisions); sources and example targets checked by Independent automated source review (OpenAI Codex); not human peer review on 2026-11-24. Last verified .
Change log (5)
- : Independent automated factual/example review completed. Cached US query estimate aligned to receipt; no traffic promise. Final technical gate recorded separately; publication disabled.
- : First version.
- : Scoped explanations and example revision; exact-version review pending, no publication approval.
- : Metric and evaluation conventions corrected; independent exact-version review pending.
- : Automated review completed; approved for the staged public release. Search indexing is controlled by the release configuration.