In [1]:
import pandas as pd
from Player.Players import Players
from Regression.Reg_Model import Reg_Model

In [2]:
#Creates list of players during 2015-2016 season
Player_List = Players('2015-16').players

In [11]:
#prepare model for subset of players
p_subset_list=[]
index=0
for key in Player_List:
    p=Player_List[key]
    stats = p.get_stats('GAME_DATE', 'Game_ID', 'PTS', ['PTS', 'MIN', 'FGM', 'FGA', 'FG_PCT'], 5)
    if len(stats>0):
        stats=stats[stats['n_games']>=5]
        y=stats['PTS']
        x=stats[['PTS_avg_5', 'MIN_avg_5', 'FGM_avg_5', 'FGA_avg_5', 'FG_PCT_avg_5']]

        if len(y)>=5:
            Model = Reg_Model()
            Model.set_training(x,y)
            Model.calc_model()
            
            p.set_model('PTS', Model)
            p_subset_list.append(key)
            index += 1
    if index>50:
        break

In [12]:
#average MSE for players
import numpy as np
print np.mean([Player_List[a].model_list['PTS'].mse for a in p_subset_list])


25.1372459769

In [41]:
#Try to see how data looks like by position, season_exp

exp = [0,4,8,12]
positions = set([Player_List[x].desc['POSITION'][0] for x in Player_List])
mse_by_seg = {}
for pos in positions:
    for ex in exp:
        x =pd.DataFrame()
        y =pd.DataFrame()

        for key in Player_List:
            if Player_List[key].desc['POSITION'][0] == pos:
                if Player_List[key].desc['SEASON_EXP'][0]>=ex and Player_List[key].desc['SEASON_EXP'][0]<(ex+4):
                    stats = Player_List[key].get_stats('GAME_DATE', 'Game_ID', 'PTS', ['PTS', 'MIN', 'FGM', 'FGA', 'FG_PCT'], 5)
                    if len(stats>0):
                        stats=stats[stats['n_games']>=5]
                        y = y.append(stats[['PTS', 'PTS_avg_5']], ignore_index=True).reset_index(drop=True)
                        x = x.append(stats[['PTS_avg_5', 'MIN_avg_5', 'FGM_avg_5', 'FGA_avg_5', 'FG_PCT_avg_5']], ignore_index=True).reset_index(drop=True)
        y=y['PTS']
        Model = Reg_Model()
        Model.set_training(x,y)
        Model.calc_model()
        segment_name = pos + '-' + str(ex)
        mse_by_seg[segment_name] = Model.mse

In [42]:
mse_by_seg


Out[42]:
{'Center-0': 22.610728761159205,
 'Center-12': 25.92413444999081,
 'Center-4': 24.467674796327085,
 'Center-8': 23.067862858829894,
 'Center-Forward-0': 28.22705822061172,
 'Center-Forward-12': 23.856781022281453,
 'Center-Forward-4': 23.601499472919901,
 'Center-Forward-8': 26.803202564760195,
 'Forward-0': 21.943651024993212,
 'Forward-12': 25.033184497551531,
 'Forward-4': 26.248815010853559,
 'Forward-8': 32.156109394999504,
 'Forward-Center-0': 20.192992779688502,
 'Forward-Center-12': 17.147617829468807,
 'Forward-Center-4': 24.039159936258216,
 'Forward-Center-8': 18.086930030500124,
 'Forward-Guard-0': 21.053376665428225,
 'Forward-Guard-12': 35.742420453841113,
 'Forward-Guard-4': 38.623104452242416,
 'Forward-Guard-8': 30.304432650905145,
 'Guard-0': 26.376897816201502,
 'Guard-12': 26.656856246560299,
 'Guard-4': 38.418152612763187,
 'Guard-8': 32.076886962358309,
 'Guard-Forward-0': 21.113916436620155,
 'Guard-Forward-12': 26.417658693009415,
 'Guard-Forward-4': 37.828767128174448,
 'Guard-Forward-8': 39.811349626808955}

In [43]:
#Repeat with 10 games

exp = [0,4,8,12]
positions = set([Player_List[x].desc['POSITION'][0] for x in Player_List])
mse_by_seg = {}
for pos in positions:
    for ex in exp:
        x =pd.DataFrame()
        y =pd.DataFrame()

        for key in Player_List:
            if Player_List[key].desc['POSITION'][0] == pos:
                if Player_List[key].desc['SEASON_EXP'][0]>=ex and Player_List[key].desc['SEASON_EXP'][0]<(ex+4):
                    stats = Player_List[key].get_stats('GAME_DATE', 'Game_ID', 'PTS', ['PTS', 'MIN', 'FGM', 'FGA', 'FG_PCT'], 10)
                    if len(stats>0):
                        stats=stats[stats['n_games']>=5]
                        y = y.append(stats[['PTS', 'PTS_avg_10']], ignore_index=True).reset_index(drop=True)
                        x = x.append(stats[['PTS_avg_10', 'MIN_avg_10', 'FGM_avg_10', 'FGA_avg_10', 'FG_PCT_avg_10']], ignore_index=True).reset_index(drop=True)
        y=y['PTS']
        Model = Reg_Model()
        Model.set_training(x,y)
        Model.calc_model()
        segment_name = pos + '-' + str(ex)
        mse_by_seg[segment_name] = Model.mse

In [44]:
mse_by_seg


Out[44]:
{'Center-0': 22.894815485543415,
 'Center-12': 24.962184167276178,
 'Center-4': 23.993721154223024,
 'Center-8': 22.478342832127819,
 'Center-Forward-0': 27.624327800350159,
 'Center-Forward-12': 24.478380503289653,
 'Center-Forward-4': 23.503942895604482,
 'Center-Forward-8': 25.640627242186042,
 'Forward-0': 21.933376108956153,
 'Forward-12': 23.626238147113625,
 'Forward-4': 26.145119786480379,
 'Forward-8': 31.036927084028953,
 'Forward-Center-0': 19.641409643339919,
 'Forward-Center-12': 16.957357169032804,
 'Forward-Center-4': 22.650696005687482,
 'Forward-Center-8': 17.517433102596634,
 'Forward-Guard-0': 20.094454417342217,
 'Forward-Guard-12': 33.984787243421493,
 'Forward-Guard-4': 37.288507725551518,
 'Forward-Guard-8': 29.293965399437479,
 'Guard-0': 26.717902060845645,
 'Guard-12': 26.888961490598497,
 'Guard-4': 37.722386207848587,
 'Guard-8': 32.122756991925449,
 'Guard-Forward-0': 21.452515019666897,
 'Guard-Forward-12': 26.521176526962218,
 'Guard-Forward-4': 37.165507404428709,
 'Guard-Forward-8': 39.313326861147686}

In [50]:
#Now i want to see how i can add other variables to the model.  probably want a model that takes into account: opposing team, current team
from Schedule.Schedule import Schedule
from Schedule.Stats import Stats

In [47]:
sched_2015 = Schedule(b_dt = '10/1/2015')
sched_2015.add_four_factors()

In [51]:
# Create last n statistics
games = sched_2015.get_games()
stats = Stats(games, 'avg', 'GAME_DATE', 'Home Team', 'Away Team', 'Pts_diff', ['Game_ID'])

In [52]:
stats_10 = stats.get_lastn_stats(10)

In [53]:
print len(stats_10)

stats_10 = stats_10[stats_10['H_10_games']==10]
print len(stats_10)

stats_10 = stats_10[stats_10['A_10_games']==10]
print len(stats_10)


1230
1078
1073

In [195]:
#Create model based on team data

exp = [0,4,8,12]
positions = set([Player_List[x].desc['POSITION'][0] for x in Player_List])
mse_by_seg = {}
for pos in positions:
    for ex in exp:
        x =pd.DataFrame()
        y =pd.DataFrame()

        for key in Player_List:
            if Player_List[key].desc['POSITION'][0] == pos:
                if Player_List[key].desc['SEASON_EXP'][0]>=ex and Player_List[key].desc['SEASON_EXP'][0]<(ex+4):
                    stats = Player_List[key].get_stats('GAME_DATE', 'Game_ID', 'PTS', ['PTS', 'MIN', 'FGM', 'FGA', 'FG_PCT'], 10)
                    if len(stats>0):
                        data = Player_List[key].game_logs
                        for index, game in data.iterrows():
                            splits = game['MATCHUP'].split(' ')
                            if splits[1] == '@':
                                data.set_value(index, 'Home', 0)
                            else:
                                data.set_value(index, 'Home', 1)
                        data = data[['Game_ID', 'Home']]
                        stats = pd.merge(stats, data, on='Game_ID')
                                                
                        stats=stats[stats['n_games']>=5]
                        
                        col_list = {}
                        for col in h_games.columns.values:
                            if col[0:2]=='H_':
                                new_col = 'Y_' + col[2:]
                            elif col[0:2]=='A_':
                                new_col = 'M_' + col[2:]
                            else:
                                new_col=col
                            col_list[col]=new_col
                        h_games.rename(columns=col_list,inplace=True)
                        
                        col_list = {}
                        for col in a_games.columns.values:
                            if col[0:2]=='H_':
                                new_col = 'M_' + col[2:]
                            elif col[0:2]=='A_':
                                new_col = 'Y_' + col[2:]
                            else:
                                new_col=col
                            col_list[col]=new_col
                        a_games.rename(columns=col_list,inplace=True)
                        
                        stats_all = h_games.append(a_games, ignore_index=True).reset_index(drop=True)
                        stats_all = stats_all[stats_all['n_games']>=5]
                        y=stats_all[['PTS', 'PTS_avg_10']]
                        x=stats_all[['PTS_avg_10', 'MIN_avg_10', 'FGM_avg_10', 'FGA_avg_10', 'FG_PCT_avg_10', 'M_BTB',
                               'M_FF_EFG_10', 'M_FF_FTFGA_10', 'M_FF_ORB_10',
                               'M_FF_TOV_10', 'M_O_FF_EFG_10',
                               'M_O_FF_FTFGA_10', 'M_O_FF_ORB_10',
                               'M_O_FF_TOV_10', 'M_O_PTS_10','M_O_WL_10',
                               'M_PTS_10', 'M_WL_10', 
                               'Y_FF_EFG_10', 'Y_FF_FTFGA_10', 'Y_FF_ORB_10',
                               'Y_FF_TOV_10', 'Y_O_FF_EFG_10',
                               'Y_O_FF_FTFGA_10', 'Y_O_FF_ORB_10',
                               'Y_O_FF_TOV_10', 'Y_O_PTS_10', 'Y_O_WL_10',
                               'Y_PTS_10', 'Y_WL_10']]
                        
        y=y['PTS']
        Model = Reg_Model()
        Model.set_training(x,y)
        Model.calc_model()
        segment_name = pos + '-' + str(ex)
        mse_by_seg[segment_name] = Model.mse
        
#Gets Player stats data and adds home indicator

In [196]:
mse_by_seg


Out[196]:
{'Center-0': 35.607776070121069,
 'Center-12': 36.734098606492829,
 'Center-4': 34.353005818799886,
 'Center-8': 36.530407809205123,
 'Center-Forward-0': 35.466471616742233,
 'Center-Forward-12': 35.169697656066639,
 'Center-Forward-4': 35.925466881945688,
 'Center-Forward-8': 34.403624846409656,
 'Forward-0': 31.44473202531816,
 'Forward-12': 35.886199229820335,
 'Forward-4': 35.626281252210475,
 'Forward-8': 33.625814104219103,
 'Forward-Center-0': 33.622497158257808,
 'Forward-Center-12': 35.179658205492991,
 'Forward-Center-4': 36.191241145666559,
 'Forward-Center-8': 35.496055934455072,
 'Forward-Guard-0': 36.060665850860119,
 'Forward-Guard-12': 35.775333757580036,
 'Forward-Guard-4': 35.705490383611028,
 'Forward-Guard-8': 35.34033317636294,
 'Guard-0': 36.684563386342525,
 'Guard-12': 36.786209034247406,
 'Guard-4': 36.5919178938247,
 'Guard-8': 37.265287748435128,
 'Guard-Forward-0': 35.532370330950997,
 'Guard-Forward-12': 34.282195910134206,
 'Guard-Forward-4': 35.247674633998805,
 'Guard-Forward-8': 35.321878475346161}

In [ ]:


In [ ]:


In [118]:
stats_10.columns
#try to see what variables i have on tap


Out[118]:
Index([u'Pts_diff', u'H_WL_10', u'H_O_WL_10', u'A_WL_10', u'A_O_WL_10',
       u'H_PTS_10', u'H_O_PTS_10', u'A_PTS_10', u'A_O_PTS_10', u'H_AST_10',
       u'H_O_AST_10', u'A_AST_10', u'A_O_AST_10', u'H_STL_10', u'H_O_STL_10',
       u'A_STL_10', u'A_O_STL_10', u'H_BLK_10', u'H_O_BLK_10', u'A_BLK_10',
       u'A_O_BLK_10', u'H_FF_EFG_10', u'H_O_FF_EFG_10', u'A_FF_EFG_10',
       u'A_O_FF_EFG_10', u'H_FF_ORB_10', u'H_O_FF_ORB_10', u'A_FF_ORB_10',
       u'A_O_FF_ORB_10', u'H_FF_FTFGA_10', u'H_O_FF_FTFGA_10',
       u'A_FF_FTFGA_10', u'A_O_FF_FTFGA_10', u'H_FF_TOV_10', u'H_O_FF_TOV_10',
       u'A_FF_TOV_10', u'A_O_FF_TOV_10', u'H_BTB', u'A_BTB', u'H_10_games',
       u'A_10_games', u'Game_ID'],
      dtype='object')

In [119]:
#join player stats and game stats for 1 player
from Player.Player import Player
lebron = Player(f_name='Lebron', l_name='James')

data = lebron.game_logs
for index, game in data.iterrows():
    splits = game['MATCHUP'].split(' ')
    if splits[1] == '@':
        data.set_value(index, 'Home', 0)
    else:
        data.set_value(index, 'Home', 1)
data = data[['Game_ID', 'Home']]
        
stats = lebron.get_stats('GAME_DATE', 'Game_ID', 'PTS', ['PTS', 'MIN', 'FGM', 'FGA', 'FG_PCT'], 10)

stats_v2 = pd.merge(stats, data, on='Game_ID')
print len(stats_v2)
stats_v3 = stats_v2[stats_v2['n_games']>=10]
print len(stats_v3)


2544
76
66

In [161]:
h_games = stats_v3[stats_v3['Home']==1]
print len(h_games)
a_games = stats_v3[stats_v3['Home']==0]
print len(a_games)

h_games = pd.merge(h_games, stats_10, on='Game_ID')
print len(h_games)
a_games = pd.merge(a_games, stats_10, on='Game_ID')
print len(a_games)


33
33
33
33

In [163]:
print len(h_games.columns)
col_list = {}
for col in h_games.columns.values:
    if col[0:2]=='H_':
        new_col = 'Y_' + col[2:]
    elif col[0:2]=='A_':
        new_col = 'M_' + col[2:]
    else:
        new_col=col
    col_list[col]=new_col
h_games.rename(columns=col_list,inplace=True)
print len(h_games.columns)

print len(a_games.columns)
col_list = {}
for col in a_games.columns.values:
    if col[0:2]=='H_':
        new_col = 'M_' + col[2:]
    elif col[0:2]=='A_':
        new_col = 'Y_' + col[2:]
    else:
        new_col=col
    col_list[col]=new_col
a_games.rename(columns=col_list,inplace=True)
print len(a_games.columns)


50
50
50
50

In [164]:
stats_all = h_games.append(a_games, ignore_index=True).reset_index(drop=True)
print len(stats_all)
print len(a_games.columns)
print len(a_games.columns)
print len(stats_all.columns)


66
50
50
50

In [148]:
stats_all.columns


Out[148]:
Index([u'FGA_avg_10', u'FGM_avg_10', u'FG_PCT_avg_10', u'Game_ID', u'Home',
       u'MIN_avg_10', u'M_10_games', u'M_AST_10', u'M_BLK_10', u'M_BTB',
       u'M_FF_EFG_10', u'M_FF_FTFGA_10', u'M_FF_ORB_10', u'M_FF_TOV_10',
       u'M_O_AST_10', u'M_O_BLK_10', u'M_O_FF_EFG_10', u'M_O_FF_FTFGA_10',
       u'M_O_FF_ORB_10', u'M_O_FF_TOV_10', u'M_O_PTS_10', u'M_O_STL_10',
       u'M_O_WL_10', u'M_PTS_10', u'M_STL_10', u'M_WL_10', u'PTS',
       u'PTS_avg_10', u'Pts_diff', u'Y_10_games', u'Y_AST_10', u'Y_BLK_10',
       u'Y_BTB', u'Y_FF_EFG_10', u'Y_FF_FTFGA_10', u'Y_FF_ORB_10',
       u'Y_FF_TOV_10', u'Y_O_AST_10', u'Y_O_BLK_10', u'Y_O_FF_EFG_10',
       u'Y_O_FF_FTFGA_10', u'Y_O_FF_ORB_10', u'Y_O_FF_TOV_10', u'Y_O_PTS_10',
       u'Y_O_STL_10', u'Y_O_WL_10', u'Y_PTS_10', u'Y_STL_10', u'Y_WL_10',
       u'n_games'],
      dtype='object')

In [170]:
stats_all = stats_all[stats_all['n_games']>4]
y=stats_all['PTS']
x=stats_all[['PTS_avg_10', 'MIN_avg_10', 'FGM_avg_10', 'FGA_avg_10', 'FG_PCT_avg_10', 'M_BTB']]

In [185]:
stats_all = stats_all[stats_all['n_games']>4]
y=stats_all['PTS']
x=stats_all[['PTS_avg_10', 'MIN_avg_10', 'FGM_avg_10', 'FGA_avg_10', 'FG_PCT_avg_10', 'M_BTB',
       'M_FF_EFG_10', 'M_FF_FTFGA_10', 'M_FF_ORB_10',
       'M_FF_TOV_10', 'M_O_FF_EFG_10',
       'M_O_FF_FTFGA_10', 'M_O_FF_ORB_10',
       'M_O_FF_TOV_10', 'M_O_PTS_10','M_O_WL_10',
       'M_PTS_10', 'M_WL_10', 
       'Y_FF_EFG_10', 'Y_FF_FTFGA_10', 'Y_FF_ORB_10',
       'Y_FF_TOV_10', 'Y_O_FF_EFG_10',
       'Y_O_FF_FTFGA_10', 'Y_O_FF_ORB_10',
       'Y_O_FF_TOV_10', 'Y_O_PTS_10', 'Y_O_WL_10',
       'Y_PTS_10', 'Y_WL_10']]

In [186]:
for index, row in x.iterrows():
    for col in x.columns.values:
         print type(x.ix[index, col]), col
    break


<type 'numpy.float64'> PTS_avg_10
<type 'numpy.float64'> MIN_avg_10
<type 'numpy.float64'> FGM_avg_10
<type 'numpy.float64'> FGA_avg_10
<type 'numpy.float64'> FG_PCT_avg_10
<type 'numpy.float64'> M_BTB
<type 'numpy.float64'> M_FF_EFG_10
<type 'numpy.float64'> M_FF_FTFGA_10
<type 'numpy.float64'> M_FF_ORB_10
<type 'numpy.float64'> M_FF_TOV_10
<type 'numpy.float64'> M_O_FF_EFG_10
<type 'numpy.float64'> M_O_FF_FTFGA_10
<type 'numpy.float64'> M_O_FF_ORB_10
<type 'numpy.float64'> M_O_FF_TOV_10
<type 'numpy.float64'> M_O_PTS_10
<type 'numpy.float64'> M_O_WL_10
<type 'numpy.float64'> M_PTS_10
<type 'numpy.float64'> M_WL_10
<type 'numpy.float64'> Y_FF_EFG_10
<type 'numpy.float64'> Y_FF_FTFGA_10
<type 'numpy.float64'> Y_FF_ORB_10
<type 'numpy.float64'> Y_FF_TOV_10
<type 'numpy.float64'> Y_O_FF_EFG_10
<type 'numpy.float64'> Y_O_FF_FTFGA_10
<type 'numpy.float64'> Y_O_FF_ORB_10
<type 'numpy.float64'> Y_O_FF_TOV_10
<type 'numpy.float64'> Y_O_PTS_10
<type 'numpy.float64'> Y_O_WL_10
<type 'numpy.float64'> Y_PTS_10
<type 'numpy.float64'> Y_WL_10

In [167]:
x


Out[167]:
PTS_avg_10 MIN_avg_10 FGM_avg_10 FGA_avg_10 FG_PCT_avg_10 M_BTB M_FF_EFG_10 M_FF_FTFGA_10 M_FF_ORB_10 M_FF_TOV_10 ... Y_FF_TOV_10 Y_O_FF_EFG_10 Y_O_FF_FTFGA_10 Y_O_FF_FTFGA_10 Y_O_FF_ORB_10 Y_O_FF_TOV_10 Y_O_PTS_10 Y_O_WL_10 Y_PTS_10 Y_WL_10
0 27.5 36.6 10.4 20.7 0.4992 0 0.499567 0.216664 0.222306 0.157226 ... 0.148223 0.470509 0.203110 0.203110 0.222303 0.136481 96.3 0.2 103.2 0.8
1 29.0 37.0 10.9 20.7 0.5376 0 0.529546 0.191625 0.197374 0.152234 ... 0.148204 0.488033 0.212365 0.212365 0.218215 0.132230 98.7 0.2 104.1 0.8
2 28.0 36.9 10.4 20.3 0.5225 0 0.479129 0.177602 0.239701 0.144632 ... 0.150807 0.484885 0.211972 0.211972 0.226658 0.130724 99.2 0.2 104.8 0.8
3 26.8 37.8 9.5 18.9 0.5090 0 0.474859 0.173879 0.263528 0.141281 ... 0.144950 0.491311 0.220018 0.220018 0.223203 0.120231 100.0 0.3 104.8 0.7
4 26.5 37.9 9.5 18.8 0.5110 0 0.477212 0.227320 0.207927 0.159148 ... 0.152920 0.487855 0.227795 0.227795 0.216491 0.128803 99.1 0.3 103.7 0.7
5 26.4 38.4 9.3 19.7 0.4808 1 0.492952 0.207718 0.270791 0.152829 ... 0.150907 0.510943 0.226956 0.226956 0.174840 0.128924 99.5 0.5 100.1 0.5
6 25.2 36.9 9.4 19.5 0.4861 1 0.511610 0.257289 0.272205 0.155198 ... 0.146851 0.504212 0.187476 0.187476 0.178954 0.141573 94.7 0.4 98.3 0.6
7 26.6 37.6 9.8 20.7 0.4772 0 0.484252 0.181076 0.206482 0.165533 ... 0.153133 0.500008 0.203859 0.203859 0.183240 0.144048 94.4 0.4 97.0 0.6
8 27.4 36.6 10.1 21.0 0.4860 0 0.506599 0.233844 0.215693 0.140396 ... 0.152206 0.480203 0.213088 0.213088 0.199855 0.152822 92.7 0.3 97.9 0.7
9 24.7 34.2 9.6 19.8 0.4826 1 0.553993 0.153726 0.220251 0.138155 ... 0.139893 0.461490 0.187855 0.187855 0.245744 0.155057 90.1 0.2 96.1 0.8
10 24.3 33.1 9.3 19.2 0.4854 1 0.481696 0.225793 0.258966 0.119578 ... 0.135372 0.446000 0.196200 0.196200 0.227202 0.151054 88.0 0.2 96.0 0.8
11 24.9 35.3 9.2 16.7 0.5391 0 0.562627 0.178130 0.210621 0.136214 ... 0.125190 0.501951 0.203365 0.203365 0.206812 0.153338 94.5 0.1 105.7 0.9
12 23.4 34.6 8.9 16.1 0.5470 0 0.550081 0.213965 0.208560 0.117590 ... 0.123726 0.514379 0.206122 0.206122 0.183531 0.138839 97.1 0.2 105.2 0.8
13 22.7 35.2 8.7 16.0 0.5388 1 0.475464 0.226111 0.286582 0.153885 ... 0.133384 0.521024 0.216385 0.216385 0.192174 0.132995 99.4 0.2 106.3 0.8
14 23.3 36.1 9.1 17.6 0.5159 0 0.489019 0.279045 0.261555 0.158768 ... 0.122879 0.513931 0.203931 0.203931 0.199441 0.130612 99.0 0.3 102.4 0.7
15 22.4 35.9 9.0 16.9 0.5347 1 0.462186 0.194991 0.228034 0.155730 ... 0.127162 0.500647 0.206562 0.206562 0.206065 0.128368 98.2 0.3 101.7 0.7
16 21.5 35.7 8.4 15.9 0.5561 0 0.536069 0.208809 0.234657 0.121977 ... 0.127083 0.505940 0.219319 0.219319 0.223344 0.129886 99.7 0.3 102.6 0.7
17 22.3 35.9 8.8 17.1 0.5476 0 0.506685 0.177643 0.237134 0.114975 ... 0.117767 0.516311 0.206092 0.206092 0.238405 0.119710 102.9 0.3 105.5 0.7
18 23.7 36.4 9.0 17.8 0.5429 0 0.516987 0.174166 0.258591 0.117192 ... 0.115784 0.498176 0.205249 0.205249 0.246340 0.126183 100.1 0.3 106.0 0.7
19 24.7 37.2 9.4 18.6 0.5396 1 0.498113 0.232298 0.240407 0.147785 ... 0.114397 0.496082 0.213131 0.213131 0.252590 0.121911 100.7 0.3 106.8 0.7
20 24.6 36.8 9.3 18.5 0.5367 0 0.467716 0.260476 0.212279 0.137020 ... 0.113767 0.496722 0.206302 0.206302 0.249404 0.129001 100.5 0.3 107.3 0.7
21 24.9 36.5 9.4 18.0 0.5505 0 0.478688 0.144253 0.226084 0.117666 ... 0.115725 0.500765 0.216941 0.216941 0.245515 0.132248 102.0 0.2 111.0 0.8
22 25.3 36.8 9.8 19.8 0.4976 1 0.500017 0.179978 0.207758 0.127054 ... 0.110027 0.484693 0.193221 0.193221 0.249019 0.121179 100.7 0.2 110.2 0.8
23 24.5 36.9 9.6 20.0 0.4816 0 0.506787 0.212613 0.203558 0.148240 ... 0.120057 0.484157 0.188102 0.188102 0.244088 0.125257 99.7 0.3 107.6 0.7
24 24.0 36.1 9.4 19.2 0.4934 1 0.481874 0.190510 0.233001 0.137453 ... 0.126511 0.495859 0.212590 0.212590 0.210023 0.128140 99.7 0.4 106.1 0.6
25 25.0 35.9 9.8 19.3 0.5094 0 0.497701 0.187773 0.198312 0.119435 ... 0.124162 0.499950 0.206226 0.206226 0.206942 0.125992 98.9 0.3 105.8 0.7
26 23.9 35.1 9.6 18.8 0.5092 1 0.490998 0.239479 0.253810 0.108359 ... 0.120721 0.499354 0.213335 0.213335 0.202350 0.133407 98.8 0.3 106.7 0.7
27 24.0 35.0 9.6 18.8 0.5092 1 0.507392 0.281610 0.229411 0.120867 ... 0.122777 0.502464 0.213915 0.213915 0.209833 0.131625 99.1 0.3 106.7 0.7
28 25.1 34.4 9.8 18.6 0.5225 0 0.523461 0.214265 0.270302 0.127802 ... 0.138722 0.523263 0.216308 0.216308 0.191493 0.127752 101.8 0.3 107.9 0.7
29 25.1 34.0 9.6 18.3 0.5221 0 0.513850 0.203850 0.225548 0.129182 ... 0.141852 0.526350 0.220012 0.220012 0.193307 0.127679 102.6 0.3 109.5 0.7
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
36 25.8 37.8 9.2 18.9 0.4931 0 0.490895 0.242097 0.192924 0.135134 ... 0.154381 0.484181 0.212985 0.212985 0.186484 0.124358 97.4 0.4 100.4 0.6
37 26.0 37.9 9.4 19.4 0.4910 0 0.499352 0.159478 0.250560 0.139627 ... 0.145788 0.521514 0.208587 0.208587 0.181335 0.135017 99.1 0.4 100.7 0.6
38 25.5 36.8 9.3 18.8 0.5053 0 0.488435 0.179974 0.220357 0.132517 ... 0.145893 0.510460 0.199264 0.199264 0.178954 0.142974 96.7 0.4 100.3 0.6
39 27.4 36.4 10.4 21.6 0.4894 0 0.553977 0.208272 0.275703 0.150120 ... 0.143586 0.477901 0.207630 0.207630 0.205230 0.153326 92.1 0.3 97.5 0.7
40 27.4 36.5 10.6 22.2 0.4879 0 0.492349 0.185336 0.289930 0.161253 ... 0.135863 0.478922 0.211049 0.211049 0.204843 0.153602 92.2 0.4 96.8 0.6
41 26.0 35.5 10.0 21.3 0.4732 0 0.494249 0.209113 0.231249 0.159812 ... 0.136621 0.478841 0.212322 0.212322 0.222971 0.149996 93.0 0.4 95.9 0.6
42 25.0 35.3 9.6 20.3 0.4732 0 0.511178 0.181182 0.287908 0.139437 ... 0.141937 0.476667 0.205337 0.205337 0.230927 0.153199 91.3 0.3 95.2 0.7
43 23.8 33.3 9.0 18.8 0.4823 0 0.491327 0.172689 0.207030 0.124872 ... 0.130860 0.457739 0.204153 0.204153 0.234538 0.141172 90.4 0.2 97.1 0.8
44 24.8 33.7 9.2 19.0 0.4868 0 0.468566 0.226556 0.203601 0.148289 ... 0.125971 0.484857 0.212728 0.212728 0.225350 0.142850 94.2 0.2 100.3 0.8
45 22.8 32.9 8.5 17.5 0.4841 1 0.501838 0.188712 0.258114 0.178430 ... 0.120507 0.483505 0.205612 0.205612 0.217136 0.141988 94.1 0.2 102.4 0.8
46 24.2 34.1 9.0 18.0 0.4935 0 0.519734 0.182389 0.236291 0.129562 ... 0.120624 0.495065 0.192882 0.192882 0.200691 0.142913 94.0 0.2 101.1 0.8
47 24.5 34.5 9.0 17.5 0.5055 0 0.550143 0.192924 0.251578 0.134328 ... 0.121949 0.509321 0.197374 0.197374 0.199205 0.147210 96.3 0.2 103.0 0.8
48 24.2 34.3 8.9 16.6 0.5199 0 0.547388 0.268603 0.237310 0.166178 ... 0.128874 0.513886 0.193419 0.193419 0.206259 0.142732 97.3 0.2 104.2 0.8
49 25.1 35.1 9.5 17.3 0.5429 0 0.476096 0.175126 0.215186 0.157267 ... 0.121878 0.514714 0.210349 0.210349 0.190313 0.143612 98.0 0.2 105.4 0.8
50 23.2 35.8 9.2 16.5 0.5805 0 0.508327 0.192894 0.293065 0.126152 ... 0.129834 0.503505 0.208389 0.208389 0.219334 0.139971 97.6 0.3 100.7 0.7
51 21.7 34.9 8.5 15.9 0.5620 0 0.500400 0.236975 0.237301 0.141298 ... 0.127686 0.502697 0.217522 0.217522 0.223412 0.120305 99.3 0.3 103.3 0.7
52 21.9 35.6 8.5 16.4 0.5500 0 0.470834 0.227380 0.201342 0.121235 ... 0.125128 0.500436 0.207717 0.207717 0.231659 0.123508 100.0 0.2 104.9 0.8
53 24.9 36.2 9.4 18.4 0.5351 0 0.531662 0.229817 0.316480 0.144740 ... 0.111102 0.493661 0.205919 0.205919 0.251788 0.134757 100.8 0.2 110.2 0.8
54 23.9 36.5 9.4 19.6 0.4843 0 0.517653 0.289349 0.239187 0.115065 ... 0.119510 0.486334 0.192114 0.192114 0.243180 0.133370 99.7 0.3 107.3 0.7
55 24.7 35.7 9.9 19.1 0.5171 0 0.520403 0.209262 0.249088 0.163916 ... 0.140320 0.501883 0.209263 0.209263 0.204833 0.135969 98.6 0.4 105.0 0.6
56 24.3 35.7 9.5 18.8 0.5047 0 0.500086 0.268688 0.254992 0.112913 ... 0.142634 0.510177 0.222666 0.222666 0.190242 0.131874 100.2 0.4 106.4 0.6
57 24.2 35.7 9.3 18.7 0.4968 0 0.526488 0.185804 0.192554 0.123057 ... 0.138050 0.523164 0.229471 0.229471 0.174363 0.131776 101.8 0.4 106.9 0.6
58 24.4 35.1 9.1 18.0 0.5068 1 0.480995 0.226236 0.250478 0.157824 ... 0.129188 0.518749 0.232225 0.232225 0.170840 0.129095 101.2 0.3 109.5 0.7
59 25.5 35.1 9.6 18.2 0.5290 0 0.497613 0.207681 0.195665 0.129238 ... 0.129503 0.517704 0.219618 0.219618 0.171316 0.127516 100.2 0.3 106.8 0.7
60 25.0 35.7 9.4 18.4 0.5075 0 0.548096 0.241649 0.251403 0.137479 ... 0.135081 0.513204 0.211189 0.211189 0.177882 0.128227 99.2 0.2 107.8 0.8
61 25.8 34.7 9.8 18.7 0.5241 0 0.532848 0.202947 0.225973 0.132072 ... 0.139733 0.531975 0.210012 0.210012 0.198069 0.128530 102.7 0.3 108.8 0.7
62 26.0 34.6 10.0 18.3 0.5504 0 0.506343 0.193964 0.223461 0.135502 ... 0.130458 0.531374 0.204812 0.204812 0.200797 0.122287 102.5 0.3 108.0 0.7
63 25.8 33.8 9.9 17.7 0.5707 0 0.537897 0.182900 0.185007 0.127174 ... 0.137958 0.515277 0.200390 0.200390 0.243610 0.131315 100.2 0.4 104.0 0.6
64 26.7 35.7 10.7 19.2 0.5705 0 0.515139 0.192341 0.232533 0.137465 ... 0.141561 0.501659 0.220391 0.220391 0.245818 0.135026 102.1 0.3 107.8 0.7
65 26.1 34.8 10.4 18.1 0.5983 0 0.489478 0.184269 0.219702 0.124917 ... 0.135055 0.496816 0.203889 0.203889 0.237000 0.135240 99.9 0.3 108.6 0.7

66 rows × 33 columns


In [187]:
Model = Reg_Model()
Model.set_training(x,y)
Model.calc_model()

In [188]:
Model.mse


Out[188]:
34.265750089800278

In [189]:
Model.model_type


Out[189]:
'gbm'

In [ ]: