Wednesday, September 30, 2015

2015 NFL Game Predictions: Week 4

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!

_____________________________________________________________________________________

Week 4: Results
The predictions and the results are below.

My predictions went 9-6.  Not great, but a little better than just flipping a coin.  What happened?  What needs to improve?  Let’s look at each game where the prediction was wrong, and see what we can find:

·         Bears vs. Raiders

o   Predicted: 24% Bears likely to Lose, but Won.

o   Bears were 0-3 and Raiders were 2-1 going into this game.  Bears won 22-20, so it was close.  Jay Cutler (QB) was back after being out the previous week.  I expect that would help the Bears.  Other sites predicted a Bears loss.

·         Bills  vs. Giants

o   Predicted 65% Bills likely to Win, but lost.

o   Bills were 2-1 and Giants were 1-2 going into the game.  Giants clearly controlled the game throughout.  The final results was 24-10, so it wasn’t close.   Both sides are pretty injured, but perhaps the Giants are more injured.  Other sites predicted a Giants win.

·         Cardinals  vs. Rams

o   Predicted:  83% Cardinals likely to Win, but lost.

o   Cardinals were 3-0 and Rams were 1-2 going into the game.  Rams led the entire game, but it was always close and finished at 24-22.  Both teams are pretty healthy, but Cardinals were missing two wide receivers and their running back.  Other sites also predicted a Cardinals win.

·         Saints  vs. Cowboys

o   Predicted Saints to lose at 32%, but they won 26-20.

o    Saints were 0-3 and Cowboys were 2-1 going into the game.  The game went into overtime.  Cowboys were pretty injured, with major starters out (QB, WR), while Saints were pretty healthy.  Other sites predicted a Saints win, so in this I disagreed.

·         Redskins  vs. Eagles

o   Predicted Redskins to lose at 48%, but they won 23-20.

o   Redskins were 1-2 and Eagles were 1-2 going into the game.  The Redskins got ahead early but the Eagles came back heavily in the third quarter.  Eagles took the lead in the 4th quarter but lost it with less than a minute to play.  Both teams have lots of injuries, but Redskins were a bit more beat up.  Other sites predicted a Redskins loss as well.

·         Steelers  vs. Ravens

o   Predicted Steelers to win at 73%, but they lost 23-20.

o   Steelers were 2-1 and Ravens were 0-3 going into the game.  The lead went back and forth and went into overtime.  Steelers were pretty injured, including starting and backup Qbs.  Ravens were also pretty injured.  Other sites predicted a Steelers loss, so in this I disagreed.

I was in agreement with other sites for 4 of these 6 games in my prediction.  Each of these games I had predicted the team with the better record to win.  Every game but one was close, and two went into overtime.  So these could have gone the other way pretty easily.  Some players were injured that weren’t injured in previous games and vice versa.  The difference in healthiness of each team seems to matter.  So going forward, it looks like I need to account for injuries in my model.  I also need less emphasis on who has the best record going into the game.  Instead, I should look at previous season records and also the strength of opponents in previous games this season.

I’ll make some adjustments and try again in a few weeks.

Week 4: First Published Predictions (Win/Lose)

I have to start somewhere, so this is where I am starting.  In alphabetical order, each team is listed with its associated next game.  Details include Home vs. Away, the Opponent, the Probability of Winning (according to my model) and the predicted result (1 for a win, 0 for a loss).  I'll analyze and comment after these games are played and the final results are in.

(Note: already I see issues.  For example, at least the Steelers vs. Ravens predictions are wrong because the Steelers starting QB is out.  Injuries to starters is something my model does not yet account for.  But it looks like it should.  Next time :) )

Team
HomeAway
Opponent
ProbabilityWin
PredictedTeamWin
ActualTeamWin
49ers
Packers
0.22
0
0
Bears
Raiders
0.24
0
1
Bengals
Chiefs
0.7
1
1
Bills
Giants
0.65
1
0
Broncos
Vikings
0.58
1
1
Browns
@
Chargers
0.5
0
0
Buccaneers
Panthers
0.24
0
0
Cardinals
Rams
0.83
1
0
Chargers
Browns
0.5
1
1
Chiefs
@
Bengals
0.3
0
0
Colts
Jaguars
0.55
1
1
Cowboys
@
Saints
0.68
1
0
Dolphins
Jets
0.3
0
0
Eagles
@
Redskins
0.52
1
0
Falcons
Texans
0.69
1
1
Giants
@
Bills
0.35
0
1
Jaguars
@
Colts
0.45
0
0
Jets
@
Dolphins
0.7
1
1
Lions
@
Seahawks
0.3
0
0
Packers
@
49ers
0.78
1
1
Panthers
@
Buccaneers
0.76
1
1
Raiders
@
Bears
0.76
1
0
Rams
@
Cardinals
0.17
0
1
Ravens
@
Steelers
0.27
0
1
Redskins
Eagles
0.48
0
1
Saints
Cowboys
0.32
0
1
Seahawks
Lions
0.7
1
1
Steelers
Ravens
0.73
1
0
Texans
@
Falcons
0.31
0
0
Vikings
@
Broncos
0.42
0
0

__________________________________________________________________________________

Wednesday, September 9, 2015

Hold'em or Fold'em: Validating a Winning Strategy

Introduction

In previous posts (here and here) I analyzed simulated hold'em poker hands to determine a winning strategy.  Bluffing aside, when should you play and when should you fold in order to have the best chances of winning?

The observations I made do not readily yield a single strategy for play.  They may sometimes conflict or be overly conservative when combined.  For example, my advice for hole cards may offer a more than 50% chance of winning on its own, but when combined with the advice on hand rankings (which also offers a better than 50% chance of winning) it may require the folding of many winning hands.

Still, we need a place to start.  Perhaps the principles I generated can be condensed, simplified, reorganized, and summed up in this way:

A Strategy

  • Hole cards
    • If your hole cards form a pair, contain an Ace, or have a rounded average rank greater than or equal to 10...
      • Continue playing
    • Else
      • Fold
  • Flop, Turn, River
    • If you have two pair 5s or better, one pair Queens or better, or three of a kind or better
      • Continue playing
    • Else
      • Fold
Will this strategy work?  Let's validate it by simulating a game against one other player.

The Program

The program remains largely the same as before, except that I have now implemented the above logic into the program.  If one folds on the hole cards, then this is tracked as "Fold - hole cards".  If one passes this test but fails on the flop, turn, or river, this is tracked as "Fold - Flop, Turn, River".  If one passes both tests, then this is tracked as "Play".

I reran 100,000 simulations of hold'em deals to Player1 and Player2.  A successful strategy will have a high percentage of Win/Play combos along with a high percentage of Lose/Fold combos.  That is, we want to play when we will win, and fold when we will lose.  If our strategy is not successful, then there will be a high percentage of Win/Fold combos (we folded when we would have won the hand) and Lose/Play combos (we played when we would have lost).

In other words, the ideal simplified scenario can be represented by the below confusion matrix:
Play
Fold
Win
50
0
Lose
0
50

In the above scenario, a win is as equally likely as a loss, so each occurs 50% of the time, adding to 100%.  However, we have predicted perfectly, so we won all the hands we have played, and lost only the hands we have folded.  Assuming we have been betting well (betting minimally with hands we will fold, betting maximally with hands we will win), the eventual result will be that we win the game and all of the money.

What does the actual confusion matrix look like?

Validation

The results of implementing this strategy are below:
Player1 Result/Action
Fold - Flop, Turn, River
Fold - hole cards
Play
Grand Total
Lose
10773
32593
4548
47914
Tie
326
3044
816
4186
Win
7158
24708
16034
47900
Grand Total
18257
60345
21398
100000


The table above gives the final result for Player1's hand (left side) and Player1's action based on the simplified principles we gave him (top).  The combinations are displayed in the middle, with row/column totals on the ends.

A simplified version of the table:
Player1 Result/Action
Fold
Play
Grand Total
Lose
43366
4548
47914
Tie
3370
816
4186
Win
31866
16034
47900
Grand Total
78602
21398
100000


Some observations:
  • As we would expect, Player1's hands lose and win about equally
  • Player1 wins about 75% of the hands he plays
  • Player1 only plays 21% of the hands
  • Of all the hands Player1 would have lost, he only plays 9% of them
  • Of all the hands Player1 would have won, he only plays 33% of them
  • 40% of Player1's folds were winning hands
  • Player1 only plays 19% of ties.

Strengths of this approach:
  • Player1 plays very few of the games he will lose
  • The strategy is simple
  • The strategy relies on information known at the time of decision

Weakness of this Approach
  • Player1 folds quite a few games in which, if he had played, he would have won
  • Player1 folds most of the games in which there is a tie (and would split the pot)
  • Player1 plays very few games

This is definitely a conservative strategy.  The result of combining the various insights we have gathered in previous posts is too cautious.  Player1 only plays when there is a great chance of winning.  Perhaps with good betting and bluffing, this can be a very effective strategy.  However, it folds a lot of winning hands, in fact, most winning hands. 

The strategy misclassifies (ignoring ties) 38% of all hands.  Counting ties (assuming you should play ties), it misclassifies 40% of all hands, that is, 40% of the time it recommends a fold when you should play and recommends that you play when you should fold.

Is there a better way?  Most certainly.  Let's use machine learning to analyze our data and come up with a more effective model.

Machine Learning: Decision Tree

I use a decision tree to develop a model for hold'em strategy because it is easy to understand the decision paths.  Here is a plot of the model along with the associated splits and ratios of classification:



The details may be difficult to see, so here is the decision tree strategy with words:
  • Flop, Turn, River
    • If Player1 has two pair or better
      • Play
    • Else (Player1 has one pair or high card)
      • If Player1 has a high card hand
        • Fold
      • Else (if Player1 has one pair)
        • If both of the cards that make up the one pair are in the community cards
          • Fold
        • Else (if only 0 or 1 of the cards that make up the one pair are in the community cards)
          • Play

This model has only 27% misclassification, that is, it predicts a loss when you really win or predicts a win when you really lose, about 27% of the time.  The confusion matrix is below for play/fold and win/lose/tie combinations:

Player1 Result/Action
Fold
Play
Grand Total
Lose
29591
18323
47914
Tie
1452
2734
4186
Win
7429
40471
47900
Grand Total
38472
61528
100000


Some observations:
  • Player1 wins about 66% of the hands he plays
  • Player1 plays 62% of the hands
  • Of all the hands Player1 would have lost, he plays 39% of them
  • Of all the hands Player1 would have won, he plays 84% of them
  • Only 19% of Player1's folds were winning hands
  • Player1 plays 65% of ties.

Strengths of this approach:
  • Most folds are losses; most plays are wins
  • The strategy is simple

Weakness of this Approach
  • The strategy relies on information not known at time of decision (at least before flop)
  • Player1 plays too many hands (in particular, too many losing hands)
This strategy is much more effective.  However, it offers no guidance for the hole cards, recommending that one should always play at least through the flop.

Do the hole cards really matter in an overall strategy?  Looking at another decision tree using only the hole card information (max rank, min rank, average rank, pair (yes/no)) reveals that, at best, the model will still misclassify about 43% of the time.  A simple split based on the average rank of the hole cards being >= 7.5 yields only a slight advantage in winning (54%) and correctly classifies only 45% of the time. 

If we force the previous decision to use the hole card information to its full extent, the model becomes incredibly complex (over 1000 nodes) and only improves to about 26% misclassification.  The decision tree looks like this:



Clearly, this isn't helpful.  But we know hole cards are important to some degree, so shouldn't this count for something?  In addition, this strategy plays too many hands, and as a result, plays too many losing hands.

A Compromise


What should we do now?  If we compare the first strategy, we see that the major problem is that one folds too much, particularly, on hands that would have been won (the lower left corner green box).  It plays too little.  In contrast, the decision tree model plays too much, in particular, it plays too many hands that it will lose (the upper right yellow box).

Is there a way to combine both strategies in a way that is more effective than either, is still simple, plays about 50% of the time, and provides more guidance at each stage of the game?  I combined both approaches and played with the logic until coming up with a more balanced strategy:
  • Hole Cards
    • If the rounded average rank of the hole cards is >= 6 or the hole cards form a pair
      • Continue Playing
    • Else
      • Fold
  • Flop, Turn, River
    • If you have two pair or better
      • Continue Playing
    • Else (one pair or high card)
      • If one pair, only 0 or 1 of the cards that make up the one pair are in the community cards, and the pair is 5s or better
        • Continue playing
      • Else (high card, one pair of 4s or worse, or one pair with both pair cards in the community)
        • Fold
The confusion matrix is as follows (I validated the approach against a test set and the results were virtually the same):

Player1 Result/Action
Fold
Play
Grand Total
Lose
35010
12904
47914
Tie
2005
2181
4186
Win
13500
34400
47900
Grand Total
50515
49485
100000


Some observations:
  • Player1 wins about 70% of the hands he plays
  • Player1 plays 49% of the hands
  • Of all the hands Player1 would have lost, he only plays 27% of them
  • Of all the hands Player1 would have won, he plays 72% of them
  • 26% of Player1's folds were winning hands
  • Player1 plays 52% of ties.
  • The strategy misclassifies 28% of the time.

Strengths of this approach:
  • Most plays are wins; most folds are losses
  • The strategy is still fairly simple
  • The strategy relies more on information known at the time of decision
  • Player1 plays about half the time
  • The misclassification is low.

This approach does not suffer the weakness of the other two approaches, but represents a balanced compromise between them. While the initial strategy is too conservative, the decision tree strategy is too liberal.  This compromise still has good predictive power, is simple, and useful, and represents a middle ground strategy.

Conclusion

As the foregoing shows, there is no single master strategy for winning at poker.  Any strategy will have strengths and weaknesses.  And different strategies may, for this reason, appeal to different people.  What I have shown above are some data driven strategies designed to maximize strengths and minimize weaknesses, but how they do so differs.  Feel free to choose the strategy (or modified suitably) that appeals to you.

This concludes my analysis of poker hands.  For now at least....

Good luck!