{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exercise: Analyzing Poker Hand Outcomes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's explore a question: how can we best visualize the likely outcomes of a poker hand given that we haven't been dealt all the cards yet? In this case, we start with a set of cards and then deal out the remaining 7 cards to complete the hand and determine the highest rank of each hand that results. Let's create a function that plots the counts of each set of resulting hands by rank so that we can compare each partial hand's strategic value. This could be very useful in terms of determining how likely a winning hand was from a particular staring point.\n", "\n", "Let's familiarize ourselves with the data. Our virtual deck of cards consists of cards with 13 possible values: 2,3,4,5,6,7,8,9,0,J,Q,K,A. Here 0 represents the value 10, and Jack, Queen, King, and Ace are represented as J,Q,K, and A, respectively. The four possible suits are represented as s (spades), c (clubs), d, diamonds, and h (hearts). The number of starting cards in the hands could vary (we may have been dealt 1 card, 2 cards, 3 cards, etc.), but the full hand consists of 7 cards. After being dealt, each hand is evaluated for the highest hand rank it contains ranging from the lowest (high card) to the highest (straight flush).\n", "\n", "**(1)** Begin by loading and viewing the raw data which you can find in the file \"poker_results.csv\". You'll notice that this is essentially the content of a histogram of sorts where instead of bins with ranges of values, we have hand ranks." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Cards | \n", "high card | \n", "pair | \n", "two pair | \n", "three of a kind | \n", "straight | \n", "flush | \n", "full house | \n", "four of a kind | \n", "straight flush | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "As Ks Qs Js | \n", "861 | \n", "2125 | \n", "946 | \n", "166 | \n", "1103 | \n", "4115 | \n", "58 | \n", "2 | \n", "624 | \n", "
1 | \n", "8s 8c 7c 6s | \n", "0 | \n", "3451 | \n", "3856 | \n", "767 | \n", "1117 | \n", "214 | \n", "562 | \n", "28 | \n", "5 | \n", "
2 | \n", "As Jh 0d 8c | \n", "2321 | \n", "4654 | \n", "1578 | \n", "238 | \n", "1141 | \n", "0 | \n", "67 | \n", "1 | \n", "0 | \n", "
3 | \n", "As Ah Ks Kh | \n", "0 | \n", "0 | \n", "7440 | \n", "0 | \n", "32 | \n", "199 | \n", "2274 | \n", "54 | \n", "1 | \n", "
4 | \n", "As Kh Qs Jc | \n", "2053 | \n", "3757 | \n", "1479 | \n", "242 | \n", "2311 | \n", "87 | \n", "71 | \n", "0 | \n", "0 | \n", "
5 | \n", "8s 8c 7c 6c | \n", "0 | \n", "3079 | \n", "3529 | \n", "731 | \n", "1019 | \n", "985 | \n", "551 | \n", "26 | \n", "80 | \n", "
6 | \n", "8s 8c 8d | \n", "0 | \n", "0 | \n", "0 | \n", "5854 | \n", "74 | \n", "72 | \n", "3191 | \n", "809 | \n", "0 | \n", "
7 | \n", "2h 7c 3d | \n", "2339 | \n", "4718 | \n", "2028 | \n", "412 | \n", "294 | \n", "69 | \n", "130 | \n", "9 | \n", "1 | \n", "
8 | \n", "Ah | \n", "1781 | \n", "4410 | \n", "2390 | \n", "503 | \n", "345 | \n", "311 | \n", "241 | \n", "16 | \n", "3 | \n", "