Machine learning with football · Chapter 5 · Numerical data

Binning

Cut a number into ranges and let the model learn a weight for each one.

Estimated time: 15 minutes · page 5 of 9

Cut the number into ranges

Binning, also called bucketing, replaces a number with the range it falls in. With five bins, minutes become five features, one per bin, and each player has a 1 in exactly one of them. That's a one-hot vector, and the board shows it for one player. The model then learns a separate weight for each bin.

Use it when the feature's link to the label isn't a straight line, or when the values sit in clusters. Minutes are a fair example. There's a big group of players with few minutes and another of regulars who play nearly every minute. "Squad player" and "regular" may matter more than the exact count.

It has a cost. Players with 17 and 29 minutes become identical. Every bin is also a feature that needs enough examples to learn from, so ten bins with three players in some of them helps nobody.

Equal width or quantiles

Equal-width bins cut the range into even slices. Quantile bins move the edges so each holds about the same number of players. Switch between them on the board. For skewed data, quantile bins give the crowded part more detail and stop the empty tail from getting bins of its own.

Check yourself

Why bin a feature at all instead of scaling it?
A player with 17 minutes and one with 29 land in the same bin. What does the model see?
What is wrong with 100 bins for 467 players?

Leagues