Model Evaluation

Train/Test Split & Cross-validation

In shortHolding back data the model never trains on to test how well it generalises; cross-validation repeats this across several splits.

Updated 24 Oct 2026· 2 min read

A train/test split divides your labelled data into a part the model learns from (training data) and a part it never sees during training (test data). Scoring the model on the test data tells you how well it is likely to perform on new, real-world examples. Cross-validation repeats the split several times so the estimate does not depend on one lucky or unlucky division.

How it works

A common pattern is to split data roughly 70 to 80% for training and the rest for testing, often with a third, validation set held back to tune settings such as learning rate or tree depth without touching the test set. MLforSEO describes the three buckets this way: training data teaches the task, test data checks generalisation (you hold the labels; the model only sees the text), and validation data helps avoid overfitting.

In k-fold cross-validation, the data is cut into k equal parts (often 5). The model is trained k times, each time testing on a different part, and the scores are averaged. scikit-learn provides train_test_split and cross_val_score for this.

How it’s used in SEO and marketing

  • Checking an intent or page-type classifier before running it on your full keyword set.
  • Comparing models fairly, such as a lexicon tool against a transformer, on the same held-out data.
  • Choosing hyperparameters with cross-validation rather than by eye.
  • Forecasting traffic, where the split must respect time: train on earlier months, test on later ones.

Example

In MLforSEO’s sentiment analysis deep dive, four methods were scored on the same 2,000 tweets from the TweetEval sentiment test set. A TF-IDF plus logistic regression model trained on about 45,000 TweetEval training tweets reached 0.60 accuracy; a RoBERTa model fine-tuned on TweetEval reached 0.71. The post notes the transformer had a home advantage: it was fine-tuned on data from the same source as the test set, so results on your own reviews may differ.

Limitations and things to watch

  • Leakage ruins evaluation. Near-duplicate pages, or the same keyword in both sets, inflate scores.
  • Use stratified splits on imbalanced data, so rare classes appear in both sets.
  • Never shuffle time-series data randomly.
  • In MLforSEO’s AI search lessons, “cross-validation” also describes AI systems checking a claim against other sources. That is a different idea from model cross-validation.

Learn it on MLforSEO

Where Train/Test Split & Cross-validation shows up on MLforSEO

Sources and further reading

Other terms from Model Evaluation

See all 16 Model Evaluation terms →