In [1]:
from itertools import combinations
import numpy as np
import pandas as pd
import pickle as pkl
import time


pd.options.display.max_rows = 100

In [40]:
summary_df = pd.read_csv('leave_summary_20200508.csv').rename(columns={'Unnamed: 0':'leave'}).set_index('leave')

In [41]:
count_dict = summary_df['count'].to_dict()
equity_dict = summary_df['equity'].to_dict()
mean_equity_dict = summary_df['mean_equity'].to_dict()
summary_df = summary_df.reset_index()

In [42]:
summary_df['leave_len'] = summary_df['leave'].apply(lambda x: len(x))

In [5]:
leaves = pkl.load(open('all_leaves.p','rb'))
alphabetical_key = '?ABCDEFGHIJKLMNOPQRSTUVWXYZ'
sort_func = lambda x: alphabetical_key.index(x)

In [6]:
child_leaves = {leave:[''.join(sorted(leave+letter, key=sort_func)) for letter in alphabetical_key]
                for i in range(1,6) for leave in leaves[i]}
child_leaves[''] = [x for x in alphabetical_key]

In [7]:
list(combinations('AABBJ',4))


Out[7]:
[('A', 'A', 'B', 'B'),
 ('A', 'A', 'B', 'J'),
 ('A', 'A', 'B', 'J'),
 ('A', 'B', 'B', 'J'),
 ('A', 'B', 'B', 'J')]

The following doesn't filter out impossible racks - we do that in the calculate_smoothed_superleave function instead to make this code faster.


In [8]:
def get_neighboring_leaves(original_leave):
    t0 = time.time()
    subleaves = [''.join(x) for x in combinations(original_leave, len(original_leave)-1)]
    t1 = time.time()
    
    neighbors = []
    for leave in subleaves:
        neighbors += child_leaves[leave]
        
    t2 = time.time()
    
    # filter neighbors to make sure they have the same number of blanks
    blank_count = sum([x=='?' for x in original_leave])
    
    t3 = time.time()
    
    neighbors = [leave for leave in neighbors if(sum([x=='?' for x in leave])==blank_count)]
    
    t4 = time.time()
    
    return neighbors

In [9]:
def calculate_smoothed_superleave(superleave):
    neighbors = get_neighboring_leaves(superleave)
    
    neighboring_equity = 0
    neighboring_count = 0
    equity_list = []
        
    for neighbor_leave in neighbors:
        neighboring_equity += equity_dict.get(neighbor_leave, 0)
        neighboring_count += count_dict.get(neighbor_leave, 0)
        equity_list.append(mean_equity_dict.get(neighbor_leave))
                
    equity_list = [x for x in equity_list if pd.notnull(x)]
    
#     print('Original:')
#     print(summary_df.loc[summary_df['leave']==superleave])
#     print(neighboring_equity, neighboring_count, neighboring_equity/neighboring_count)
#     print(np.mean(equity_list))
#     print(equity_list)
    
    return neighboring_equity/neighboring_count

3820 superleaves of length 6 were never observed once


In [10]:
print(summary_df.loc[summary_df['leave_len']==6].apply(lambda x: pd.notnull(x['ev']), axis=1).value_counts())
print(summary_df.loc[summary_df['leave_len']==6].apply(lambda x: pd.notnull(x['ev']) and x['count']<10, axis=1).value_counts())


True     733491
False      3820
dtype: int64
False    676958
True      60353
dtype: int64

In [11]:
summary_df.loc[summary_df['leave_len']==5].sort_values('ev', ascending=False)[:50]


Out[11]:
leave points equity count bingo_count mean_score mean_equity bingo pct pct adjusted_mean_score ev leave_len
167808 ??LQX 2917 15182.514 103 2 28.320388 147.403049 1.941748 0.011261 -10.751291 106.315359 5
109471 ??DQX 3218 15198.186 110 0 29.254545 138.165327 0.000000 0.012027 -9.817134 97.077638 5
108048 ??DMZ 12534 44523.936 382 61 32.811518 116.554806 15.968586 0.041766 -6.260161 75.467117 5
169820 ??MOZ 28258 64857.103 585 184 48.304274 110.866843 31.452991 0.063961 9.232594 69.779154 5
78274 ??CCV 3659 17857.948 167 21 21.910180 106.933820 12.574850 0.018259 -17.161500 65.846131 5
87025 ??CHK 9801 29445.381 277 70 35.382671 106.301014 25.270758 0.030286 -3.689008 65.213325 5
123214 ??ESZ 94252 101743.515 985 765 95.687310 103.292909 77.664975 0.107695 56.615630 62.205219 5
108972 ??DOZ 48383 84760.445 827 318 58.504232 102.491469 38.452237 0.090420 19.432553 61.403780 5
118409 ??EIZ 250647 270260.787 2662 2148 94.157400 101.525465 80.691210 0.291049 55.085721 60.437776 5
107424 ??DLX 18761 35242.078 353 116 53.147309 99.835915 32.861190 0.038595 14.075629 58.748226 5
43198 ??AEZ 203401 221510.987 2224 1631 91.457284 99.600264 73.336331 0.243160 52.385605 58.512575 5
90483 ??CKP 8142 14638.810 147 69 55.387755 99.583741 46.938776 0.016072 16.316076 58.496052 5
157270 ??ISZ 73979 81373.446 822 596 89.998783 98.994460 72.506083 0.089873 50.927104 57.906771 5
54189 ??ASZ 65156 71895.144 728 526 89.500000 98.757066 72.252747 0.079596 50.428321 57.669377 5
122367 ??EOZ 171302 190557.809 1940 1407 88.300000 98.225675 72.525773 0.212109 49.228321 57.137986 5
47261 ??AHK 26550 45745.994 466 229 56.974249 98.167369 49.141631 0.050950 17.902570 57.079680 5
49384 ??AIZ 165876 182218.695 1859 1340 89.228618 98.019739 72.081764 0.203253 50.156938 56.932050 5
37655 ??ACK 37058 56761.007 581 350 63.783133 97.695365 60.240964 0.063523 24.711453 56.607676 5
174150 ??OSZ 51206 57876.460 593 404 86.350759 97.599427 68.128162 0.064835 47.279080 56.511737 5
175662 ??QSU 59135 68665.694 704 489 83.998580 97.536497 69.460227 0.076972 44.926900 56.448808 5
53785 ??AQU 119537 134891.931 1383 997 86.433116 97.535742 72.089660 0.151210 47.361437 56.448053 5
122810 ??EQU 180728 205861.301 2111 1538 85.612506 97.518380 72.856466 0.230805 46.540827 56.430691 5
121443 ??EMZ 43088 53469.498 550 312 78.341818 97.217269 56.727273 0.060134 39.270139 56.129580 5
37117 ??ACH 92491 112123.695 1155 903 80.078788 97.076792 78.181818 0.126281 41.007109 55.989103 5
123071 ??ERZ 139353 150959.207 1564 1122 89.100384 96.521232 71.739130 0.170999 50.028704 55.433543 5
98828 ??DEZ 83352 97415.462 1012 625 82.363636 96.260338 61.758893 0.110647 43.291957 55.172649 5
155499 ??IMZ 32716 43561.489 453 246 72.220751 96.162227 54.304636 0.049529 33.149071 55.074538 5
52418 ??AMZ 32695 42406.069 441 243 74.138322 96.158887 55.102041 0.048217 35.066643 55.071197 5
90663 ??CKS 20637 23638.186 246 196 83.890244 96.090187 79.674797 0.026896 44.818565 55.002498 5
156012 ??INZ 116282 127840.684 1331 935 87.364388 96.048598 70.247934 0.145524 48.292708 54.960909 5
156866 ??IQU 147488 164620.370 1716 1221 85.948718 95.932617 71.153846 0.187618 46.877039 54.844927 5
170667 ??MSZ 12455 16401.937 171 88 72.836257 95.917760 51.461988 0.018696 33.764578 54.830071 5
123205 ??ESX 75647 82160.503 857 639 88.269545 95.869898 74.562427 0.093700 49.197866 54.782209 5
121956 ??ENZ 142603 156132.945 1631 1134 87.432863 95.728354 69.527897 0.178325 48.361184 54.640665 5
156423 ??IOZ 129941 148466.690 1553 1033 83.670959 95.599929 66.516420 0.169797 44.599280 54.512240 5
92182 ??CMZ 6300 18595.424 195 33 32.307692 95.361149 16.923077 0.021320 -6.763987 54.273460 5
87777 ??CHS 45443 48999.571 514 441 88.410506 95.329905 85.797665 0.056198 49.338827 54.242216 5
77801 ??CCN 16460 32299.055 339 163 48.554572 95.277448 48.082596 0.037064 9.482893 54.189759 5
53342 ??AOZ 108947 124008.183 1305 840 83.484291 95.025428 64.367816 0.142682 44.412612 53.937738 5
157127 ??IRZ 118214 129601.078 1367 955 86.476957 94.806933 69.861010 0.149460 47.405278 53.719244 5
170894 ??MYZ 5018 8334.299 88 35 57.022727 94.707943 39.772727 0.009621 17.951048 53.620254 5
123314 ??ETZ 142733 156549.392 1653 1150 86.347852 94.706226 69.570478 0.180730 47.276173 53.618537 5
105014 ??DIZ 71109 84086.966 889 531 79.987627 94.586013 59.730034 0.097198 40.915947 53.498324 5
120828 ??ELZ 91571 100790.813 1068 728 85.740637 94.373420 68.164794 0.116769 46.668957 53.285731 5
147719 ??HKS 14530 18094.825 192 131 75.677083 94.243880 68.229167 0.020992 36.605404 53.156191 5
81530 ??CEH 129647 138979.117 1477 1284 87.777251 94.095543 86.932972 0.161487 48.705572 53.007854 5
87915 ??CHY 13515 15859.467 169 116 79.970414 93.843000 68.639053 0.018478 40.898735 52.755311 5
54046 ??ARZ 93845 102697.321 1096 731 85.625000 93.701935 66.697080 0.119831 46.553321 52.614246 5
54289 ??ATZ 101524 113502.236 1212 758 83.765677 93.648710 62.541254 0.132513 44.693997 52.561020 5
151009 ??HSZ 11380 13294.816 142 83 80.140845 93.625465 58.450704 0.015526 41.069166 52.537776 5

In [43]:
summary_df['smoothed_ev'] = summary_df['ev']
summary_df['point_equity_diff'] = (summary_df['points']-summary_df['equity'])/summary_df['count']

In [13]:
summary_df.sort_values('point_equity_diff')[:50]


Out[13]:
leave points equity count bingo_count mean_score mean_equity bingo pct pct adjusted_mean_score ev leave_len smoothed_ev point_equity_diff
618171 ??DLQX 303 12408.544 46 0 6.586957 269.750957 0.000000 0.005029 -32.484723 228.663267 6 228.663267 -263.164000
559834 ??DDQX 26 815.492 3 0 8.666667 271.830667 0.000000 0.000328 -30.405013 230.742978 6 230.742978 -263.164000
879005 ??LLQX 107 1215.027 7 0 15.285714 173.575286 0.000000 0.000765 -23.785965 132.487597 6 132.487597 -158.289571
886010 ??LPQX 48 976.316 6 0 8.000000 162.719333 0.000000 0.000656 -31.071679 121.631644 6 121.631644 -154.719333
887144 ??LQXY 74 351.173 2 0 37.000000 175.586500 0.000000 0.000219 -2.071679 134.498811 6 134.498811 -138.586500
886915 ??LQSX 56 324.656 2 0 28.000000 162.328000 0.000000 0.000219 -11.071679 121.240311 6 121.240311 -134.328000
620183 ??DMOZ 2583 32787.245 233 3 11.085837 140.717790 1.287554 0.025475 -27.985842 99.630101 6 99.630101 -129.631953
457258 ??CCJV 10 138.164 1 0 10.000000 138.164000 0.000000 0.000109 -29.071679 97.076311 6 97.076311 -128.164000
459910 ??CCNV 987 14439.933 107 0 9.224299 134.952645 0.000000 0.011699 -29.847380 93.864956 6 93.864956 -125.728346
616124 ??DLLX 281 1382.806 9 1 31.222222 153.645111 11.111111 0.000984 -7.849457 112.557422 6 112.557422 -122.422889
167808 ??LQX 2917 15182.514 103 2 28.320388 147.403049 1.941748 0.011261 -10.751291 106.315359 5 106.315359 -119.082660
625176 ??DPQX 108 792.975 6 0 18.000000 132.162500 0.000000 0.000656 -21.071679 91.074811 6 91.074811 -114.162500
621254 ??DMXZ 102 655.941 5 0 20.400000 131.188200 0.000000 0.000547 -18.671679 90.100511 6 90.100511 -110.788200
109471 ??DQX 3218 15198.186 110 0 29.254545 138.165327 0.000000 0.012027 -9.817134 97.077638 5 97.077638 -108.910782
511335 ??CHHK 23 239.828 2 0 11.500000 119.914000 0.000000 0.000219 -27.571679 78.826311 6 78.826311 -108.414000
621231 ??DMVZ 90 1056.478 9 0 10.000000 117.386444 0.000000 0.000984 -29.071679 76.298755 6 76.298755 -107.386444
868729 ??KMOZ 107 744.541 6 0 17.833333 124.090167 0.000000 0.000656 -21.238346 83.002478 6 83.002478 -106.256833
531480 ??CKPW 13 118.164 1 0 13.000000 118.164000 0.000000 0.000109 -26.071679 77.076311 6 77.076311 -105.164000
554127 ??DDHW 1339 17399.928 153 1 8.751634 113.725020 0.653595 0.016728 -30.320045 72.637330 6 72.637330 -104.973386
873722 ??KPQX 11 111.497 1 0 11.000000 111.497000 0.000000 0.000109 -28.071679 70.409311 6 70.409311 -100.497000
235175 ??ACHK 2613 17832.269 152 11 17.190789 117.317559 7.236842 0.016619 -21.880890 76.229870 6 76.229870 -100.126770
884999 ??LOQX 470 1971.587 15 0 31.333333 131.439133 0.000000 0.001640 -7.738346 90.351444 6 90.351444 -100.105800
458020 ??CCKV 18 315.492 3 0 6.000000 105.164000 0.000000 0.000328 -33.071679 64.076311 6 64.076311 -99.164000
737649 ??FLQX 100 397.120 3 0 33.333333 132.373333 0.000000 0.000328 -5.738346 91.285644 6 91.285644 -99.040000
473603 ??CDKP 657 3917.084 33 2 19.909091 118.699515 6.060606 0.003608 -19.162588 77.611826 6 77.611826 -98.790424
455134 ??CCHV 72 663.902 6 0 12.000000 110.650333 0.000000 0.000656 -27.071679 69.562644 6 69.562644 -98.650333
536150 ??CMMZ 14 112.164 1 0 14.000000 112.164000 0.000000 0.000109 -25.071679 71.076311 6 71.076311 -98.164000
557548 ??DDLQ 289 1265.540 10 0 28.900000 126.554000 0.000000 0.001093 -10.171679 85.466311 6 85.466311 -97.654000
573229 ??DEQX 554 2386.622 19 0 29.157895 125.611684 0.000000 0.002077 -9.913785 84.523995 6 84.523995 -96.453789
714795 ??FHHW 0 96.164 1 0 0.000000 96.164000 0.000000 0.000109 -39.071679 55.076311 6 55.076311 -96.164000
713773 ??FHHJ 0 96.164 1 0 0.000000 96.164000 0.000000 0.000109 -39.071679 55.076311 6 55.076311 -96.164000
696970 ??FFHJ 7 103.164 1 0 7.000000 103.164000 0.000000 0.000109 -32.071679 62.076311 6 62.076311 -96.164000
538021 ??CMTZ 1371 12265.804 115 4 11.921739 106.659165 3.478261 0.012573 -27.149940 65.571476 6 65.571476 -94.737426
340579 ??BBKS 8 100.164 1 0 8.000000 100.164000 0.000000 0.000109 -31.071679 59.076311 6 59.076311 -92.164000
745734 ??FQUZ 17 109.164 1 0 17.000000 109.164000 0.000000 0.000109 -22.071679 68.076311 6 68.076311 -92.164000
862499 ??JQUZ 10 102.164 1 0 10.000000 102.164000 0.000000 0.000109 -29.071679 61.076311 6 61.076311 -92.164000
805920 ??HJQZ 10 102.164 1 0 10.000000 102.164000 0.000000 0.000109 -29.071679 61.076311 6 61.076311 -92.164000
453720 ??CCGV 88 636.152 6 0 14.666667 106.025333 0.000000 0.000656 -24.405013 64.937644 6 64.937644 -91.358667
869095 ??KMQS 23 205.328 2 0 11.500000 102.664000 0.000000 0.000219 -27.571679 61.576311 6 61.576311 -91.164000
869233 ??KMQY 23 205.328 2 0 11.500000 102.664000 0.000000 0.000219 -27.571679 61.576311 6 61.576311 -91.164000
894431 ??MPQY 0 91.164 1 0 0.000000 91.164000 0.000000 0.000109 -39.071679 50.076311 6 50.076311 -91.164000
889937 ??MMQY 8 99.164 1 0 8.000000 99.164000 0.000000 0.000109 -31.071679 58.076311 6 58.076311 -91.164000
856930 ??JMQY 0 91.164 1 0 0.000000 91.164000 0.000000 0.000109 -39.071679 50.076311 6 50.076311 -91.164000
886772 ??LQRX 398 1755.184 15 0 26.533333 117.012267 0.000000 0.001640 -12.538346 75.924578 6 75.924578 -90.478933
515106 ??CHKX 18 108.164 1 0 18.000000 108.164000 0.000000 0.000109 -21.071679 67.076311 6 67.076311 -90.164000
793476 ??HHMM 11 98.831 1 0 11.000000 98.831000 0.000000 0.000109 -28.071679 57.743311 6 57.743311 -87.831000
813727 ??HMMW 9 96.831 1 0 9.000000 96.831000 0.000000 0.000109 -30.071679 55.743311 6 55.743311 -87.831000
813709 ??HMMV 7 94.831 1 0 7.000000 94.831000 0.000000 0.000109 -32.071679 53.743311 6 53.743311 -87.831000
328220 ??BBCX 7 94.164 1 0 7.000000 94.164000 0.000000 0.000109 -32.071679 53.076311 6 53.076311 -87.164000
459436 ??CCMZ 20 194.328 2 0 10.000000 97.164000 0.000000 0.000219 -29.071679 56.076311 6 56.076311 -87.164000

In [14]:
leaves_to_smooth = list(summary_df.loc[(summary_df['leave_len']==5) & (summary_df['count']<828)]['leave'].values)
print(len(leaves_to_smooth))
leaves_to_smooth += list(summary_df.loc[(summary_df['leave_len']==6) & (summary_df['count']<234)]['leave'].values)
print(len(leaves_to_smooth))


37022
472533

"ev" is defined as the average equity of a superleave, minus the average equity over all plays in a run of simulated games. It's about 41 points.


In [15]:
mean_equity = summary_df.loc[summary_df['leave']=='??']['mean_equity'].values[0] - \
    summary_df.loc[summary_df['leave']=='??']['ev'].values[0]

In [44]:
summary_df = summary_df.set_index('leave')
smooth_ev_dict = summary_df['ev'].to_dict()

In [17]:
ev_dict = summary_df['ev'].to_dict()

In [18]:
smooth_ev_dict['AABBJ']


Out[18]:
-5.292460051313853

In [26]:
t0 = time.time()

for i,leave in enumerate(leaves_to_smooth):
    if (i+1)%1000==0:
        print(i, time.time()-t0)
    
    smooth_ev_dict[leave] = calculate_smoothed_superleave(leave) - mean_equity


999 0.24371099472045898
1999 0.4743340015411377
2999 0.7030730247497559
3999 0.9337389469146729
4999 1.1726887226104736
5999 1.406951904296875
6999 1.641942024230957
7999 1.878746747970581
8999 2.1052029132843018
9999 2.326411008834839
10999 2.5659329891204834
11999 2.823171854019165
12999 3.063843011856079
13999 3.3091189861297607
14999 3.549504041671753
15999 3.7925429344177246
16999 4.060200929641724
17999 4.315937042236328
18999 4.573595762252808
19999 4.811480760574341
20999 5.068622827529907
21999 5.3416218757629395
22999 5.602749824523926
23999 5.869962930679321
24999 6.131170034408569
25999 6.394488096237183
26999 6.647558927536011
27999 6.913771867752075
28999 7.185763835906982
29999 7.466888904571533
30999 7.744753837585449
31999 8.032512903213501
32999 8.311309814453125
33999 8.57605504989624
34999 8.826551914215088
35999 9.069002866744995
36999 9.304077863693237
37999 9.595224857330322
38999 9.929030895233154
39999 10.277236938476562
40999 10.589678764343262
41999 10.920156955718994
42999 11.230169773101807
43999 11.529150009155273
44999 11.839560985565186
45999 12.148830890655518
46999 12.47131896018982
47999 12.804113864898682
48999 13.123877763748169
49999 13.439286947250366
50999 13.758992910385132
51999 14.066948890686035
52999 14.373715877532959
53999 14.679941892623901
54999 14.977654933929443
55999 15.293908834457397
56999 15.608667850494385
57999 15.933092832565308
58999 16.254721879959106
59999 16.584234952926636
60999 16.901771068572998
61999 17.22010087966919
62999 17.537009954452515
63999 17.85765790939331
64999 18.17375373840332
65999 18.500524044036865
66999 18.81989884376526
67999 19.134373903274536
68999 19.469439029693604
69999 19.805856943130493
70999 20.13852286338806
71999 20.46326994895935
72999 20.77602481842041
73999 21.09429407119751
74999 21.416653871536255
75999 21.732131719589233
76999 22.04779601097107
77999 22.367548942565918
78999 22.691094875335693
79999 23.01662802696228
80999 23.34128475189209
81999 23.669606924057007
82999 23.9968318939209
83999 24.312042951583862
84999 24.643669843673706
85999 24.95410394668579
86999 25.283714771270752
87999 25.616045713424683
88999 25.95850396156311
89999 26.29058575630188
90999 26.58876395225525
91999 26.886172771453857
92999 27.227698802947998
93999 27.51245903968811
94999 27.81099796295166
95999 28.10950994491577
96999 28.39238667488098
97999 28.696624755859375
98999 28.99938201904297
99999 29.319031953811646
100999 29.642350673675537
101999 29.96399688720703
102999 30.289230823516846
103999 30.583061933517456
104999 30.872163772583008
105999 31.173317909240723
106999 31.46951985359192
107999 31.78562092781067
108999 32.111079931259155
109999 32.42185688018799
110999 32.72683787345886
111999 33.05582284927368
112999 33.39582180976868
113999 33.731353759765625
114999 34.0623197555542
115999 34.40396070480347
116999 34.720101833343506
117999 35.026328802108765
118999 35.338878870010376
119999 35.681294679641724
120999 36.004536867141724
121999 36.31279277801514
122999 36.633649826049805
123999 36.99255084991455
124999 37.33088994026184
125999 37.65030097961426
126999 37.98342680931091
127999 38.335911989212036
128999 38.66180992126465
129999 38.98594570159912
130999 39.308615922927856
131999 39.63413405418396
132999 39.959715843200684
133999 40.28825092315674
134999 40.618905782699585
135999 40.942111015319824
136999 41.24866986274719
137999 41.55958390235901
138999 41.890705823898315
139999 42.215702056884766
140999 42.5450177192688
141999 42.87174081802368
142999 43.20807981491089
143999 43.533539056777954
144999 43.85260486602783
145999 44.15597176551819
146999 44.47154092788696
147999 44.8039128780365
148999 45.13198494911194
149999 45.45943093299866
150999 45.78773283958435
151999 46.10836577415466
152999 46.41759371757507
153999 46.746013879776
154999 47.078964948654175
155999 47.425477743148804
156999 47.75459098815918
157999 48.06861901283264
158999 48.3816020488739
159999 48.700366735458374
160999 49.04438877105713
161999 49.40068292617798
162999 49.73587203025818
163999 50.078882932662964
164999 50.411664724349976
165999 50.74791598320007
166999 51.066969871520996
167999 51.401691913604736
168999 51.73258090019226
169999 52.09767198562622
170999 52.43431496620178
171999 52.76734495162964
172999 53.074707984924316
173999 53.39890789985657
174999 53.72532391548157
175999 54.04148292541504
176999 54.34491586685181
177999 54.665915966033936
178999 54.97995090484619
179999 55.31115794181824
180999 55.62427377700806
181999 55.93285775184631
182999 56.21428084373474
183999 56.53806781768799
184999 56.85618877410889
185999 57.152047872543335
186999 57.46162486076355
187999 57.76385307312012
188999 58.079484939575195
189999 58.36428380012512
190999 58.657768964767456
191999 58.941290855407715
192999 59.237653970718384
193999 59.53619885444641
194999 59.8513388633728
195999 60.18161201477051
196999 60.48789882659912
197999 60.82046985626221
198999 61.12140893936157
199999 61.4428186416626
200999 61.74000000953674
201999 62.04130411148071
202999 62.34490704536438
203999 62.66357183456421
204999 62.98689103126526
205999 63.31784701347351
206999 63.64183497428894
207999 63.98138070106506
208999 64.30671787261963
209999 64.6373360157013
210999 64.96731996536255
211999 65.30091285705566
212999 65.62530994415283
213999 65.95365881919861
214999 66.26345896720886
215999 66.58404564857483
216999 66.9180097579956
217999 67.25886106491089
218999 67.58692574501038
219999 67.92496490478516
220999 68.2481300830841
221999 68.56746888160706
222999 68.90592789649963
223999 69.24040699005127
224999 69.57816290855408
225999 69.91456389427185
226999 70.24477291107178
227999 70.57912874221802
228999 70.9213707447052
229999 71.24972891807556
230999 71.56614303588867
231999 71.88345193862915
232999 72.18917989730835
233999 72.49726009368896
234999 72.8015878200531
235999 73.10553288459778
236999 73.40152597427368
237999 73.70364499092102
238999 74.00825810432434
239999 74.3107430934906
240999 74.60718393325806
241999 74.9105339050293
242999 75.215824842453
243999 75.52191472053528
244999 75.82565784454346
245999 76.09424471855164
246999 76.39604091644287
247999 76.69434905052185
248999 77.00214886665344
249999 77.33538889884949
250999 77.66327786445618
251999 77.98076701164246
252999 78.29253196716309
253999 78.62788081169128
254999 78.95729780197144
255999 79.29787492752075
256999 79.65799498558044
257999 79.99190497398376
258999 80.32238388061523
259999 80.6491870880127
260999 80.96347069740295
261999 81.29154205322266
262999 81.6204149723053
263999 81.94908595085144
264999 82.26728177070618
265999 82.59150099754333
266999 82.90228772163391
267999 83.20981287956238
268999 83.5341649055481
269999 83.86387395858765
270999 84.19451189041138
271999 84.51472592353821
272999 84.83233571052551
273999 85.16991090774536
274999 85.50040698051453
275999 85.83843088150024
276999 86.16594576835632
277999 86.49797773361206
278999 86.82010698318481
279999 87.15884590148926
280999 87.49188780784607
281999 87.82014989852905
282999 88.15259599685669
283999 88.48615884780884
284999 88.821280002594
285999 89.1471939086914
286999 89.47370982170105
287999 89.80424809455872
288999 90.14757680892944
289999 90.50789594650269
290999 90.8483510017395
291999 91.16776585578918
292999 91.47050070762634
293999 91.81072187423706
294999 92.12026500701904
295999 92.45436596870422
296999 92.7706229686737
297999 93.10313606262207
298999 93.41897296905518
299999 93.71498489379883
300999 94.02990984916687
301999 94.36648297309875
302999 94.68166875839233
303999 95.00718092918396
304999 95.32233190536499
305999 95.63948011398315
306999 95.98740196228027
307999 96.31713104248047
308999 96.6441400051117
309999 96.96715998649597
310999 97.30413579940796
311999 97.62105298042297
312999 97.95374178886414
313999 98.27409100532532
314999 98.58396482467651
315999 98.90929794311523
316999 99.2467348575592
317999 99.57598185539246
318999 99.91784501075745
319999 100.25179481506348
320999 100.59132599830627
321999 100.92332792282104
322999 101.25383281707764
323999 101.58151984214783
324999 101.90875387191772
325999 102.24174904823303
326999 102.56531190872192
327999 102.89736866950989
328999 103.20953798294067
329999 103.51375007629395
330999 103.81440591812134
331999 104.1262457370758
332999 104.47620296478271
333999 104.83606386184692
334999 105.17638492584229
335999 105.49687385559082
336999 105.84120607376099
337999 106.19759678840637
338999 106.54526591300964
339999 106.87711191177368
340999 107.22946786880493
341999 107.58607578277588
342999 107.90625381469727
343999 108.21652507781982
344999 108.55544972419739
345999 108.8665668964386
346999 109.16398000717163
347999 109.47544384002686
348999 109.7788417339325
349999 110.10208106040955
350999 110.41662383079529
351999 110.74836587905884
352999 111.07108688354492
353999 111.38155698776245
354999 111.68098092079163
355999 111.97329688072205
356999 112.26734590530396
357999 112.57999992370605
358999 112.8917338848114
359999 113.1938910484314
360999 113.50932669639587
361999 113.84422993659973
362999 114.17515802383423
363999 114.50036406517029
364999 114.83912968635559
365999 115.19192385673523
366999 115.53771090507507
367999 115.88186597824097
368999 116.21188879013062
369999 116.55836391448975
370999 116.8855140209198
371999 117.23061084747314
372999 117.5610659122467
373999 117.89481687545776
374999 118.2274317741394
375999 118.57508492469788
376999 118.9330039024353
377999 119.30506086349487
378999 119.66113471984863
379999 120.01193809509277
380999 120.3508689403534
381999 120.70327496528625
382999 121.06861591339111
383999 121.42744398117065
384999 121.7957398891449
385999 122.12979197502136
386999 122.46556687355042
387999 122.79736590385437
388999 123.13271975517273
389999 123.488285779953
390999 123.82910108566284
391999 124.14991903305054
392999 124.47470784187317
393999 124.79203772544861
394999 125.12144207954407
395999 125.44453597068787
396999 125.76539278030396
397999 126.07849979400635
398999 126.40794968605042
399999 126.72657680511475
400999 127.04315185546875
401999 127.36245203018188
402999 127.67593502998352
403999 127.98846793174744
404999 128.32811498641968
405999 128.6414337158203
406999 128.9853138923645
407999 129.3351228237152
408999 129.66278195381165
409999 129.96888184547424
410999 130.29953479766846
411999 130.62742400169373
412999 130.9763309955597
413999 131.3231077194214
414999 131.6728298664093
415999 132.01331996917725
416999 132.358256816864
417999 132.69994688034058
418999 133.03967094421387
419999 133.35206294059753
420999 133.6511948108673
421999 133.9801206588745
422999 134.29874396324158
423999 134.61607193946838
424999 134.92226791381836
425999 135.2442479133606
426999 135.5600118637085
427999 135.8658049106598
428999 136.17733192443848
429999 136.47840285301208
430999 136.78699398040771
431999 137.09528183937073
432999 137.40351486206055
433999 137.70713090896606
434999 137.99616193771362
435999 138.30156588554382
436999 138.62026500701904
437999 138.93037486076355
438999 139.24512481689453
439999 139.55442190170288
440999 139.8599569797516
441999 140.17732977867126
442999 140.49508571624756
443999 140.80428075790405
444999 141.12653279304504
445999 141.41782879829407
446999 141.71775197982788
447999 142.0214228630066
448999 142.3246648311615
449999 142.63280200958252
450999 142.94557189941406
451999 143.29222989082336
452999 143.6298098564148
453999 143.96419286727905
454999 144.2962770462036
455999 144.60254883766174
456999 144.91578698158264
457999 145.24365282058716
458999 145.55241990089417
459999 145.85402393341064
460999 146.13813185691833
461999 146.4409327507019
462999 146.74937987327576
463999 147.03596687316895
464999 147.34003472328186
465999 147.63757276535034
466999 147.92753195762634
467999 148.22944688796997
468999 148.52357506752014
469999 148.8234407901764
470999 149.1174976825714
471999 149.40094780921936

In [27]:
pd.Series(smooth_ev_dict).to_csv('leave_values_20200512_smoothed.csv')


/opt/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:1: FutureWarning: The signature of `Series.to_csv` was aligned to that of `DataFrame.to_csv`, and argument 'header' will change its default value from False to True: please pass an explicit value to suppress this warning.
  """Entry point for launching an IPython kernel.

In [37]:
smoothed_ev = pd.Series(smooth_ev_dict,name='smoothed_ev')

In [47]:
summary_df = summary_df.drop('smoothed_ev', axis=1)
summary_df = pd.concat([summary_df,smoothed_ev],axis=1)

In [48]:
summary_df


Out[48]:
points equity count bingo_count mean_score mean_equity bingo pct pct adjusted_mean_score ev leave_len point_equity_diff smoothed_ev
leave
? 782820960 9.019760e+08 13841229 7322671 56.557186 65.165892 52.904775 1513.324492 17.485506 24.078203 1 -8.608707 24.078203
A 2005089326 2.117354e+09 49868572 10037371 40.207474 42.458690 20.127649 5452.357690 1.135795 1.371000 1 -2.251215 1.371000
B 461839888 4.765642e+08 12390310 1601088 37.274280 38.462657 12.922098 1354.688921 -1.797399 -2.625032 1 -1.188377 -2.625032
C 576503825 6.071711e+08 14491423 2644552 39.782416 41.898656 18.249084 1584.413158 0.710737 0.810967 1 -2.116239 0.810967
D 1012212785 1.059361e+09 25452930 4829723 39.768026 41.620414 18.975116 2782.884551 0.696347 0.532724 1 -1.852387 0.532724
... ... ... ... ... ... ... ... ... ... ... ... ... ...
??WXYY 0 0.000000e+00 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 27.054749
?WXYYZ 59 6.361000e+01 1 0 59.000000 63.610000 0.000000 0.000109 19.928321 22.522311 6 -4.610000 13.542543
??WXYZ 54 5.319400e+01 1 0 54.000000 53.194000 0.000000 0.000109 14.928321 12.106311 6 0.806000 29.007211
??WYYZ 0 0.000000e+00 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 32.317652
??XYYZ 0 0.000000e+00 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 29.680993

914624 rows × 13 columns


In [49]:
summary_df['ev_delta'] = summary_df['smoothed_ev']-summary_df['ev']

In [52]:
summary_df.sort_values('ev_delta', ascending=False)


Out[52]:
points equity count bingo_count mean_score mean_equity bingo pct pct adjusted_mean_score ev leave_len point_equity_diff smoothed_ev ev_delta
leave
??CCVV 0 40.306 1 0 0.0 40.306 0.0 0.000109 -39.071679 -0.781689 6 -40.306 56.351787 57.133476
??CCVX 44 38.329 1 0 44.0 38.329 0.0 0.000109 4.928321 -2.758689 6 5.671 43.757802 46.516492
??FSWW 36 31.358 1 0 36.0 31.358 0.0 0.000109 -3.071679 -9.729689 6 4.642 35.682576 45.412265
??DJQX 48 49.051 1 0 48.0 49.051 0.0 0.000109 8.928321 7.963311 6 -1.051 50.432336 42.469025
??DQXZ 46 55.091 1 0 46.0 55.091 0.0 0.000109 6.928321 14.003311 6 -9.091 56.397570 42.394259
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
?WWXYZ 0 0.000 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 10.266142 NaN
??WWYY 0 0.000 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 27.634908 NaN
??WXYY 0 0.000 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 27.054749 NaN
??WYYZ 0 0.000 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 32.317652 NaN
??XYYZ 0 0.000 0 0 NaN NaN NaN 0.000000 NaN NaN 6 NaN 29.680993 NaN

914624 rows × 14 columns


In [ ]: