License


Copyright 2017 J. Patrick Hall, jphall@gwu.edu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Monotonic Gradient Boosting using XGBoost


http://xgboost.readthedocs.io/en/latest//tutorials/monotonic.html

Monotonicity is an important facet of intepretability. Monotonicity constraints ensure that the modeled relationship between inputs and the target move in only direction, i.e. as an input increases the target can only increase or as input increases the target can only decrease. Such monotonic relationships are usually easier to explain and understand than non-monotonic relationships.

Preliminaries: imports, start h2o, load and clean data


In [1]:
# imports
import h2o
from h2o.estimators.xgboost import H2OXGBoostEstimator
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import pandas as pd
import xgboost as xgb

In [2]:
# start h2o
h2o.init()
h2o.remove_all()


Checking whether there is an H2O instance running at http://localhost:54321..... not found.
Attempting to start a local H2O server...
; Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
  Starting server from C:\Anaconda3\lib\site-packages\h2o\backend\bin\h2o.jar
  Ice root: C:\Users\p\AppData\Local\Temp\tmp92vc54ht
  JVM stdout: C:\Users\p\AppData\Local\Temp\tmp92vc54ht\h2o_p_started_from_python.out
  JVM stderr: C:\Users\p\AppData\Local\Temp\tmp92vc54ht\h2o_p_started_from_python.err
  Server is running at http://127.0.0.1:54321
Connecting to H2O server at http://127.0.0.1:54321... successful.
H2O cluster uptime: 01 secs
H2O cluster version: 3.10.5.4
H2O cluster version age: 6 days
H2O cluster name: H2O_from_python_p_q2okdx
H2O cluster total nodes: 1
H2O cluster free memory: 3.538 Gb
H2O cluster total cores: 8
H2O cluster allowed cores: 8
H2O cluster status: accepting new members, healthy
H2O connection url: http://127.0.0.1:54321
H2O connection proxy: None
H2O internal security: False
Python version: 3.5.2 final

Load and prepare data for modeling


In [3]:
# load clean data
path = '../../03_regression/data/train.csv'
frame = h2o.import_file(path=path)


Parse progress: |█████████████████████████████████████████████████████████| 100%

In [4]:
# assign target and inputs
y = 'SalePrice'
X = [name for name in frame.columns if name not in [y, 'Id']]

Monotonic constraints are easier to understand for numeric inputs without missing values


In [5]:
# determine column types
# impute
reals, enums = [], []
for key, val in frame.types.items():
    if key in X:
        if val == 'enum':
            enums.append(key)
        else: 
            reals.append(key)
            
_ = frame[reals].impute(method='median')

In [6]:
# split into training and validation
train, valid = frame.split_frame([0.7], seed=12345)

In [7]:
# for convenience create a tuple for xgboost monotone_constraints parameter
mono_constraints = tuple(int(i) for i in np.ones(shape=(int(1), len(reals))).tolist()[0])

Train a monotonic predictive model

  • In this XGBoost GBM all the modeled relationships between the inputs and the target are forced to be monotonically increasing.

Log transform for better regression results and easy RMSLE in XGBoost


In [8]:
# Check log transform - looks good
%matplotlib inline
train['SalePrice'].log().as_data_frame().hist()

# Execute log transform
train['SalePrice'] = train['SalePrice'].log()
valid['SalePrice'] = valid['SalePrice'].log()
print(train[0:3, 'SalePrice'])


SalePrice
12.2477
12.109
12.3172

Train XGBoost with monotonicity Constraints


In [9]:
ave_y = train['SalePrice'].mean()[0]

# XGBoost uses SVMLight data structure, not Numpy arrays or Pandas data frames 
dtrain = xgb.DMatrix(train.as_data_frame()[reals],
                      train.as_data_frame()['SalePrice'])
dvalid = xgb.DMatrix(valid.as_data_frame()[reals],
                      valid.as_data_frame()['SalePrice'])

# tuning parameters
params = {
    'objective': 'reg:linear',
    'booster': 'gbtree', 
    'eval_metric': 'rmse',
    'eta': 0.005,
    'subsample': 0.1, 
    'colsample_bytree': 0.8,
    'max_depth': 5,
    'reg_alpha' : 0.01,
    'reg_lambda' : 0.0,
    'monotone_constraints':mono_constraints,
    'base_score': ave_y,
    'silent': 0,
    'seed': 12345,
}

# watchlist is used for early stopping
watchlist = [(dtrain, 'train'), (dvalid, 'eval')]

# train model
xgb_model1 = xgb.train(params, 
                       dtrain, 
                       1000,
                       evals=watchlist, 
                       early_stopping_rounds=50, 
                       verbose_eval=True)


[0]	train-rmse:0.3924	eval-rmse:0.410023
Multiple eval metrics have been passed: 'eval-rmse' will be used for early stopping.

Will train until eval-rmse hasn't improved in 50 rounds.
[1]	train-rmse:0.390954	eval-rmse:0.408467
[2]	train-rmse:0.389618	eval-rmse:0.407106
[3]	train-rmse:0.388497	eval-rmse:0.405756
[4]	train-rmse:0.387136	eval-rmse:0.404236
[5]	train-rmse:0.385714	eval-rmse:0.402831
[6]	train-rmse:0.384449	eval-rmse:0.401643
[7]	train-rmse:0.382743	eval-rmse:0.399816
[8]	train-rmse:0.381471	eval-rmse:0.398484
[9]	train-rmse:0.380089	eval-rmse:0.397062
[10]	train-rmse:0.378992	eval-rmse:0.395882
[11]	train-rmse:0.377797	eval-rmse:0.394543
[12]	train-rmse:0.376604	eval-rmse:0.39328
[13]	train-rmse:0.37533	eval-rmse:0.391908
[14]	train-rmse:0.373751	eval-rmse:0.390438
[15]	train-rmse:0.37246	eval-rmse:0.389129
[16]	train-rmse:0.371113	eval-rmse:0.38778
[17]	train-rmse:0.369844	eval-rmse:0.386449
[18]	train-rmse:0.368511	eval-rmse:0.385084
[19]	train-rmse:0.36718	eval-rmse:0.383684
[20]	train-rmse:0.365808	eval-rmse:0.382153
[21]	train-rmse:0.364398	eval-rmse:0.380706
[22]	train-rmse:0.363094	eval-rmse:0.379213
[23]	train-rmse:0.361733	eval-rmse:0.377871
[24]	train-rmse:0.360402	eval-rmse:0.376537
[25]	train-rmse:0.359047	eval-rmse:0.37518
[26]	train-rmse:0.357816	eval-rmse:0.373909
[27]	train-rmse:0.356583	eval-rmse:0.372763
[28]	train-rmse:0.355392	eval-rmse:0.371539
[29]	train-rmse:0.354017	eval-rmse:0.370001
[30]	train-rmse:0.352962	eval-rmse:0.368869
[31]	train-rmse:0.351735	eval-rmse:0.367572
[32]	train-rmse:0.350414	eval-rmse:0.366278
[33]	train-rmse:0.34909	eval-rmse:0.364852
[34]	train-rmse:0.348044	eval-rmse:0.363857
[35]	train-rmse:0.346958	eval-rmse:0.362709
[36]	train-rmse:0.345771	eval-rmse:0.361432
[37]	train-rmse:0.344657	eval-rmse:0.360253
[38]	train-rmse:0.343384	eval-rmse:0.358927
[39]	train-rmse:0.342106	eval-rmse:0.357613
[40]	train-rmse:0.340843	eval-rmse:0.356215
[41]	train-rmse:0.339678	eval-rmse:0.354896
[42]	train-rmse:0.338493	eval-rmse:0.353594
[43]	train-rmse:0.337334	eval-rmse:0.352363
[44]	train-rmse:0.336152	eval-rmse:0.35105
[45]	train-rmse:0.334906	eval-rmse:0.34972
[46]	train-rmse:0.333908	eval-rmse:0.348785
[47]	train-rmse:0.332783	eval-rmse:0.347465
[48]	train-rmse:0.331776	eval-rmse:0.346471
[49]	train-rmse:0.330468	eval-rmse:0.345205
[50]	train-rmse:0.329272	eval-rmse:0.343932
[51]	train-rmse:0.328072	eval-rmse:0.342741
[52]	train-rmse:0.326961	eval-rmse:0.341641
[53]	train-rmse:0.325797	eval-rmse:0.340275
[54]	train-rmse:0.324647	eval-rmse:0.339084
[55]	train-rmse:0.323357	eval-rmse:0.337551
[56]	train-rmse:0.32236	eval-rmse:0.336513
[57]	train-rmse:0.321196	eval-rmse:0.335334
[58]	train-rmse:0.320245	eval-rmse:0.33428
[59]	train-rmse:0.319255	eval-rmse:0.333335
[60]	train-rmse:0.318107	eval-rmse:0.331977
[61]	train-rmse:0.316973	eval-rmse:0.330865
[62]	train-rmse:0.315922	eval-rmse:0.329654
[63]	train-rmse:0.314727	eval-rmse:0.328422
[64]	train-rmse:0.313633	eval-rmse:0.327252
[65]	train-rmse:0.312645	eval-rmse:0.326283
[66]	train-rmse:0.311411	eval-rmse:0.324992
[67]	train-rmse:0.310406	eval-rmse:0.323971
[68]	train-rmse:0.309295	eval-rmse:0.322864
[69]	train-rmse:0.3084	eval-rmse:0.321954
[70]	train-rmse:0.307538	eval-rmse:0.321043
[71]	train-rmse:0.306586	eval-rmse:0.319932
[72]	train-rmse:0.305433	eval-rmse:0.318684
[73]	train-rmse:0.304577	eval-rmse:0.317955
[74]	train-rmse:0.303391	eval-rmse:0.316781
[75]	train-rmse:0.302433	eval-rmse:0.315815
[76]	train-rmse:0.301417	eval-rmse:0.314746
[77]	train-rmse:0.300425	eval-rmse:0.313772
[78]	train-rmse:0.299632	eval-rmse:0.312921
[79]	train-rmse:0.298593	eval-rmse:0.311855
[80]	train-rmse:0.297476	eval-rmse:0.310512
[81]	train-rmse:0.296454	eval-rmse:0.309488
[82]	train-rmse:0.295476	eval-rmse:0.308448
[83]	train-rmse:0.294545	eval-rmse:0.307467
[84]	train-rmse:0.293698	eval-rmse:0.306618
[85]	train-rmse:0.292919	eval-rmse:0.3058
[86]	train-rmse:0.291839	eval-rmse:0.304714
[87]	train-rmse:0.29112	eval-rmse:0.30394
[88]	train-rmse:0.290434	eval-rmse:0.303167
[89]	train-rmse:0.289413	eval-rmse:0.301853
[90]	train-rmse:0.288591	eval-rmse:0.300972
[91]	train-rmse:0.287797	eval-rmse:0.3003
[92]	train-rmse:0.287085	eval-rmse:0.299615
[93]	train-rmse:0.286334	eval-rmse:0.298834
[94]	train-rmse:0.285387	eval-rmse:0.297891
[95]	train-rmse:0.284492	eval-rmse:0.296876
[96]	train-rmse:0.283575	eval-rmse:0.29586
[97]	train-rmse:0.282698	eval-rmse:0.295007
[98]	train-rmse:0.281767	eval-rmse:0.293973
[99]	train-rmse:0.280898	eval-rmse:0.293025
[100]	train-rmse:0.279944	eval-rmse:0.291954
[101]	train-rmse:0.278922	eval-rmse:0.290909
[102]	train-rmse:0.277925	eval-rmse:0.289707
[103]	train-rmse:0.277078	eval-rmse:0.288749
[104]	train-rmse:0.276306	eval-rmse:0.287823
[105]	train-rmse:0.275496	eval-rmse:0.287069
[106]	train-rmse:0.274698	eval-rmse:0.286221
[107]	train-rmse:0.273866	eval-rmse:0.285274
[108]	train-rmse:0.273091	eval-rmse:0.284503
[109]	train-rmse:0.272268	eval-rmse:0.283633
[110]	train-rmse:0.27163	eval-rmse:0.282928
[111]	train-rmse:0.270892	eval-rmse:0.282141
[112]	train-rmse:0.270112	eval-rmse:0.281381
[113]	train-rmse:0.269582	eval-rmse:0.280827
[114]	train-rmse:0.268758	eval-rmse:0.280047
[115]	train-rmse:0.267932	eval-rmse:0.279143
[116]	train-rmse:0.267085	eval-rmse:0.278244
[117]	train-rmse:0.266338	eval-rmse:0.277479
[118]	train-rmse:0.265643	eval-rmse:0.276677
[119]	train-rmse:0.264955	eval-rmse:0.275966
[120]	train-rmse:0.26422	eval-rmse:0.275228
[121]	train-rmse:0.263567	eval-rmse:0.274551
[122]	train-rmse:0.26288	eval-rmse:0.273894
[123]	train-rmse:0.262087	eval-rmse:0.273105
[124]	train-rmse:0.261296	eval-rmse:0.272233
[125]	train-rmse:0.260619	eval-rmse:0.271463
[126]	train-rmse:0.259946	eval-rmse:0.270694
[127]	train-rmse:0.259205	eval-rmse:0.269923
[128]	train-rmse:0.258388	eval-rmse:0.269018
[129]	train-rmse:0.257643	eval-rmse:0.268309
[130]	train-rmse:0.256697	eval-rmse:0.267332
[131]	train-rmse:0.255963	eval-rmse:0.26669
[132]	train-rmse:0.255326	eval-rmse:0.265973
[133]	train-rmse:0.254567	eval-rmse:0.265155
[134]	train-rmse:0.253865	eval-rmse:0.264362
[135]	train-rmse:0.25307	eval-rmse:0.263556
[136]	train-rmse:0.252377	eval-rmse:0.262872
[137]	train-rmse:0.251536	eval-rmse:0.26203
[138]	train-rmse:0.250944	eval-rmse:0.261465
[139]	train-rmse:0.250208	eval-rmse:0.260754
[140]	train-rmse:0.249587	eval-rmse:0.260099
[141]	train-rmse:0.248974	eval-rmse:0.259413
[142]	train-rmse:0.248352	eval-rmse:0.258791
[143]	train-rmse:0.247759	eval-rmse:0.258198
[144]	train-rmse:0.247017	eval-rmse:0.257496
[145]	train-rmse:0.246287	eval-rmse:0.256718
[146]	train-rmse:0.245688	eval-rmse:0.256152
[147]	train-rmse:0.244938	eval-rmse:0.255274
[148]	train-rmse:0.244268	eval-rmse:0.254508
[149]	train-rmse:0.243695	eval-rmse:0.253796
[150]	train-rmse:0.243007	eval-rmse:0.252967
[151]	train-rmse:0.242488	eval-rmse:0.252324
[152]	train-rmse:0.241913	eval-rmse:0.251672
[153]	train-rmse:0.241123	eval-rmse:0.250736
[154]	train-rmse:0.240559	eval-rmse:0.250131
[155]	train-rmse:0.239988	eval-rmse:0.249553
[156]	train-rmse:0.239331	eval-rmse:0.248683
[157]	train-rmse:0.23872	eval-rmse:0.247863
[158]	train-rmse:0.237997	eval-rmse:0.247032
[159]	train-rmse:0.237253	eval-rmse:0.246289
[160]	train-rmse:0.236633	eval-rmse:0.245547
[161]	train-rmse:0.236091	eval-rmse:0.244908
[162]	train-rmse:0.235566	eval-rmse:0.244327
[163]	train-rmse:0.23486	eval-rmse:0.243538
[164]	train-rmse:0.234117	eval-rmse:0.242741
[165]	train-rmse:0.233493	eval-rmse:0.242019
[166]	train-rmse:0.232785	eval-rmse:0.241236
[167]	train-rmse:0.232113	eval-rmse:0.240538
[168]	train-rmse:0.231448	eval-rmse:0.239996
[169]	train-rmse:0.230898	eval-rmse:0.239428
[170]	train-rmse:0.230326	eval-rmse:0.238819
[171]	train-rmse:0.229715	eval-rmse:0.238149
[172]	train-rmse:0.229058	eval-rmse:0.237391
[173]	train-rmse:0.228336	eval-rmse:0.236686
[174]	train-rmse:0.227743	eval-rmse:0.236005
[175]	train-rmse:0.227188	eval-rmse:0.235316
[176]	train-rmse:0.226576	eval-rmse:0.234718
[177]	train-rmse:0.225921	eval-rmse:0.233964
[178]	train-rmse:0.225286	eval-rmse:0.233209
[179]	train-rmse:0.224611	eval-rmse:0.232514
[180]	train-rmse:0.224121	eval-rmse:0.231974
[181]	train-rmse:0.223554	eval-rmse:0.231389
[182]	train-rmse:0.222938	eval-rmse:0.230591
[183]	train-rmse:0.222368	eval-rmse:0.230006
[184]	train-rmse:0.221852	eval-rmse:0.229488
[185]	train-rmse:0.221213	eval-rmse:0.22879
[186]	train-rmse:0.220518	eval-rmse:0.227971
[187]	train-rmse:0.220076	eval-rmse:0.227468
[188]	train-rmse:0.219669	eval-rmse:0.227056
[189]	train-rmse:0.21918	eval-rmse:0.226464
[190]	train-rmse:0.21871	eval-rmse:0.225987
[191]	train-rmse:0.218218	eval-rmse:0.225402
[192]	train-rmse:0.217701	eval-rmse:0.224801
[193]	train-rmse:0.217214	eval-rmse:0.224224
[194]	train-rmse:0.216694	eval-rmse:0.223686
[195]	train-rmse:0.216036	eval-rmse:0.223017
[196]	train-rmse:0.215364	eval-rmse:0.222351
[197]	train-rmse:0.214899	eval-rmse:0.221838
[198]	train-rmse:0.214338	eval-rmse:0.221244
[199]	train-rmse:0.213877	eval-rmse:0.220764
[200]	train-rmse:0.213324	eval-rmse:0.220193
[201]	train-rmse:0.212605	eval-rmse:0.219451
[202]	train-rmse:0.212054	eval-rmse:0.218773
[203]	train-rmse:0.211368	eval-rmse:0.218094
[204]	train-rmse:0.210884	eval-rmse:0.217538
[205]	train-rmse:0.210421	eval-rmse:0.217114
[206]	train-rmse:0.209907	eval-rmse:0.216516
[207]	train-rmse:0.209387	eval-rmse:0.215891
[208]	train-rmse:0.208686	eval-rmse:0.214936
[209]	train-rmse:0.208159	eval-rmse:0.214348
[210]	train-rmse:0.207863	eval-rmse:0.214075
[211]	train-rmse:0.207414	eval-rmse:0.213616
[212]	train-rmse:0.206923	eval-rmse:0.213013
[213]	train-rmse:0.206341	eval-rmse:0.212406
[214]	train-rmse:0.205881	eval-rmse:0.211968
[215]	train-rmse:0.205259	eval-rmse:0.21123
[216]	train-rmse:0.204775	eval-rmse:0.210702
[217]	train-rmse:0.20435	eval-rmse:0.21011
[218]	train-rmse:0.203849	eval-rmse:0.209552
[219]	train-rmse:0.203468	eval-rmse:0.209204
[220]	train-rmse:0.202964	eval-rmse:0.208647
[221]	train-rmse:0.20258	eval-rmse:0.208229
[222]	train-rmse:0.202187	eval-rmse:0.207791
[223]	train-rmse:0.201756	eval-rmse:0.20726
[224]	train-rmse:0.201325	eval-rmse:0.206733
[225]	train-rmse:0.200918	eval-rmse:0.206284
[226]	train-rmse:0.200547	eval-rmse:0.205834
[227]	train-rmse:0.200003	eval-rmse:0.205323
[228]	train-rmse:0.199743	eval-rmse:0.204965
[229]	train-rmse:0.199318	eval-rmse:0.204527
[230]	train-rmse:0.19873	eval-rmse:0.203787
[231]	train-rmse:0.198261	eval-rmse:0.203157
[232]	train-rmse:0.197734	eval-rmse:0.20245
[233]	train-rmse:0.197388	eval-rmse:0.202029
[234]	train-rmse:0.197017	eval-rmse:0.20157
[235]	train-rmse:0.196598	eval-rmse:0.201135
[236]	train-rmse:0.196114	eval-rmse:0.200748
[237]	train-rmse:0.195742	eval-rmse:0.200389
[238]	train-rmse:0.195308	eval-rmse:0.199833
[239]	train-rmse:0.194935	eval-rmse:0.199443
[240]	train-rmse:0.194592	eval-rmse:0.198978
[241]	train-rmse:0.193996	eval-rmse:0.198277
[242]	train-rmse:0.193602	eval-rmse:0.197903
[243]	train-rmse:0.193149	eval-rmse:0.197439
[244]	train-rmse:0.192726	eval-rmse:0.196872
[245]	train-rmse:0.192395	eval-rmse:0.196441
[246]	train-rmse:0.19214	eval-rmse:0.196092
[247]	train-rmse:0.191754	eval-rmse:0.19566
[248]	train-rmse:0.191368	eval-rmse:0.195321
[249]	train-rmse:0.190934	eval-rmse:0.194774
[250]	train-rmse:0.190518	eval-rmse:0.194258
[251]	train-rmse:0.190115	eval-rmse:0.193791
[252]	train-rmse:0.189729	eval-rmse:0.193406
[253]	train-rmse:0.189412	eval-rmse:0.193034
[254]	train-rmse:0.188999	eval-rmse:0.192507
[255]	train-rmse:0.188653	eval-rmse:0.192147
[256]	train-rmse:0.188278	eval-rmse:0.191794
[257]	train-rmse:0.187767	eval-rmse:0.191309
[258]	train-rmse:0.187474	eval-rmse:0.191003
[259]	train-rmse:0.18708	eval-rmse:0.19056
[260]	train-rmse:0.186751	eval-rmse:0.190134
[261]	train-rmse:0.18632	eval-rmse:0.18964
[262]	train-rmse:0.185957	eval-rmse:0.189304
[263]	train-rmse:0.185497	eval-rmse:0.188872
[264]	train-rmse:0.18518	eval-rmse:0.188537
[265]	train-rmse:0.184851	eval-rmse:0.188166
[266]	train-rmse:0.184492	eval-rmse:0.187696
[267]	train-rmse:0.184162	eval-rmse:0.187351
[268]	train-rmse:0.183756	eval-rmse:0.186909
[269]	train-rmse:0.183425	eval-rmse:0.186566
[270]	train-rmse:0.183157	eval-rmse:0.186233
[271]	train-rmse:0.182845	eval-rmse:0.185848
[272]	train-rmse:0.182382	eval-rmse:0.185321
[273]	train-rmse:0.181988	eval-rmse:0.184951
[274]	train-rmse:0.18166	eval-rmse:0.184534
[275]	train-rmse:0.181327	eval-rmse:0.184128
[276]	train-rmse:0.180906	eval-rmse:0.183577
[277]	train-rmse:0.180485	eval-rmse:0.183009
[278]	train-rmse:0.18008	eval-rmse:0.182563
[279]	train-rmse:0.179739	eval-rmse:0.182097
[280]	train-rmse:0.179393	eval-rmse:0.181688
[281]	train-rmse:0.179023	eval-rmse:0.181365
[282]	train-rmse:0.178572	eval-rmse:0.180867
[283]	train-rmse:0.178326	eval-rmse:0.18053
[284]	train-rmse:0.178034	eval-rmse:0.180175
[285]	train-rmse:0.177641	eval-rmse:0.17966
[286]	train-rmse:0.177327	eval-rmse:0.179176
[287]	train-rmse:0.176989	eval-rmse:0.17889
[288]	train-rmse:0.176747	eval-rmse:0.178603
[289]	train-rmse:0.176487	eval-rmse:0.178302
[290]	train-rmse:0.17609	eval-rmse:0.177954
[291]	train-rmse:0.175773	eval-rmse:0.177582
[292]	train-rmse:0.175445	eval-rmse:0.177289
[293]	train-rmse:0.175207	eval-rmse:0.177089
[294]	train-rmse:0.174892	eval-rmse:0.176631
[295]	train-rmse:0.174567	eval-rmse:0.176259
[296]	train-rmse:0.174219	eval-rmse:0.175851
[297]	train-rmse:0.173919	eval-rmse:0.175445
[298]	train-rmse:0.173607	eval-rmse:0.175114
[299]	train-rmse:0.173319	eval-rmse:0.174804
[300]	train-rmse:0.17305	eval-rmse:0.174532
[301]	train-rmse:0.172741	eval-rmse:0.174241
[302]	train-rmse:0.172493	eval-rmse:0.173963
[303]	train-rmse:0.172104	eval-rmse:0.173566
[304]	train-rmse:0.171852	eval-rmse:0.173254
[305]	train-rmse:0.171537	eval-rmse:0.172841
[306]	train-rmse:0.171339	eval-rmse:0.172652
[307]	train-rmse:0.170964	eval-rmse:0.172193
[308]	train-rmse:0.170696	eval-rmse:0.171894
[309]	train-rmse:0.170394	eval-rmse:0.171555
[310]	train-rmse:0.170058	eval-rmse:0.17119
[311]	train-rmse:0.169682	eval-rmse:0.170843
[312]	train-rmse:0.1693	eval-rmse:0.170432
[313]	train-rmse:0.169042	eval-rmse:0.170165
[314]	train-rmse:0.168781	eval-rmse:0.169887
[315]	train-rmse:0.168508	eval-rmse:0.169491
[316]	train-rmse:0.168253	eval-rmse:0.169193
[317]	train-rmse:0.167968	eval-rmse:0.16884
[318]	train-rmse:0.167764	eval-rmse:0.168594
[319]	train-rmse:0.167357	eval-rmse:0.1682
[320]	train-rmse:0.167047	eval-rmse:0.167865
[321]	train-rmse:0.1668	eval-rmse:0.16759
[322]	train-rmse:0.166481	eval-rmse:0.167166
[323]	train-rmse:0.166182	eval-rmse:0.166894
[324]	train-rmse:0.166005	eval-rmse:0.166694
[325]	train-rmse:0.165763	eval-rmse:0.166461
[326]	train-rmse:0.165443	eval-rmse:0.166138
[327]	train-rmse:0.165182	eval-rmse:0.165808
[328]	train-rmse:0.16489	eval-rmse:0.165487
[329]	train-rmse:0.16466	eval-rmse:0.165233
[330]	train-rmse:0.16438	eval-rmse:0.164916
[331]	train-rmse:0.164039	eval-rmse:0.164527
[332]	train-rmse:0.163831	eval-rmse:0.164288
[333]	train-rmse:0.16359	eval-rmse:0.164008
[334]	train-rmse:0.163367	eval-rmse:0.163699
[335]	train-rmse:0.163133	eval-rmse:0.163415
[336]	train-rmse:0.162833	eval-rmse:0.163104
[337]	train-rmse:0.162578	eval-rmse:0.162879
[338]	train-rmse:0.162447	eval-rmse:0.162746
[339]	train-rmse:0.162206	eval-rmse:0.162486
[340]	train-rmse:0.161988	eval-rmse:0.162203
[341]	train-rmse:0.161837	eval-rmse:0.162007
[342]	train-rmse:0.16166	eval-rmse:0.161807
[343]	train-rmse:0.161418	eval-rmse:0.161502
[344]	train-rmse:0.161222	eval-rmse:0.161321
[345]	train-rmse:0.16107	eval-rmse:0.161146
[346]	train-rmse:0.160776	eval-rmse:0.160854
[347]	train-rmse:0.160607	eval-rmse:0.160657
[348]	train-rmse:0.160397	eval-rmse:0.160369
[349]	train-rmse:0.160109	eval-rmse:0.160017
[350]	train-rmse:0.15985	eval-rmse:0.159681
[351]	train-rmse:0.159681	eval-rmse:0.159486
[352]	train-rmse:0.159438	eval-rmse:0.15911
[353]	train-rmse:0.159154	eval-rmse:0.158708
[354]	train-rmse:0.158934	eval-rmse:0.15845
[355]	train-rmse:0.158735	eval-rmse:0.158236
[356]	train-rmse:0.158474	eval-rmse:0.157874
[357]	train-rmse:0.158275	eval-rmse:0.157645
[358]	train-rmse:0.158049	eval-rmse:0.157418
[359]	train-rmse:0.157843	eval-rmse:0.157232
[360]	train-rmse:0.157664	eval-rmse:0.157026
[361]	train-rmse:0.157488	eval-rmse:0.156811
[362]	train-rmse:0.15728	eval-rmse:0.156613
[363]	train-rmse:0.157064	eval-rmse:0.156373
[364]	train-rmse:0.156831	eval-rmse:0.156136
[365]	train-rmse:0.156649	eval-rmse:0.155935
[366]	train-rmse:0.156479	eval-rmse:0.155737
[367]	train-rmse:0.156294	eval-rmse:0.155528
[368]	train-rmse:0.156066	eval-rmse:0.155179
[369]	train-rmse:0.155858	eval-rmse:0.154915
[370]	train-rmse:0.155605	eval-rmse:0.154658
[371]	train-rmse:0.155392	eval-rmse:0.154364
[372]	train-rmse:0.155214	eval-rmse:0.154156
[373]	train-rmse:0.154991	eval-rmse:0.153916
[374]	train-rmse:0.154794	eval-rmse:0.153693
[375]	train-rmse:0.154607	eval-rmse:0.153476
[376]	train-rmse:0.154451	eval-rmse:0.153326
[377]	train-rmse:0.154257	eval-rmse:0.153135
[378]	train-rmse:0.154011	eval-rmse:0.152844
[379]	train-rmse:0.153769	eval-rmse:0.152616
[380]	train-rmse:0.153571	eval-rmse:0.152468
[381]	train-rmse:0.153365	eval-rmse:0.152261
[382]	train-rmse:0.153188	eval-rmse:0.151991
[383]	train-rmse:0.153047	eval-rmse:0.151824
[384]	train-rmse:0.152912	eval-rmse:0.151676
[385]	train-rmse:0.152731	eval-rmse:0.151519
[386]	train-rmse:0.152538	eval-rmse:0.151273
[387]	train-rmse:0.152372	eval-rmse:0.151109
[388]	train-rmse:0.152256	eval-rmse:0.150997
[389]	train-rmse:0.152091	eval-rmse:0.150779
[390]	train-rmse:0.151871	eval-rmse:0.15056
[391]	train-rmse:0.151691	eval-rmse:0.150345
[392]	train-rmse:0.151489	eval-rmse:0.149996
[393]	train-rmse:0.151336	eval-rmse:0.149807
[394]	train-rmse:0.151202	eval-rmse:0.149678
[395]	train-rmse:0.150981	eval-rmse:0.14938
[396]	train-rmse:0.150718	eval-rmse:0.149044
[397]	train-rmse:0.150566	eval-rmse:0.148879
[398]	train-rmse:0.150394	eval-rmse:0.148657
[399]	train-rmse:0.150228	eval-rmse:0.148461
[400]	train-rmse:0.150131	eval-rmse:0.148315
[401]	train-rmse:0.149968	eval-rmse:0.148157
[402]	train-rmse:0.149775	eval-rmse:0.147935
[403]	train-rmse:0.149626	eval-rmse:0.14775
[404]	train-rmse:0.149504	eval-rmse:0.147572
[405]	train-rmse:0.149313	eval-rmse:0.14743
[406]	train-rmse:0.14915	eval-rmse:0.147247
[407]	train-rmse:0.148981	eval-rmse:0.147044
[408]	train-rmse:0.148801	eval-rmse:0.146836
[409]	train-rmse:0.148638	eval-rmse:0.14664
[410]	train-rmse:0.148482	eval-rmse:0.146484
[411]	train-rmse:0.148286	eval-rmse:0.146268
[412]	train-rmse:0.148149	eval-rmse:0.146109
[413]	train-rmse:0.147988	eval-rmse:0.145895
[414]	train-rmse:0.147817	eval-rmse:0.145679
[415]	train-rmse:0.147605	eval-rmse:0.145547
[416]	train-rmse:0.147463	eval-rmse:0.145402
[417]	train-rmse:0.147277	eval-rmse:0.145244
[418]	train-rmse:0.147105	eval-rmse:0.145054
[419]	train-rmse:0.146989	eval-rmse:0.144866
[420]	train-rmse:0.146794	eval-rmse:0.144706
[421]	train-rmse:0.146701	eval-rmse:0.144627
[422]	train-rmse:0.146477	eval-rmse:0.14436
[423]	train-rmse:0.146313	eval-rmse:0.144221
[424]	train-rmse:0.1462	eval-rmse:0.144085
[425]	train-rmse:0.146066	eval-rmse:0.143929
[426]	train-rmse:0.145882	eval-rmse:0.143765
[427]	train-rmse:0.145744	eval-rmse:0.143639
[428]	train-rmse:0.145639	eval-rmse:0.143595
[429]	train-rmse:0.145516	eval-rmse:0.143452
[430]	train-rmse:0.14531	eval-rmse:0.143175
[431]	train-rmse:0.145142	eval-rmse:0.142957
[432]	train-rmse:0.144966	eval-rmse:0.142784
[433]	train-rmse:0.144853	eval-rmse:0.142675
[434]	train-rmse:0.144798	eval-rmse:0.142609
[435]	train-rmse:0.14464	eval-rmse:0.142401
[436]	train-rmse:0.14451	eval-rmse:0.14226
[437]	train-rmse:0.144391	eval-rmse:0.142137
[438]	train-rmse:0.144201	eval-rmse:0.141939
[439]	train-rmse:0.144007	eval-rmse:0.141804
[440]	train-rmse:0.143864	eval-rmse:0.141624
[441]	train-rmse:0.143744	eval-rmse:0.141481
[442]	train-rmse:0.143591	eval-rmse:0.141358
[443]	train-rmse:0.143476	eval-rmse:0.141262
[444]	train-rmse:0.143322	eval-rmse:0.141109
[445]	train-rmse:0.143195	eval-rmse:0.140984
[446]	train-rmse:0.143047	eval-rmse:0.140853
[447]	train-rmse:0.142952	eval-rmse:0.140742
[448]	train-rmse:0.142756	eval-rmse:0.140562
[449]	train-rmse:0.142683	eval-rmse:0.140447
[450]	train-rmse:0.142557	eval-rmse:0.140325
[451]	train-rmse:0.14243	eval-rmse:0.140195
[452]	train-rmse:0.142261	eval-rmse:0.140004
[453]	train-rmse:0.142111	eval-rmse:0.139803
[454]	train-rmse:0.141881	eval-rmse:0.139646
[455]	train-rmse:0.141826	eval-rmse:0.139634
[456]	train-rmse:0.141733	eval-rmse:0.139536
[457]	train-rmse:0.14164	eval-rmse:0.139422
[458]	train-rmse:0.141556	eval-rmse:0.139311
[459]	train-rmse:0.141471	eval-rmse:0.139167
[460]	train-rmse:0.141333	eval-rmse:0.138978
[461]	train-rmse:0.141208	eval-rmse:0.138892
[462]	train-rmse:0.141105	eval-rmse:0.138723
[463]	train-rmse:0.141	eval-rmse:0.138614
[464]	train-rmse:0.140925	eval-rmse:0.13854
[465]	train-rmse:0.140808	eval-rmse:0.138414
[466]	train-rmse:0.140659	eval-rmse:0.138241
[467]	train-rmse:0.140581	eval-rmse:0.138138
[468]	train-rmse:0.140456	eval-rmse:0.138026
[469]	train-rmse:0.140302	eval-rmse:0.137855
[470]	train-rmse:0.140268	eval-rmse:0.137789
[471]	train-rmse:0.140139	eval-rmse:0.137658
[472]	train-rmse:0.140028	eval-rmse:0.137502
[473]	train-rmse:0.139964	eval-rmse:0.137423
[474]	train-rmse:0.13974	eval-rmse:0.137208
[475]	train-rmse:0.139642	eval-rmse:0.137097
[476]	train-rmse:0.139547	eval-rmse:0.136999
[477]	train-rmse:0.139401	eval-rmse:0.136779
[478]	train-rmse:0.139243	eval-rmse:0.136595
[479]	train-rmse:0.139154	eval-rmse:0.136534
[480]	train-rmse:0.139077	eval-rmse:0.136447
[481]	train-rmse:0.138903	eval-rmse:0.136302
[482]	train-rmse:0.138778	eval-rmse:0.136166
[483]	train-rmse:0.138677	eval-rmse:0.136073
[484]	train-rmse:0.138499	eval-rmse:0.135908
[485]	train-rmse:0.13844	eval-rmse:0.135864
[486]	train-rmse:0.138372	eval-rmse:0.135812
[487]	train-rmse:0.138238	eval-rmse:0.135707
[488]	train-rmse:0.138142	eval-rmse:0.135636
[489]	train-rmse:0.138062	eval-rmse:0.135539
[490]	train-rmse:0.137959	eval-rmse:0.135437
[491]	train-rmse:0.137842	eval-rmse:0.135278
[492]	train-rmse:0.137752	eval-rmse:0.135162
[493]	train-rmse:0.13763	eval-rmse:0.135039
[494]	train-rmse:0.137496	eval-rmse:0.134938
[495]	train-rmse:0.137383	eval-rmse:0.134751
[496]	train-rmse:0.137294	eval-rmse:0.134767
[497]	train-rmse:0.137201	eval-rmse:0.134714
[498]	train-rmse:0.137112	eval-rmse:0.134662
[499]	train-rmse:0.137042	eval-rmse:0.134608
[500]	train-rmse:0.136936	eval-rmse:0.134494
[501]	train-rmse:0.136829	eval-rmse:0.13441
[502]	train-rmse:0.136721	eval-rmse:0.134388
[503]	train-rmse:0.136617	eval-rmse:0.134281
[504]	train-rmse:0.136537	eval-rmse:0.134204
[505]	train-rmse:0.136442	eval-rmse:0.134118
[506]	train-rmse:0.136328	eval-rmse:0.134026
[507]	train-rmse:0.136283	eval-rmse:0.134006
[508]	train-rmse:0.136236	eval-rmse:0.133974
[509]	train-rmse:0.136128	eval-rmse:0.133824
[510]	train-rmse:0.136039	eval-rmse:0.133748
[511]	train-rmse:0.135982	eval-rmse:0.133682
[512]	train-rmse:0.135946	eval-rmse:0.133637
[513]	train-rmse:0.135872	eval-rmse:0.133543
[514]	train-rmse:0.135791	eval-rmse:0.13345
[515]	train-rmse:0.135724	eval-rmse:0.133427
[516]	train-rmse:0.135664	eval-rmse:0.133392
[517]	train-rmse:0.135633	eval-rmse:0.13336
[518]	train-rmse:0.135557	eval-rmse:0.133304
[519]	train-rmse:0.13548	eval-rmse:0.133242
[520]	train-rmse:0.135435	eval-rmse:0.133236
[521]	train-rmse:0.135412	eval-rmse:0.133198
[522]	train-rmse:0.135357	eval-rmse:0.13327
[523]	train-rmse:0.135278	eval-rmse:0.133177
[524]	train-rmse:0.1352	eval-rmse:0.133176
[525]	train-rmse:0.13515	eval-rmse:0.133152
[526]	train-rmse:0.135064	eval-rmse:0.133027
[527]	train-rmse:0.135008	eval-rmse:0.132949
[528]	train-rmse:0.134937	eval-rmse:0.132853
[529]	train-rmse:0.134825	eval-rmse:0.132765
[530]	train-rmse:0.134749	eval-rmse:0.132718
[531]	train-rmse:0.134694	eval-rmse:0.132664
[532]	train-rmse:0.134569	eval-rmse:0.132543
[533]	train-rmse:0.134457	eval-rmse:0.132402
[534]	train-rmse:0.134356	eval-rmse:0.132294
[535]	train-rmse:0.134261	eval-rmse:0.132259
[536]	train-rmse:0.134173	eval-rmse:0.132232
[537]	train-rmse:0.134118	eval-rmse:0.132198
[538]	train-rmse:0.134042	eval-rmse:0.132123
[539]	train-rmse:0.133966	eval-rmse:0.132089
[540]	train-rmse:0.133888	eval-rmse:0.132023
[541]	train-rmse:0.133848	eval-rmse:0.131931
[542]	train-rmse:0.133798	eval-rmse:0.131853
[543]	train-rmse:0.133732	eval-rmse:0.131796
[544]	train-rmse:0.133714	eval-rmse:0.131772
[545]	train-rmse:0.13365	eval-rmse:0.131721
[546]	train-rmse:0.133571	eval-rmse:0.131642
[547]	train-rmse:0.133493	eval-rmse:0.131581
[548]	train-rmse:0.133409	eval-rmse:0.131504
[549]	train-rmse:0.133372	eval-rmse:0.131453
[550]	train-rmse:0.133294	eval-rmse:0.13139
[551]	train-rmse:0.133213	eval-rmse:0.131307
[552]	train-rmse:0.133161	eval-rmse:0.131212
[553]	train-rmse:0.133084	eval-rmse:0.131121
[554]	train-rmse:0.133002	eval-rmse:0.131035
[555]	train-rmse:0.132957	eval-rmse:0.131009
[556]	train-rmse:0.132899	eval-rmse:0.130947
[557]	train-rmse:0.132824	eval-rmse:0.130891
[558]	train-rmse:0.132743	eval-rmse:0.130756
[559]	train-rmse:0.132666	eval-rmse:0.130715
[560]	train-rmse:0.132608	eval-rmse:0.130645
[561]	train-rmse:0.132564	eval-rmse:0.130556
[562]	train-rmse:0.132518	eval-rmse:0.130528
[563]	train-rmse:0.132473	eval-rmse:0.130462
[564]	train-rmse:0.13241	eval-rmse:0.130401
[565]	train-rmse:0.132367	eval-rmse:0.130295
[566]	train-rmse:0.132298	eval-rmse:0.130249
[567]	train-rmse:0.132252	eval-rmse:0.13019
[568]	train-rmse:0.132208	eval-rmse:0.130173
[569]	train-rmse:0.132163	eval-rmse:0.130095
[570]	train-rmse:0.132095	eval-rmse:0.13007
[571]	train-rmse:0.132026	eval-rmse:0.130016
[572]	train-rmse:0.131994	eval-rmse:0.129973
[573]	train-rmse:0.131936	eval-rmse:0.129909
[574]	train-rmse:0.131894	eval-rmse:0.129874
[575]	train-rmse:0.131807	eval-rmse:0.129826
[576]	train-rmse:0.131764	eval-rmse:0.129829
[577]	train-rmse:0.131717	eval-rmse:0.129797
[578]	train-rmse:0.131634	eval-rmse:0.129687
[579]	train-rmse:0.131569	eval-rmse:0.129628
[580]	train-rmse:0.131499	eval-rmse:0.129587
[581]	train-rmse:0.13144	eval-rmse:0.12953
[582]	train-rmse:0.131373	eval-rmse:0.129445
[583]	train-rmse:0.131319	eval-rmse:0.129521
[584]	train-rmse:0.131285	eval-rmse:0.129478
[585]	train-rmse:0.131226	eval-rmse:0.129535
[586]	train-rmse:0.131181	eval-rmse:0.129483
[587]	train-rmse:0.131121	eval-rmse:0.129461
[588]	train-rmse:0.13107	eval-rmse:0.129397
[589]	train-rmse:0.131016	eval-rmse:0.129338
[590]	train-rmse:0.130979	eval-rmse:0.129289
[591]	train-rmse:0.130928	eval-rmse:0.129258
[592]	train-rmse:0.130892	eval-rmse:0.129269
[593]	train-rmse:0.130867	eval-rmse:0.129196
[594]	train-rmse:0.130839	eval-rmse:0.129169
[595]	train-rmse:0.130815	eval-rmse:0.129138
[596]	train-rmse:0.130775	eval-rmse:0.129102
[597]	train-rmse:0.130755	eval-rmse:0.129136
[598]	train-rmse:0.130732	eval-rmse:0.129105
[599]	train-rmse:0.130681	eval-rmse:0.129074
[600]	train-rmse:0.130635	eval-rmse:0.129027
[601]	train-rmse:0.130597	eval-rmse:0.129008
[602]	train-rmse:0.130599	eval-rmse:0.128936
[603]	train-rmse:0.130559	eval-rmse:0.128924
[604]	train-rmse:0.13054	eval-rmse:0.128921
[605]	train-rmse:0.130514	eval-rmse:0.128905
[606]	train-rmse:0.130473	eval-rmse:0.128888
[607]	train-rmse:0.130415	eval-rmse:0.128885
[608]	train-rmse:0.130377	eval-rmse:0.128834
[609]	train-rmse:0.130337	eval-rmse:0.128791
[610]	train-rmse:0.130314	eval-rmse:0.128775
[611]	train-rmse:0.130303	eval-rmse:0.128767
[612]	train-rmse:0.130256	eval-rmse:0.128678
[613]	train-rmse:0.130236	eval-rmse:0.128645
[614]	train-rmse:0.130202	eval-rmse:0.128623
[615]	train-rmse:0.130143	eval-rmse:0.128765
[616]	train-rmse:0.130115	eval-rmse:0.128728
[617]	train-rmse:0.130074	eval-rmse:0.128698
[618]	train-rmse:0.130041	eval-rmse:0.128687
[619]	train-rmse:0.130008	eval-rmse:0.128623
[620]	train-rmse:0.129996	eval-rmse:0.128626
[621]	train-rmse:0.129944	eval-rmse:0.128559
[622]	train-rmse:0.129922	eval-rmse:0.128529
[623]	train-rmse:0.129914	eval-rmse:0.128674
[624]	train-rmse:0.129852	eval-rmse:0.128786
[625]	train-rmse:0.129807	eval-rmse:0.12879
[626]	train-rmse:0.129769	eval-rmse:0.128772
[627]	train-rmse:0.12977	eval-rmse:0.128738
[628]	train-rmse:0.129712	eval-rmse:0.128763
[629]	train-rmse:0.129662	eval-rmse:0.128724
[630]	train-rmse:0.129646	eval-rmse:0.128697
[631]	train-rmse:0.129638	eval-rmse:0.128685
[632]	train-rmse:0.129613	eval-rmse:0.128704
[633]	train-rmse:0.129574	eval-rmse:0.128689
[634]	train-rmse:0.129563	eval-rmse:0.128682
[635]	train-rmse:0.129542	eval-rmse:0.128676
[636]	train-rmse:0.129525	eval-rmse:0.128666
[637]	train-rmse:0.129498	eval-rmse:0.128644
[638]	train-rmse:0.129471	eval-rmse:0.128598
[639]	train-rmse:0.129443	eval-rmse:0.128546
[640]	train-rmse:0.129447	eval-rmse:0.128526
[641]	train-rmse:0.129423	eval-rmse:0.128514
[642]	train-rmse:0.129409	eval-rmse:0.12843
[643]	train-rmse:0.129375	eval-rmse:0.128396
[644]	train-rmse:0.129351	eval-rmse:0.128385
[645]	train-rmse:0.129324	eval-rmse:0.128344
[646]	train-rmse:0.129305	eval-rmse:0.128311
[647]	train-rmse:0.129311	eval-rmse:0.128371
[648]	train-rmse:0.129296	eval-rmse:0.12839
[649]	train-rmse:0.129274	eval-rmse:0.128388
[650]	train-rmse:0.129198	eval-rmse:0.12839
[651]	train-rmse:0.129169	eval-rmse:0.128392
[652]	train-rmse:0.129138	eval-rmse:0.128373
[653]	train-rmse:0.129122	eval-rmse:0.128363
[654]	train-rmse:0.129106	eval-rmse:0.128338
[655]	train-rmse:0.129088	eval-rmse:0.128335
[656]	train-rmse:0.129077	eval-rmse:0.128329
[657]	train-rmse:0.129061	eval-rmse:0.128335
[658]	train-rmse:0.129046	eval-rmse:0.128396
[659]	train-rmse:0.129042	eval-rmse:0.1284
[660]	train-rmse:0.129036	eval-rmse:0.128382
[661]	train-rmse:0.128992	eval-rmse:0.128364
[662]	train-rmse:0.128975	eval-rmse:0.128357
[663]	train-rmse:0.128968	eval-rmse:0.128432
[664]	train-rmse:0.128942	eval-rmse:0.128374
[665]	train-rmse:0.128907	eval-rmse:0.12835
[666]	train-rmse:0.12888	eval-rmse:0.128407
[667]	train-rmse:0.128839	eval-rmse:0.128392
[668]	train-rmse:0.128809	eval-rmse:0.128371
[669]	train-rmse:0.128787	eval-rmse:0.128366
[670]	train-rmse:0.128771	eval-rmse:0.128343
[671]	train-rmse:0.128772	eval-rmse:0.128314
[672]	train-rmse:0.128753	eval-rmse:0.128321
[673]	train-rmse:0.128724	eval-rmse:0.128291
[674]	train-rmse:0.12873	eval-rmse:0.128288
[675]	train-rmse:0.128672	eval-rmse:0.128273
[676]	train-rmse:0.128654	eval-rmse:0.12825
[677]	train-rmse:0.128644	eval-rmse:0.128257
[678]	train-rmse:0.128622	eval-rmse:0.128256
[679]	train-rmse:0.128604	eval-rmse:0.128277
[680]	train-rmse:0.12861	eval-rmse:0.128363
[681]	train-rmse:0.128581	eval-rmse:0.128333
[682]	train-rmse:0.128568	eval-rmse:0.128346
[683]	train-rmse:0.128569	eval-rmse:0.128332
[684]	train-rmse:0.128572	eval-rmse:0.128371
[685]	train-rmse:0.128524	eval-rmse:0.128304
[686]	train-rmse:0.128494	eval-rmse:0.128296
[687]	train-rmse:0.128476	eval-rmse:0.128289
[688]	train-rmse:0.128437	eval-rmse:0.12829
[689]	train-rmse:0.128452	eval-rmse:0.128377
[690]	train-rmse:0.128412	eval-rmse:0.128444
[691]	train-rmse:0.128379	eval-rmse:0.128408
[692]	train-rmse:0.128377	eval-rmse:0.128449
[693]	train-rmse:0.128345	eval-rmse:0.128448
[694]	train-rmse:0.128316	eval-rmse:0.128414
[695]	train-rmse:0.128302	eval-rmse:0.128396
[696]	train-rmse:0.128267	eval-rmse:0.128439
[697]	train-rmse:0.128233	eval-rmse:0.128498
[698]	train-rmse:0.12825	eval-rmse:0.128482
[699]	train-rmse:0.128203	eval-rmse:0.128429
[700]	train-rmse:0.1282	eval-rmse:0.128433
[701]	train-rmse:0.128185	eval-rmse:0.128468
[702]	train-rmse:0.128156	eval-rmse:0.128457
[703]	train-rmse:0.128131	eval-rmse:0.128482
[704]	train-rmse:0.128111	eval-rmse:0.128505
[705]	train-rmse:0.128101	eval-rmse:0.12853
[706]	train-rmse:0.128093	eval-rmse:0.128544
[707]	train-rmse:0.128066	eval-rmse:0.128551
[708]	train-rmse:0.128064	eval-rmse:0.128559
[709]	train-rmse:0.128027	eval-rmse:0.128572
[710]	train-rmse:0.128	eval-rmse:0.128569
[711]	train-rmse:0.127968	eval-rmse:0.128541
[712]	train-rmse:0.127961	eval-rmse:0.128529
[713]	train-rmse:0.127967	eval-rmse:0.128513
[714]	train-rmse:0.127971	eval-rmse:0.12853
[715]	train-rmse:0.127981	eval-rmse:0.128579
[716]	train-rmse:0.127963	eval-rmse:0.128577
[717]	train-rmse:0.12791	eval-rmse:0.128532
[718]	train-rmse:0.127894	eval-rmse:0.128544
[719]	train-rmse:0.127882	eval-rmse:0.128576
[720]	train-rmse:0.127869	eval-rmse:0.128561
[721]	train-rmse:0.127884	eval-rmse:0.128586
[722]	train-rmse:0.127902	eval-rmse:0.128597
[723]	train-rmse:0.127907	eval-rmse:0.128563
[724]	train-rmse:0.127915	eval-rmse:0.128552
[725]	train-rmse:0.127913	eval-rmse:0.128525
[726]	train-rmse:0.127869	eval-rmse:0.128499
Stopping. Best iteration:
[676]	train-rmse:0.128654	eval-rmse:0.12825

Plot variable importance


In [10]:
_ = xgb.plot_importance(xgb_model1)


Examine monotonic behavior with partial dependence and ICE

  • Partial dependence is used to view the global, average behavior of a variable under the monotonic model.
  • ICE is used to view the local behavior of a single instance and single variable under the monotonic model.
  • Overlaying partial dependence onto ICE in a plot is a convenient way to validate and understand both global and local monotonic behavior.

Helper function for calculating partial dependence


In [11]:
def par_dep(xs, frame, model, resolution=20, bins=None):
    
    """ Creates Pandas dataframe containing partial dependence for a single variable.
    
    Args:
        xs: Variable for which to calculate partial dependence.
        frame: H2OFrame for which to calculate partial dependence.
        model: XGBoost model for which to calculate partial dependence.
        resolution: The number of points across the domain of xs for which to calculate partial dependence.
    
    Returns:
        Pandas dataframe containing partial dependence values.
        
    """
    
    # don't show progress bars for parse
    h2o.no_progress()
    
    # init empty Pandas frame w/ correct col names
    par_dep_frame = pd.DataFrame(columns=[xs, 'partial_dependence'])
    
    # cache original data 
    col_cache = h2o.deep_copy(frame[xs], xid='col_cache')
  
    # determine values at which to calculate partial dependency
    if bins == None:
        min_ = frame[xs].min()
        max_ = frame[xs].max()
        by = (max_ - min_)/resolution
        bins = np.arange(min_, max_, by)
        
    # calculate partial dependency  
    # by setting column of interest to constant 
    for j in bins:
        frame[xs] = j
        dframe = xgb.DMatrix(frame.as_data_frame(),)
        par_dep_i = h2o.H2OFrame(model.predict(dframe).tolist())
        par_dep_j = par_dep_i.mean()[0]
        par_dep_frame = par_dep_frame.append({xs:j,
                                              'partial_dependence': par_dep_j}, 
                                              ignore_index=True)
        
    # return input frame to original cached state    
    frame[xs] = h2o.get_frame('col_cache')

    return par_dep_frame

Calculate partial dependence for 3 important variables


In [12]:
par_dep_OverallCond = par_dep('OverallCond', valid[reals], xgb_model1)
par_dep_GrLivArea = par_dep('GrLivArea', valid[reals], xgb_model1)
par_dep_LotArea = par_dep('LotArea', valid[reals], xgb_model1)

Helper function for finding decile indices


In [13]:
def get_quantile_dict(y, id_, frame):

    """ Returns the percentiles of a column y as the indices for another column id_.
    
    Args:
        y: Column in which to find percentiles.
        id_: Id column that stores indices for percentiles of y.
        frame: H2OFrame containing y and id_. 
    
    Returns:
        Dictionary of percentile values and index column values.
    
    """
    
    quantiles_df = frame.as_data_frame()
    quantiles_df.sort_values(y, inplace=True)
    quantiles_df.reset_index(inplace=True)
    
    percentiles_dict = {}
    percentiles_dict[0] = quantiles_df.loc[0, id_]
    percentiles_dict[99] = quantiles_df.loc[quantiles_df.shape[0]-1, id_]
    inc = quantiles_df.shape[0]//10
    
    for i in range(1, 10):
        percentiles_dict[i * 10] = quantiles_df.loc[i * inc,  id_]

    return percentiles_dict

Calculate deciles of SaleProce


In [14]:
quantile_dict = get_quantile_dict('SalePrice', 'Id', valid)

Calculate values for ICE


In [15]:
bins_OverallCond = list(par_dep_OverallCond['OverallCond'])
bins_GrLivArea = list(par_dep_GrLivArea['GrLivArea'])
bins_LotArea = list(par_dep_LotArea['LotArea'])

for i in sorted(quantile_dict.keys()):
    
    col_name = 'Percentile_' + str(i)
    
    par_dep_OverallCond[col_name] = par_dep('OverallCond', 
                                            valid[valid['Id'] == int(quantile_dict[i])][reals], 
                                            xgb_model1, 
                                            bins=bins_OverallCond)['partial_dependence']
    
    par_dep_GrLivArea[col_name] = par_dep('GrLivArea', 
                                          valid[valid['Id'] == int(quantile_dict[i])][reals], 
                                          xgb_model1, 
                                          bins=bins_GrLivArea)['partial_dependence']
    
    par_dep_LotArea[col_name] = par_dep('LotArea', 
                                         valid[valid['Id'] == int(quantile_dict[i])][reals], 
                                         xgb_model1, 
                                         bins=bins_LotArea)['partial_dependence']

Plot Partial Dependence and ICE


In [16]:
# OverallCond

fig, ax = plt.subplots()
par_dep_OverallCond.drop('partial_dependence', axis=1).plot(x='OverallCond', colormap='gnuplot', ax=ax)

par_dep_OverallCond.plot(title='Partial Dependence and ICE for OverallCond',
                         x='OverallCond', 
                         y='partial_dependence',
                         style='r-', 
                         linewidth=3, 
                         ax=ax)

_ = plt.legend(bbox_to_anchor=(1.05, 0),
               loc=3, 
               borderaxespad=0.)



In [17]:
# GrLivArea

fig, ax = plt.subplots()
par_dep_GrLivArea.drop('partial_dependence', axis=1).plot(x='GrLivArea', colormap='gnuplot', ax=ax)

par_dep_GrLivArea.plot(title='Partial Dependence and ICE for GrLivArea',
                         x='GrLivArea', 
                         y='partial_dependence',
                         style='r-', 
                         linewidth=3, 
                         ax=ax)

_ = plt.legend(bbox_to_anchor=(1.05, 0),
               loc=3, 
               borderaxespad=0.)



In [18]:
# LotArea

fig, ax = plt.subplots()
par_dep_LotArea.drop('partial_dependence', axis=1).plot(x='LotArea', colormap='gnuplot', ax=ax)

par_dep_LotArea.plot(title='Partial Dependence and ICE for LotArea',
                     x='LotArea', 
                     y='partial_dependence',
                     style='r-', 
                     linewidth=3, 
                     ax=ax)

_ = plt.legend(bbox_to_anchor=(1.05, 0),
               loc=3, 
               borderaxespad=0.)


Shutdown H2O


In [19]:
h2o.cluster().shutdown(prompt=True)


Are you sure you want to shutdown the H2O instance running at http://127.0.0.1:54321 (Y/N)? y
H2O session _sid_91ac closed.