Machine learning with football · Chapter 6

Working with categorical data

Clubs, leagues, days of the week. Values from a fixed list need turning into numbers before any model can use them.

Estimated time: 5 minutes · page 1 of 5

Values from a fixed list

Categorical data takes its values from a fixed set: the twenty clubs in a league, the seven days of the week, home win, draw or away win. Chapter 5's binned minutes count too, since a bin is just a category made out of a number.

Some categories look like numbers. A club's ID, a shirt number or a postcode is written in digits, but nobody would say league 2 is twice league 1. The test from chapter 5 still works: if doubling the value doesn't mean twice as much of something, treat it as a category.

A model only works with floating point numbers, so a value like "Arsenal FC" can't go in as it is. Turning categories into number vectors is called encoding, and most of this chapter is about doing it well. The board shows one finished match from Premier League, with each of its features marked as one kind or the other.

Check yourself

Which of these should a model treat as categorical?
Matchday 10 and matchday 5: numerical or categorical?

Leagues