Thursday, November 19, 2015

A Football Chart

 

Wednesday, November 18, 2015

2015 NFL Game Predictions: Week 11

Welcome!  I intend this to be an ongoing project of predicting NFL game outcomes, point spreads, and final scores.  My hope is that my models will improve over time as they become more sophisticated and use better data.  I will try to regularly publish predictions to keep myself accountable, and will make observations along the way about what is working and what isn't.  See below for latest updates.  Enjoy!
Previous predictions:
________________________________________________________________________________
Week 11: Recap
My predictions were 9-5 (actual results in below table).  That is 64% accurate.  Not great, but consistent with my model accuracy of 68% (if I had gone 10-4, then it would have been 71% accurate).  Any insights from what happened?
  • Titans/Jaguars
    • The game went back and forth, and the Titans were winning most of the time.  However, they gave up 10 points in the 4th quarter and didn't score at all. They couldn't finish.  A familiar theme for those of us in Seattle.
  • Bengals/Cardinals
    • It was going to be a close game anyway, and it was.  The lead went back and forth between the teams.  So it could have gone my way.  Unlucky.
  • Eagles/Buccaneers
    • Eagles got crushed by Buccaneers.  This was surprising.  The Eagles played badly - lots of punting, interceptions, and fumbling.  Not a good game for them, nor typical of their play.
  • Falcons/Colts
    • Another example of not being able to finish.  The Falcons didn't score in the 4th quarter and gave up 10 points instead.  Lots of punting and interceptions and a missed field goal.
  • Raiders/Lions
    • Once again.  The Raiders had the victory but lost it in the 4th quarter.  They gave up 9 points without scoring any in the 4th.  To be fair, they weren't winning most of the game anyway.  And it was predicted to be close.

The lesson seems to be that I need to get more information about how teams do in each quarter, and particularly, how they close out the game. Once again, I need better data, and better models, to improve the overall predictions.

Good luck in week 12!

_________________________________________________________________________________
Week 11: Third Published Predictions (Win/Lose)
Below is the next round of predictions I was able to make.  I've been continuing to work on cleaning up the code, automating data pulls, and creating new features to use in the prediction.  So far, my model has topped out at 68% accurate (i.e., (TP + TN)/(TP+FP+TN+FN)).  While that may not sound great, other professional sports models for predicting the outcome of any particular game are about as accurate (see here for example).  So I am in good company.
Any oddities in the below predictions?  If we assume that the team with the better record will win, then the following teams are predicted to pull an upset: Titans, Texans, Cowboys, Ravens, and Packers.  Looking at pro-football-reference.com, my predictions disagree in the predicted outcome in the following games: Jaguars/Titans, Broncos/Bears, Vikings/Packers, and Cardinals/Bengals.  There are lot's of good matchups so it should be an exciting week!
Here are the predictions for week 11:
Week
Date
Team
Home Away
Opponent
Probability Win
Predicted Team Win
Actual Team Win
11
11/19/2015
Jaguars
Titans
0.31
0
1
11
11/19/2015
Titans
@
Jaguars
0.69
1
0
11
11/22/2015
49ers
@
Seahawks
0.4
0
0
11
11/22/2015
Bears
Broncos
0.45
0
0
11
11/22/2015
Bengals
@
Cardinals
0.57
1
0
11
11/22/2015
Broncos
@
Bears
0.55
1
1
11
11/22/2015
Buccaneers
@
Eagles
0.4
0
1
11
11/22/2015
Cardinals
Bengals
0.43
0
1
11
11/22/2015
Chargers
Chiefs
0.46
0
0
11
11/22/2015
Chiefs
@
Chargers
0.54
1
1
11
11/22/2015
Colts
@
Falcons
0.3
0
1
11
11/22/2015
Cowboys
@
Dolphins
0.51
1
1
11
11/22/2015
Dolphins
Cowboys
0.49
0
0
11
11/22/2015
Eagles
Buccaneers
0.6
1
0
11
11/22/2015
Falcons
Colts
0.7
1
0
11
11/22/2015
Jets
@
Texans
0.43
0
0
11
11/22/2015
Lions
Raiders
0.43
0
1
11
11/22/2015
Packers
@
Vikings
0.56
1
1
11
11/22/2015
Panthers
Redskins
0.83
1
1
11
11/22/2015
Raiders
@
Lions
0.57
1
0
11
11/22/2015
Rams
@
Ravens
0.25
0
0
11
11/22/2015
Ravens
Rams
0.75
1
1
11
11/22/2015
Redskins
@
Panthers
0.17
0
0
11
11/22/2015
Seahawks
49ers
0.6
1
1
11
11/22/2015
Texans
Jets
0.57
1
1
11
11/22/2015
Vikings
Packers
0.44
0
0
11
11/23/2015
Bills
@
Patriots
0.25
0
0
11
11/23/2015
Patriots
Bills
0.75
1
1
_____________________________________________________________________________________

Wednesday, November 4, 2015

A Sudoku Solver and Thoughts on Automating Life

Introduction

While on a recent flight, I turned to the back of the inflight magazine to look for the crossword puzzle.  This was something my wife and I could do to pass the time while we also tried our best to entertain our infant son, who was sitting on our laps.  So we would take turns, one of us holding the magazine and reading the clues with pen in hand, the other, offering suggestions with baby on lap.  We quickly dispatched that and, needing something else to fill up the time, I turned my attention to the other inflight magazine puzzle offerings: Sudoku.
 
I had done my fair share of Sudoku puzzles, but it had been a while since I really attempted to work through a puzzle.  But as there was little else to do that would work as entertainment in the cramped space with a squirmy child, I decided to give it a shot.  I chose the easy puzzle and started to work.  I had an hour to complete my task.
 
I never finished.  Maybe it was the lack of focus to be had under such conditions.  Or maybe I was just out of practice.  Or maybe "easy" was harder than I thought it would be and I simply overestimated my abilities.  Whatever the reason was, the fact remained, and I had to put the unfinished puzzle back into the seat pouch as we arrived at our destination.
 
Frustrated by my inability to complete an "easy" Sudoku puzzle, what did I do?  Did I decide to practice, doing puzzle after puzzle to hone my skills?  Nope.  My goal was to complete Sudoku puzzles, so naturally, I thought of the best way to accomplish this goal: write a program to do it for me.
 

The Program

I chose my favorite language of late, R, to write the program in.  Perhaps not the most elegant language or most efficient for my task, but it would suffice.  The process for solving the puzzle is as follows (feel free to skip if you don't care):
  1. Load the puzzle to be solved into a matrix
  2. Create a work table with a row for each puzzle cell containing:
    • Row number
    • Column number
    • Square number (i.e., which 3x3 square block)
    • Possible values remaining
  3. Apply rules for eliminating values from possible values remaining
    1. If a row already contains a decided value, remove that value from the possible values list for every other cell in that row.
    2. If a column already contains a decided value, remove that value from the possible values list for every other cell in that column.
    3. If a square block already contains a decided value, remove that value from the possible values list for every other cell in that square block.
  4. Repeat step 3 until no more changes are made (i.e., no more possible values are removed).
  5. Check if solved (i.e., only one possible value remains for each cell).
    • If solved, verify results.  If verified, print solved puzzle.
    • If not solved or not verified, proceed to 6.
  6. Choose a remaining possible value for a cell and hold that fixed.  Then repeat steps 3-5. 
    • If no solution is found, hold the next remaining possible value for a cell fixed.  Then repeat steps 3-5. 
    • Do this for all cells until a solution is found and verified.
  7. Print solved puzzle solution.
Instead of taking an hour, it takes less than a second to solve a puzzle.  Hooray?
 

Missing the Point

Creating the program to solve the puzzle was like solving the puzzle itself.  I experienced frustration when my attempts didn't work, excitement when I had a breakthrough or revelation, and satisfaction when I had finally solved the puzzle (i.e., the code worked and solved the puzzles for me).  But I don't experience that same satisfaction now whenever I feed in a new puzzle to solve.  Wouldn't that be nice?  If I could experience each time the satisfaction of solving a puzzle with my code in the same way that I would experience it in solving it on my own?  But I don't.
 
This experience highlights a typical difference in the way people experience life: as a journey vs. a destination.  Is life, and its constituent parts (like solving a Sudoku), to be treated like a destination or a journey?  Whether any part should be treated like a journey or like a destination probably depends on our criteria for success.  At least in the case of solving a Sudoku puzzle, the criteria would seem to be something to do with its ability to produce fun, enjoyment, and satisfaction.
 
In treating the object of a Sudoku puzzle to be merely the destination (i.e., solving it), I missed its primary method of providing satisfaction, which is the experience of solving it, not actually solving it.  Sure, the actual solving is a part of the satisfaction, but it is only a small part of the experience, and hence, a small part of the satisfaction which comes from actually having worked through the solution myself to the final result.  That is, the journey is the most enjoyable part, not the destination alone.
 
I am reminded of the hedonistic paradox: if you aim at happiness as your only goal, you will miss it; if you aim at other things, you will find happiness as well.  In my attempt to automate Sudoku solving, I was aiming for the happiness of solving the puzzle, and I missed it.
 

So What?

This isn't really about Sudoku, but about life in general.  I love automation and greater efficiency, but certainly it seems that some things should not and cannot be automated if we are to benefit from them in desirable ways.  Particularly, if something comes too easily, we do not enjoy it nearly as much as we would have if it had come though challenges and obstacles.  We like working at things to a certain degree.  Projects, games, exercise, and other activities all have to be somewhat difficult, but not too difficult, to be worthwhile and worth doing for our own satisfaction and enjoyment.
 
An article in the Atlantic titled "A World Without Work" highlights the fact that we, to a certain degree, enjoy our work.  And we are more miserable if we aren't working. It seems that the only thing worse than having a job is not having a job.  Ask any retiree who has not transitioned to doing something else after retirement.  We need to have some challenge, some goal, some project in our life if we are to find meaning in it.
 
So what am I saying?  I suppose, automation and efficiency have their place and are important, but they may not be the most important consideration in designing and implementing a solution to a problem.  It just depends on the goal.  Many unpleasant tasks can, should, and will be automated most of the time.  But those tasks we enjoy and find satisfaction in doing ourselves, shouldn't always be.  I bet most things fall somewhere in the middle.  Like work, many tasks are enjoyable sometimes and not so enjoyable other times.  For example, driving is a chore a lot of the time, but occasionally (on backroads) it is fun. 
 

Automating Life Appropriately

A simple and obvious solution is to use automation and efficiency when we want to (e.g., driving the morning commute) and not when we don't want (e.g., driving country backroads).  As long as we have the option and can decide how and when we do things automatically instead of manually, we can have the best of both worlds.  When I want to wash the car, I can pull out the hose and scrub away.  When I don't, I can use the drive through.  When I want get my hands dirty and use my muscles, I can dig away in the garden and mow the lawn.  When I don't, I can get yard service.  In this way, we can have the advantages of automation and efficiency without being forced to give up the satisfaction of doing it ourselves.
 
My Sudoku solver works great, but I think I'll do it by hand and brain the next time around.  It won't be nearly as fast, but it will be fun.  And isn't that the point after all?