Sitemap

What is a training set, validation set, and test set?

1 min readMar 27, 2026

--

These three datasets are used to build, tune, and evaluate a machine learning model properly.

📚 Training Set

Purpose: To train the model

  • This is the data the model actually learns from.
  • The algorithm adjusts its parameters based on this data.

👉 Example:
If you’re building a spam classifier, the training set contains emails labeled as spam or not spam, and the model learns patterns from them.

Press enter or click to view image in full size

⚙️ Validation Set

Purpose: To tune the model

  • Used during training to:
  • Adjust hyperparameters (e.g., learning rate, depth of tree)
  • Compare different models
  • Helps detect overfitting

Get Nivethabaskar’s stories in your inbox

Join Medium for free to get updates from this writer.

👉 Example:
You try different models/settings and check which performs best on the validation set.

🧪 Test Set

Purpose: To evaluate the final model

  • Used only after training is complete.
  • Gives an unbiased estimate of real-world performance.
  • Should never be used during training or tuning.

👉 Example:
After choosing your best model, you test it once on this dataset to see how well it generalizes.

🔁 Simple Analogy

Think of preparing for an exam:

  • Training set → Studying from textbooks 📖
  • Validation set → Taking practice tests 📝
  • Test set → Final exam 🎓

--

--