Pulse Data Hub

Data Science in Sports Analytics: A Premier League Model

Data Science in Sports Analytics: A Premier League Model

Data science in sports analytics is mostly about one discipline: turning noisy results into honest probabilities. This guide uses every match of the 2018-19 Premier League season (380 games) to measure home advantage, check how well goal difference explains the table, and test a simple Poisson goals model on matches it never saw. Everything was run with pandas 3.0.5, SciPy and statsmodels, and we say where the test is small.

Bar chart: home win 47.6%, away win 33.7%, draw 18.7%, always-home accuracy 49.0%, Poisson model accuracy 57.0%
Outcome shares over the season, and test accuracy of two ways to pick results.

The data

The results come from the open football-datasets repository (data originally published by football-data.co.uk): 380 matches from 10 August 2018 to 12 May 2019, 20 teams, with goals, shots, shots on target, corners, fouls and cards per match. Our table matches the real season: Manchester City 98 points, Liverpool 97, Chelsea 72, Tottenham 71.

import pandas as pd

d = pd.read_csv('season-1819.csv')
print(d.FTHG.mean(), d.FTAG.mean())        # 1.568 home goals, 1.253 away goals per match
print(d.FTR.value_counts(normalize=True)) # H 0.476, A 0.337, D 0.187

Home advantage is real

Home teams scored 1.57 goals a match against 1.25 for visitors, and won 47.6% of games to 33.7% for away teams (18.7% draws). A fitted model (below) puts the home effect at a factor of 1.23 on expected goals. It also varies between clubs: the gap between a team’s home and away goals per game ran from -0.68 to +1.11 across the 20 clubs, so for some teams the venue made little or negative difference in this one season of 19 home games each, which is too few to call a pattern.

Goal difference explains the table

The correlation between a team’s goal difference and its points was 0.991. Manchester City’s +72 and Liverpool’s +67 sit at the top of the table. That is a useful shortcut: points are a noisy measure, and goals scored and conceded describe team strength well. It is also partly built in, because goals decide the points.

Shots, goals and luck

Shots on target tracked home goals much better than total shots did (correlation 0.59 versus 0.33), and across the season about 0.32 goals were scored per shot on target. Goals are rare and random: the average match had 2.82 goals with a variance of 2.56, close to what a Poisson distribution (variance equal to the mean) would give. That is the idea behind the model below.

A Poisson model, tested on unseen matches

We modelled each side’s goals as Poisson with an expected value set by an attack strength for the team, a defence weakness for the opponent, and a home effect. We trained it on the first 280 matches by date and predicted outcome probabilities for the last 100.

import statsmodels.api as sm, statsmodels.formula.api as smf
from scipy.stats import poisson

# long format: one row per team per match
model = smf.glm('goals ~ home + C(team) + C(opp)', data=long_train,
                family=sm.families.Poisson()).fit()

# P(home win), P(draw), P(away win) from two Poisson distributions
M = np.outer(poisson.pmf(range(11), lam_home), poisson.pmf(range(11), lam_away))
p_home, p_draw, p_away = np.tril(M, -1).sum(), np.trace(M), np.triu(M, 1).sum()
On the last 100 matchesAccuracyLog-loss (lower is better)
Always predict a home win0.490–
Base-rate probabilities–1.015
Poisson goals model0.5700.872

The model picked the right result in 57 of 100 matches against 49 for always backing the home team, and its probabilities scored better than the season-average rates (0.872 versus 1.015 log-loss). With only 100 test matches that gap could partly be chance, so we would not claim more than “better than naive”. The model never predicted a draw, though 16 of the 100 matches were draws; draws are hard to call because they are what happens when two probabilities are close. Betting markets use far richer information, and nothing here is a betting recommendation.

Where sports data science goes next

Real teams add tracking data, player ratings and injury information, and test models on many seasons rather than one. For the technique, see logistic regression in Python, linear regression and our scikit-learn walkthrough; the wider picture is in data science by industry. The statsmodels GLM documentation covers the Poisson family used above.

Limits of this analysis

One season, one league, a 280/100 split and no tuning. A team’s strength can change during a season (injuries, transfers, managers), which this static model ignores. Results will differ in other seasons.

FAQ

How is data science used in sports analytics?

To estimate team and player strength, predict results, and decide tactics and recruitment. Here we measured home advantage and tested a goals model.

Why use a Poisson distribution for goals?

Goals are rare, independent-looking events. In our season the mean was 2.82 goals per match with variance 2.56, which is close to Poisson behaviour.

How accurate was the model?

57% on 100 unseen matches versus 49% for always picking the home side. It never predicted a draw.

Can I use this for betting?

We do not recommend it. Our model is simple, tested on a small sample, and betting markets include much more information.

Newsletter Signup Form

Latest tutorials

Latest articles

On this page
Verified by MonsterInsights