Skip to content

Machine Learning Through Football

How models learn from past matches to predict the next one: features and targets, training and testing, and the traps in between.

20 parts Beginner to Advanced

New to this? These parts are Beginner level: 1, 2, 3, 4, 5, 6, 7 and 16.

Start at part 1

Foundations

What a model is, how to test one honestly, and how to score a forecast. Parts 1 to 7.

What are we trying to predict? Features and targets

Every machine learning model starts with two decisions, what to predict and what to tell the model. The first is the target, the second the features, and real SPFL results show why the features matter as much as the model.

Beginner Part 1

Brilliant in training, gone on matchday. Overfitting

A model can learn its training matches too well, rules and all, and then fall apart on matches it hasn't seen. Real SPFL seasons show how it happens, how to spot it, and what to do about it.

Beginner Part 3

Stubborn or jumpy? Bias and variance

A model can be too rigid to learn, or so sensitive that one result rewrites everything it believes. Those are bias and variance, and twenty-five years of SPFL results show what each costs.

Beginner Part 5

One good season or a good model? Cross-validation

A single test season can flatter a model or bury it. Cross-validation tests it again and again on different slices of the data; for football, that means walking forward through the seasons. 23 SPFL seasons show why it matters.

Beginner Part 6

Is accuracy the right score? Evaluating a model

Accuracy counts how many results a model called right, and hides almost everything else. A confusion matrix shows where the mistakes are, probability scores show how confident it was, and five SPFL seasons show why draws break accuracy.

Beginner Part 7

Predicting a match

Home, draw or away: six ways to forecast a result, all tested on the same five seasons, then how to tell a sure model from a well-informed one. Parts 8 to 14.

Three questions and a prediction. Decision trees

A decision tree predicts a match the way a pundit reasons, with a string of yes-or-no questions, and it learns which questions to ask from the data. On five SPFL test seasons two questions nearly match logistic regression; twelve fall apart.

Intermediate Part 9

Ask a hundred pundits. Random forests

One decision tree is jumpy, so grow a hundred, each on a slightly different set of matches, and average what they say. On five SPFL test seasons the forest fixes most of a single tree's wild guesses, and still finishes just behind logistic regression.

Intermediate Part 10

Learning from its mistakes. Gradient boosting

Start with a rough guess, look at what it got wrong, and fix a little of it with a small tree. Repeat a few hundred times. On five SPFL test seasons gradient boosting draws level with logistic regression, and shows where three numbers run out.

Intermediate Part 11

Every team its own attack and defence. Dixon-Coles from scratch

Four machine learning models stalled at the same score on three numbers per match. Rate every team's attack and defence from the goals they score and let in, refit before every matchday, and a classic football model finally gets past them.

Advanced Part 12

Tuning Elo honestly. Five dials and a moving target

Elo has dials to set, from how far one result moves a rating to how much home advantage is worth. Tuned on held-back seasons it draws level with Dixon-Coles on the test seasons. The dial that mattered most changed between eras, and no honest tuning could have seen it coming.

Advanced Part 13

Sure of itself, or just better informed? Calibration in depth

A forecast can lose by being wrong about its own confidence, or by knowing less. Splitting the Brier score into calibration and resolution shows which. On five SPFL test seasons Elo is as well calibrated as the bookmakers, and loses only because they know more.

Advanced Part 14

More models

Other ways to learn from past matches: the closest past games, a straight line through the numbers, and adding up clues. Parts 15 to 17.

Matches like this one. K-nearest neighbours

To forecast a match, find the past matches most like it and see what happened. No training, no weights, just the right number of lookalikes. On five SPFL test seasons, the 300 nearest draw level with logistic regression.

Intermediate Part 15

How many shots is a goal worth? Linear regression

Draw the best straight line through 310 Scottish team-seasons and it says a goal comes every 3.1 shots on target. Then test it on seasons it never saw, and watch one version break when the way shots are counted changes.

Beginner Part 16

Clue by clue. Naive Bayes, and the danger of counting twice

Start with how often each result happens, then let every clue shift the odds. It's how spam filters work, and on three overlapping football clues it gets worse the more it's told. Merge the clues into one and it draws level with logistic regression.

Intermediate Part 17

Beyond the result

Questions with no single score to predict: how teams play, how seasons follow each other, and where everyone stood when the shot went in. Parts 18 to 20.

Four ways to play. K-means and team styles

Give a computer eight stats for 310 Scottish team-seasons and no labels, and K-means sorts them into four styles, from dominant to outshot. The outshot sides who foul a lot take no more points than the ones who don't.

Intermediate Part 18

What happens next season? Time series and ARIMA

A club's points a game, season after season, is a time series. For most clubs a season remembers the last two or three; a match remembers nothing. Smoothing over every past season forecasts next season better than last season alone, about nine points either way.

Intermediate Part 19

Expected goals from scratch. Where everyone stood

Most expected-goals models only know where a shot was taken. Train one on 95,162 real shots that also record where the keeper and defenders stood, and it gets within touching distance of a professional model. Then drag the players yourself.

Intermediate Part 20