Skip to content
Query Feedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  • News
  • Business
    • Digital Marketing
      • Marketing & Sales
      • SEO
      • Content Marketing
      • AEO and GEO
    • Startups
      • Founder Stories
      • Funding & VC
      • Product & Growth
    • Money
      • Investing
      • Markets & Economy
      • Saving & Budgeting
  • AI & Technology
    • Technology
      • Consumer Tech
      • CRM
      • Cyber Security
      • Software Engineering
      • WordPress
      • Hardware
    • Artificial IntelligenceAI Glossary
      • LLMs
      • Machine Learning
      • AI Fundamentals
      • Generative AI
      • Deep Learning
    • AI Use Cases
      • Automation
      • Content
      • Customer Support
      • Finance
      • Marketing
      • View All
  • Tools & Software
  • Account
    • Submit Guest Post
    • Submit a tool
    • My listing
  • Contact
QueryFeedz
  1. Home /
  2. AI Glossaries /
  3. Machine Learning /
  4. What is Cross-Validation in Machine Learning?
Machine Learning

What is Cross-Validation in Machine Learning?

Updated October 2, 2026 Read 3 min

Cross-validation is a technique that repeatedly splits data into training and validation parts, rotating which part is held out, so model performance is estimated more reliably than from a single split.

Contents 12
  1. 01Key takeaways
  2. 02Cross-validation explained in simple terms
  3. 03How k-fold cross-validation works
  4. 04Variants and when to use them
  5. 05The two most common mistakes
  6. 06Preprocessing inside the loop
  7. 07How many folds?
  8. 08When not to use cross-validation
  9. 09Limitations
  10. 10Common Use Cases
  11. 11Frequently Asked Questions
  12. 12Related Terms

Cross-validation is a technique that repeatedly splits data into training and validation parts, rotating which part is held out, then averages the results. A single split can be lucky or unlucky, especially with limited data. Cross-validation uses every example for validation exactly once, giving a more stable estimate of how a model will perform on new data.

Key takeaways

  • K-fold is the standard: split into k parts, train k times, average the scores.
  • 5 or 10 folds are the usual choices.
  • Stratified folds preserve class proportions and are the default for classification.
  • Time series and grouped data need specialised splitting, or results are invalid.
  • Cross-validation is for model selection and estimation, not a replacement for a final test set.

Cross-validation explained in simple terms

Testing a recipe on one friend tells you little: they may simply dislike coriander. Testing it on five friends in turn, each tasting a different batch, gives a far better picture. Cross-validation does this with data: every example gets a turn as the judge.

How k-fold cross-validation works

  1. Shuffle the data (unless it is time-ordered).
  2. Split it into k equal folds.
  3. For i = 1 to k: train on all folds except i, validate on fold i.
  4. Record the score each time.
  5. Report the mean and the standard deviation.

Worked example with 5-fold on 1,000 examples:

FoldTraining examplesValidation examplesAccuracy
18002000.86
28002000.83
38002000.88
48002000.81
58002000.85

Mean accuracy 0.846, standard deviation 0.027. The spread matters as much as the mean: a model scoring 0.85 ± 0.03 is more trustworthy than one scoring 0.86 ± 0.12.

Variants and when to use them

VariantHow it splitsUse when
K-foldRandom equal foldsGeneral-purpose default
Stratified k-foldPreserves class proportions in each foldClassification, especially imbalanced
Leave-one-out (LOOCV)k equals the number of examplesVery small datasets; expensive, high variance
Group k-foldKeeps all rows of a group togetherMultiple rows per customer, patient or device
Time-series splitTrains on the past, validates on the futureAny time-ordered data
Repeated k-foldRuns k-fold several times with different seedsMore stable estimates on small data
Nested CVInner loop tunes, outer loop evaluatesTuning plus unbiased estimation

The two most common mistakes

Random splits on time-series data. Training on data from after the validation period leaks the future into the past. Forecasting results look excellent and fail completely in production. Always split by time for time-dependent problems.

Ignoring groups. If one customer appears in 50 rows, random splitting puts some of their rows in training and others in validation. The model memorises that customer and scores well for the wrong reason. This is a form of data leakage. Use group-aware folds.

Preprocessing inside the loop

Scaling, imputation, encoding and feature selection must be fitted inside each fold, on the training part only. Fitting a scaler on the whole dataset before cross-validation leaks information from validation data into training and inflates the score. Pipelines in libraries such as scikit-learn exist to make this correct by default.

How many folds?

kTraining data per foldCostVariance of estimate
367%LowHigher
580%ModerateGood balance
1090%HigherLower
n (LOOCV)Almost allVery highCan be high

Five or ten folds suit most problems. More folds mean more training data per fold, a slightly less pessimistic estimate, and proportionally more compute.

When not to use cross-validation

  • Very large datasets: a single large validation split is already stable and far cheaper.
  • Very expensive training: retraining an LLM k times is rarely justified.
  • Strict temporal deployment: a rolling time-based evaluation often reflects reality better.

Limitations

  • Multiplies training cost by k.
  • Still optimistic if tuning is heavy and repeated on the same folds.
  • Does not protect against a dataset that is unrepresentative of production.
  • Requires careful splitting for grouped, nested or time-structured data.

Common Use Cases

01

Model selection

Compare algorithms fairly on limited data.

02

Hyperparameter tuning

Score candidate settings reliably.

03

Small datasets

Use every example for both training and validation.

04

Medical and scientific data

Keep patient or subject groups intact across folds.

05

Forecasting

Validate with time-ordered splits that mimic deployment.

06

Stability checks

Use fold variance to judge model reliability.

Frequently Asked Questions

A technique that rotates which part of the data is held out for validation, averaging results for a more reliable estimate.

Five or ten are standard. More folds give more training data per fold but cost more compute.

K-fold that preserves class proportions in every fold, the default for classification.

Not with random folds. Use time-series splits that always train on earlier data and validate on later data.

Yes. Fit scalers, imputers and encoders inside each fold to avoid leaking information.

Related Terms

  • Validation Dataset
  • Test Dataset
  • Hyperparameter Tuning
  • Data Leakage
  • Overfitting
  • Training Dataset

Related AI Terms

What is Hyperparameter Tuning?Hyperparameter tuning is the process of systematically searching for the configuration values that make a model perform best…What is Early Stopping in Machine Learning?Early stopping is a regularisation technique that halts training when validation performance stops improving, preventing the model from…What is L2 Regularization?L2 regularization adds a penalty equal to the sum of the squared weights, shrinking all weights smoothly towards…What is L1 Regularization?L1 regularization, known as lasso in linear models, adds a penalty equal to the sum of the absolute…What is Stochastic Gradient Descent (SGD)?Stochastic gradient descent (SGD) updates a model's weights using one example or a small batch at a time…What is the Bias-Variance Tradeoff?The bias-variance tradeoff describes how a model's error splits into bias from overly simple assumptions and variance from…

Contents

  1. 01Key takeaways
  2. 02Cross-validation explained in simple terms
  3. 03How k-fold cross-validation works
  4. 04Variants and when to use them
  5. 05The two most common mistakes
  6. 06Preprocessing inside the loop
  7. 07How many folds?
  8. 08When not to use cross-validation
  9. 09Limitations
  10. 10Common Use Cases
  11. 11Frequently Asked Questions
  12. 12Related Terms

AI Topic

  • Machine Learning

Related Terms

  • What is Hyperparameter Tuning?
  • What is Early Stopping in Machine Learning?
  • What is L2 Regularization?
  • What is L1 Regularization?
  • What is Stochastic Gradient Descent (SGD)?
  • What is the Bias-Variance Tradeoff?

Quick Navigation

  • Common Use Cases
  • Frequently Asked Questions
  • Related Terms
  • Back to top

Details

Updated
October 2, 2026
Read
3 min
  • Forum
  • Submit a tool
  • Submit Guest Post
  • List Your Startup
  • Privacy Policy
  • Editorial Policy
  • Account
  • Contact
  • AI Productivity
  • AI Video
  • AI Coding
  • AI Chatbots
  • Sales
  • AI Business
  • View All Tools

Subscribe our Newsletter

Get weekly exclusive content - No spam.

Copyright © 2026 -  Query Feedz

Manage Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
View preferences
  • {title}
  • {title}
  • {title}