Skip to content

Instantly share code, notes, and snippets.

@zzh8829
Last active August 28, 2016 23:41
Show Gist options
  • Select an option

  • Save zzh8829/bc9f8e7534a13d5e9cca6c3b3d8839f0 to your computer and use it in GitHub Desktop.

Select an option

Save zzh8829/bc9f8e7534a13d5e9cca6c3b3d8839f0 to your computer and use it in GitHub Desktop.
Poker profit prediction
import numpy as np
import matplotlib.pyplot as plt
import csv
import re
def graph_profit(profit):
x = np.arange(len(profit))
y = np.cumsum(profit)
p1 = np.poly1d(np.polyfit(x, y, 3))
p2 = np.poly1d(np.polyfit(x, y, 4))
p3 = np.poly1d(np.polyfit(x, y, 5))
xp = np.linspace(0, 200, 100)
graph = plt.plot(x, y, '.', xp, p1(xp), '-', xp, p2(xp), '--', xp, p3(xp), '*')
plt.ylim(-20,20)
plt.show()
rows = []
with open('Poker.csv') as f:
reader = csv.reader(f)
rows = list(reader)
del rows[0]
print(rows)
def column(matrix, i):
return [row[i] for row in matrix]
def graph_type(game_type):
games = list(filter(lambda row: re.match(game_type, row[1]) is not None, rows))
buyin = np.array(column(games, 2)).astype(float)
result = np.array(column(games, 3)).astype(float)
graph_profit(result - buyin)
graph_type('.')
graph_type('Spin-N-Go')
graph_type('Cash Game')
graph_type('Heads Up')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment