Think of the three sets as three jobs

A training set fits the model. A validation set helps compare choices, such as which settings to use. A test set provides a final check after the choices are settled. Set aside the groups before developing the model and keep a record so you can explain how each example was used.

Work through 100 fictional messages

Imagine 100 labeled messages, 30 of which need follow-up. Start with 70 for training, 15 for validation and 15 for testing. For independent messages, a stratified split can distribute positive cases more evenly. One possible outcome is 21 positive training cases, four positive validation cases and five positive test cases. The 70/15/15 division is an illustration, and a small test set makes metric estimates uncertain.

Keep related examples together

Two messages from the same thread can contain nearly identical wording. Splitting those into separate groups can make a model look better than it will on a new thread. Keep an entire thread in one group if thread independence matters. To estimate performance on future messages, consider training on older data and testing on newer data in chronological order.

Fit preparation steps with the right data

If you learn a text vocabulary, choose features or calculate a value used to fill missing data, learn that step on the training set. Apply the fitted step to validation and test examples. In a cross-validation workflow, fit preprocessing within each training fold. Keep the final test set out of the tuning loop.

Report what the split tells you

Write down the example counts, how the groups were assigned, what metric you chose and why, and whether related records were grouped. If a test result leads you to change the model, set aside a fresh final evaluation set when possible. After the final check, use a confusion matrix to show which types of mistakes the model made.

Related guides

Further reading. scikit-learn guidance on data leakage.