BlazeOrange.ninja

NFL Predictor Algorithm (Part 1)

By now you've seen enough rants and raves about the NFL from me. I had a bit of time off and decided to have a go at writing code to predict the outcome of games. I'm already in a pool for no money so I might as well give myself a legitimate edge. The first thing I thought of was Heal Points. The next thing I thought of was the old BCS computer scores for NCAA football. Both were designed to deal with comparing teams that never played each other. Then I made an abomination of the two. Somehow it's working halfway decently. Follow along if you want to copy it in your language of choice.

The first thing you're going to need is a list of who beat who this season up until the end of last week. For every team, add 100 points for every win and 50 points for every tie, then divide by the number of games played. A 7-3 record = 70 points, 6-3 = 66.666666 points, etc. These are basically your seed values.

Now the fun part begins. We're going to iteratively try to solve a set of 32 equations with 32 variables! I found that 1000 iterations is enough to make the numbers not vary beyond a thousandth of a point. Make a copy of whatever you're using to hold your seed values. Use them as inputs for each team equation and write the result out to the copy.

You may notice that the results of each equation are almost always lower than the inputs going in. We need to scale it, otherwise after 1000 iterations, we'll only get 0's back. After each equation is complete, get the lowest and highest values and scale them such that the lowest value is 0 and the highest value is 100. After that's done, overwrite the seed values with the resulting values, and you've finished one iteration. Repeat that 1000 times and your resulting values will look very different from your seed values.

After 11 weeks, the results are somewhat realistic but there are some real questions with others:

  1. Dallas Cowboys: 100.000
  2. Tampa Bay Buccaneers: 65.047
  3. Buffalo Bills: 57.619
  4. Pittsburgh Steelers: 51.906
  5. Los Angeles Chargers: 44.442
  6. Philadelphia Eagles: 38.058
  7. Arizona Cardinals: 36.277
  8. Minnesota Vikings: 36.014
  9. Tennessee Titans: 33.039
    1. Carolina Panthers: 31.511
    2. Kansas City Chiefs: 30.620
    3. Atlanta Falcons: 28.588
    4. New York Jets: 27.061
    5. Cincinnati Bengals: 25.914
    6. Denver Broncos: 17.888
    7. Indianapolis Colts: 17.351
    8. Cleveland Browns: 16.583
    9. New England Patriots: 16.335
    10. San Francisco 49ers: 16.188
    11. Green Bay Packers: 16.122
    12. Miami Dolphins: 15.780
    13. Houston Texans: 15.366
    14. Washington Football Team: 14.814
    15. Baltimore Ravens: 14.482
    16. Las Vegas Raiders: 12.445
    17. Los Angeles Rams: 11.393
    18. Jacksonville Jaguars: 11.278
    19. New Orleans Saints: 10.799
    20. Seattle Seahawks: 9.330
    21. New York Giants: 8.335
    22. Chicago Bears: 6.695
    23. Detroit Lions: 0.000

I tested this against every game this season (excluding the tie game) and while I wouldn't put any money on it, it's better than 50/50:

  1. Correct 102 games, incorrect 62 games (62.195% correct) across the season
  2. Correct 9 games, incorrect 7 games (56.250% correct) in week 1
  3. Correct 10 games, incorrect 6 games (62.500% correct) in week 2
  4. Correct 10 games, incorrect 6 games (62.500% correct) in week 3
  5. Correct 8 games, incorrect 8 games (50.000% correct) in week 4
  6. Correct 12 games, incorrect 4 games (75.000% correct) in week 5
  7. Correct 10 games, incorrect 4 games (71.429% correct) in week 6
  8. Correct 9 games, incorrect 4 games (69.231% correct) in week 7
  9. Correct 10 games, incorrect 5 games (66.667% correct) in week 8
    1. Correct 7 games, incorrect 7 games (50.000% correct) in week 9
    2. Correct 9 games, incorrect 4 games (69.231% correct) in week 10
    3. Correct 8 games, incorrect 7 games (53.333% correct) in week 11

I'll continue to hack away at it and see if I can't get the success rate higher. I think adding a recency bias will help some.

Day 77 of #100DaysToOffload

Tags: Programming Football NFL AI Math