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.
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
- The Characteristics of a Machine Learning Problem
- Sentiment Analysis: A Deep Dive Into the Theory, Methods, and Applications
- Introduction to Machine Learning for SEO course, lesson on ML solution characteristics.
Where Train/Test Split & Cross-validation shows up on MLforSEO
Try it yourself
Sources and further reading
Other terms from Model Evaluation
- Accuracy (ML metric)Accuracy is the share of all predictions a model gets right. It is the simplest evaluation metric, but it misl…
- Coherence ScoreA metric for how interpretable a topic model's topics are, based on how often each topic's top words appear to…
- Cosine SimilarityA measure of how closely two vectors point in the same direction, used to score how similar two texts, keyword…
- Emotion ScoresPer-emotion scores (joy, sadness, fear, disgust, anger) an emotion analysis API assigns to a text, each from 0…
- Entity Salience ScoreA 0 to 1 score from Google's Natural Language API showing how central each extracted entity is to the analysed…
- F1 ScoreA single evaluation metric that balances precision and recall (their harmonic mean); useful when classes are i…
- LLM-as-a-JudgeUsing a large language model to score or compare outputs against a rubric, as a scalable stand-in for human re…
- OverfittingOverfitting is when a model learns its training data too closely, including noise, so it scores well in traini…
- Precision and RecallPrecision is the share of a model's positive results that are correct; recall is the share of all true positiv…
