fivethirtyeight/nfl-elo-game

Name: nfl-elo-game

Owner: FiveThirtyEight

Description: Data and code for FiveThirtyEight's NFL game

Created: 2017-08-31 14:41:01.0

Updated: 2018-01-18 06:16:59.0

Pushed: 2017-09-18 00:14:47.0

Homepage: null

Size: 685

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Can You Beat FiveThirtyEight's NFL Predictions?

This repository contains code and data to accompany FiveThirtyEight's NFL Predictions game. Specifically, it has:

Our goal in providing this repository is for people to be able to figure out how FiveThirtyEight's NFL Elo model and NFL predictions game work and to provide a loose framework for evaluating forecasts against historical data. This repository does not include assistance in building a predictive model.

Evaluating historical forecasts

eval.py is the only runnable script, and does the following:

  1. Reads in the CSV of historical games. Each row includes a elo_prob1 field, which is the probability that team1 will win the game according to the Elo model.
  2. Fills in a my_prob1 field for every game using code in forecast.py. By default, these are filled in using the exact same Elo model.
  3. Evaluates the probabilities stored in my_prob1 against the ones in elo_prob1, and shows how those forecasts would have done in our game for every season since 1920.

Jump in by running python eval.py. You should see the following output:

verage, your forecasts would have gotten 642.61 points per season. Elo got 642.61 points per season.

This makes sense ? right now it's just running FiveThirtyEight's Elo model against itself, so it gets the same number of points for every game.

Open up forecast.py, change the HFA (home-field advantage) parameter to 100, and rerun python eval.py. You should see:

verage, your forecasts would have gotten 602.78 points per season. Elo got 642.61 points per season.

OK, looks like changing home-field advantage from 65 to 100 points isn't a good idea. With that tweak, our generated probabilities perform worse historically than the official FiveThirtyEight Elo probabilities.

Making 2017 forecasts

Inside the Util.read_games function, there are three lines you can uncomment to download the 2017 schedule and results to data/nfl_games_2017.csv. If you run python eval.py after uncommenting them, you'll see something like the following in the output:

casts for upcoming games:
-09-07  NE vs. KC       69% (Elo)       73% (You)
-09-10  CHI vs. ATL     28% (Elo)       31% (You)
-09-10  CIN vs. BAL     63% (Elo)       67% (You)

The scripts are now maintaining Elo ratings through the 2017 season, and printing forecasts (both from elo_prob1 and from my_prob1) for upcoming games. Note that our model is more confident in the home team in every game because we've adjusted the HFA parameter to 100.

More

Have at it! Some ideas for further exploration:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.