Machine learning with football · Chapter 7

Datasets, generalization and overfitting

A model that only knows its training data is useless. This chapter is about data you can trust, splits that tell the truth, and models that generalize.

Estimated time: 5 minutes · page 1 of 12

Data first

Ask people who build models for a living where their time goes and most will say data: finding it, checking it, cleaning it. Around 80% of a project is typical. Better data improves a model far more than a cleverer loss function, and this chapter is about getting the data right and checking that a model works beyond the matches it learned from.

The running example is chapter 6's club model, which predicts a home win from nothing but the two clubs' names, one-hot encoded. It has 40 weights and only 111 finished matches in Premier League. That combination is asking for trouble, and the board shows the trouble arriving.

The board splits the season by date. The oldest 70% of matches train the model, the next 15% check it, and the latest 15% are kept for one final test. Chapters 3 to 6 already used this idea in their Python exercises. Here it gets the full explanation.

Check yourself

What usually improves a model most?
How much of a machine learning project goes into preparing data?

What's in this chapter

What makes a dataset trustworthy, direct and proxy labels, rare classes, the three-way split, the conditions for generalization, overfitting and its causes, model complexity, L2 regularization and early stopping, and how to read a loss curve. It ends with a Python exercise that overfits on purpose and then fixes it.

Leagues