API details.
import pandas as pd
import os
import sys
import inspect
import numpy as np

import time
import sys
import gc


from catboost import CatBoostRegressor, Pool, cv

import hyperopt

Data loading

data_df = pd.read_csv("../data/sales_train.csv")
data_df.head()
date date_block_num shop_id item_id item_price item_cnt_day
0 02.01.2013 0 59 22154 999.00 1.0
1 03.01.2013 0 25 2552 899.00 1.0
2 05.01.2013 0 25 2552 899.00 -1.0
3 06.01.2013 0 25 2554 1709.05 1.0
4 15.01.2013 0 25 2555 1099.00 1.0
data_df = data_df.drop("date",axis=1)
X_train = data_df[data_df.date_block_num < 33].drop(['item_cnt_day'], axis=1)
Y_train = data_df[data_df.date_block_num < 33]['item_cnt_day']
X_valid = data_df[data_df.date_block_num == 33].drop(['item_cnt_day'], axis=1)
Y_valid = data_df[data_df.date_block_num == 33]['item_cnt_day']
X_test = data_df[data_df.date_block_num == 34].drop(['item_cnt_day'], axis=1)
X_train.head()
date_block_num shop_id item_id item_price
0 0 59 22154 999.00
1 0 25 2552 899.00
2 0 25 2552 899.00
3 0 25 2554 1709.05
4 0 25 2555 1099.00
del data_df
gc.collect();

Model training

is_use_GPU = False
if is_use_GPU:
    task_type = "GPU"
else:
    task_type = "CPU"

Hyperopt

def hyperopt_objective(params):
    model = CatBoostRegressor(
        task_type = task_type,
        l2_leaf_reg=int(params['l2_leaf_reg']),
        learning_rate=params['learning_rate'],
        depth=int(params['depth']),
        
        iterations=500, # go to 500
        eval_metric='RMSE',
        random_seed=42,
        logging_level='Silent'
    )
    
    cv_data = cv(
        Pool(X_train
                , Y_train
                , cat_features = categorical_features_indices
            )
        ,model.get_params()
    )
    best_rmse = np.min(cv_data['test-RMSE-mean'])
    
    return best_rmse # as hyperopt minimises
do_tuning = False
if do_tuning:
    params_space = {
        'l2_leaf_reg': hyperopt.hp.qloguniform('l2_leaf_reg', 0, 2, 1),
        'learning_rate': hyperopt.hp.uniform('learning_rate', 1e-3, 5e-1),
        #'depth' : hyperopt.hp.uniform('depth', 5, 15)
        'depth' : hyperopt.hp.choice('depth', range(5,15))
    }

    trials = hyperopt.Trials()

    best = hyperopt.fmin(
        hyperopt_objective,
        space=params_space,
        algo=hyperopt.tpe.suggest,
        max_evals=50, # go to 50
        trials=trials,
        rstate=RandomState(123)
    )

    print(best)

Model parametrization

ts = time.time()

print("task type:",task_type)

model = CatBoostRegressor(
    task_type = task_type
    ,loss_function='RMSE'
    ,random_seed=42
    ,logging_level='Info'
    
    ,iterations=1000 # go to 500
    ,depth=7
    ,l2_leaf_reg=1.0
    ,learning_rate=0.36
    
    ,thread_count=-1
    ,early_stopping_rounds=50
)

train_pool = Pool(X_train
                  , Y_train
                  #, cat_features=categorical_features_indices
                 )

model_fit = model.fit(train_pool
                  , verbose=True 
                  , use_best_model=True
                  , eval_set=[(X_valid, Y_valid)])

time.time() - ts
task type: CPU
0:	learn: 2.2294130	test: 9.7623564	best: 9.7623564 (0)	total: 762ms	remaining: 12m 41s
1:	learn: 2.2051488	test: 9.7571760	best: 9.7571760 (1)	total: 1.14s	remaining: 9m 31s
2:	learn: 2.1936169	test: 9.7581899	best: 9.7571760 (1)	total: 1.55s	remaining: 8m 37s
3:	learn: 2.1501633	test: 9.6044575	best: 9.6044575 (3)	total: 1.84s	remaining: 7m 37s
4:	learn: 2.1415261	test: 9.6035323	best: 9.6035323 (4)	total: 2.13s	remaining: 7m 5s
5:	learn: 2.1368785	test: 9.6032698	best: 9.6032698 (5)	total: 2.54s	remaining: 7m
6:	learn: 2.1271711	test: 9.6032873	best: 9.6032698 (5)	total: 2.84s	remaining: 6m 43s
7:	learn: 2.1240736	test: 9.6031107	best: 9.6031107 (7)	total: 3.27s	remaining: 6m 46s
8:	learn: 2.1198226	test: 9.6070751	best: 9.6031107 (7)	total: 3.56s	remaining: 6m 32s
9:	learn: 2.1158140	test: 9.6057547	best: 9.6031107 (7)	total: 3.85s	remaining: 6m 21s
10:	learn: 2.1068363	test: 9.6056186	best: 9.6031107 (7)	total: 4.15s	remaining: 6m 12s
11:	learn: 2.1054902	test: 9.6058995	best: 9.6031107 (7)	total: 4.45s	remaining: 6m 6s
12:	learn: 2.1029512	test: 9.6059401	best: 9.6031107 (7)	total: 4.78s	remaining: 6m 3s
13:	learn: 2.0810105	test: 9.6061047	best: 9.6031107 (7)	total: 5.09s	remaining: 5m 58s
14:	learn: 2.0782914	test: 9.6060214	best: 9.6031107 (7)	total: 5.38s	remaining: 5m 53s
15:	learn: 2.0768353	test: 9.6059496	best: 9.6031107 (7)	total: 5.73s	remaining: 5m 52s
16:	learn: 2.0592506	test: 9.5452229	best: 9.5452229 (16)	total: 6.03s	remaining: 5m 48s
17:	learn: 2.0578205	test: 9.5449473	best: 9.5449473 (17)	total: 6.32s	remaining: 5m 44s
18:	learn: 2.0554762	test: 9.5449793	best: 9.5449473 (17)	total: 6.69s	remaining: 5m 45s
19:	learn: 2.0538966	test: 9.5449150	best: 9.5449150 (19)	total: 6.98s	remaining: 5m 41s
20:	learn: 2.0201790	test: 9.5452356	best: 9.5449150 (19)	total: 7.41s	remaining: 5m 45s
21:	learn: 2.0159917	test: 9.5444882	best: 9.5444882 (21)	total: 8.11s	remaining: 6m
22:	learn: 2.0144246	test: 9.5430907	best: 9.5430907 (22)	total: 8.46s	remaining: 5m 59s
23:	learn: 2.0137116	test: 9.5430047	best: 9.5430047 (23)	total: 8.93s	remaining: 6m 3s
24:	learn: 2.0083557	test: 9.5436835	best: 9.5430047 (23)	total: 9.32s	remaining: 6m 3s
25:	learn: 2.0014393	test: 9.5490417	best: 9.5430047 (23)	total: 9.63s	remaining: 6m
26:	learn: 1.9996181	test: 9.5490454	best: 9.5430047 (23)	total: 9.94s	remaining: 5m 58s
27:	learn: 1.9960842	test: 9.5384069	best: 9.5384069 (27)	total: 10.2s	remaining: 5m 55s
28:	learn: 1.9933633	test: 9.5379635	best: 9.5379635 (28)	total: 10.5s	remaining: 5m 52s
29:	learn: 1.9920022	test: 9.5380063	best: 9.5379635 (28)	total: 10.9s	remaining: 5m 51s
30:	learn: 1.9905059	test: 9.5379752	best: 9.5379635 (28)	total: 11.2s	remaining: 5m 48s
31:	learn: 1.9898216	test: 9.5380038	best: 9.5379635 (28)	total: 11.5s	remaining: 5m 46s
32:	learn: 1.9885853	test: 9.5380456	best: 9.5379635 (28)	total: 11.8s	remaining: 5m 45s
33:	learn: 1.9840746	test: 9.5384603	best: 9.5379635 (28)	total: 12.1s	remaining: 5m 42s
34:	learn: 1.9825693	test: 9.5384415	best: 9.5379635 (28)	total: 12.4s	remaining: 5m 42s
35:	learn: 1.9819100	test: 9.5384631	best: 9.5379635 (28)	total: 12.7s	remaining: 5m 40s
36:	learn: 1.9783488	test: 9.5194970	best: 9.5194970 (36)	total: 13s	remaining: 5m 38s
37:	learn: 1.9759464	test: 9.5196083	best: 9.5194970 (36)	total: 13.3s	remaining: 5m 36s
38:	learn: 1.9745541	test: 9.5195385	best: 9.5194970 (36)	total: 13.6s	remaining: 5m 34s
39:	learn: 1.9741921	test: 9.5189835	best: 9.5189835 (39)	total: 13.9s	remaining: 5m 32s
40:	learn: 1.9719567	test: 9.5192959	best: 9.5189835 (39)	total: 14.2s	remaining: 5m 31s
41:	learn: 1.9699940	test: 9.5226360	best: 9.5189835 (39)	total: 14.5s	remaining: 5m 30s
42:	learn: 1.9690314	test: 9.5226526	best: 9.5189835 (39)	total: 14.8s	remaining: 5m 28s
43:	learn: 1.9681814	test: 9.5223103	best: 9.5189835 (39)	total: 15.1s	remaining: 5m 27s
44:	learn: 1.9669671	test: 9.5223395	best: 9.5189835 (39)	total: 15.4s	remaining: 5m 27s
45:	learn: 1.9663137	test: 9.5223377	best: 9.5189835 (39)	total: 15.8s	remaining: 5m 26s
46:	learn: 1.9585372	test: 9.5224917	best: 9.5189835 (39)	total: 16.1s	remaining: 5m 25s
47:	learn: 1.9555785	test: 9.5224015	best: 9.5189835 (39)	total: 16.4s	remaining: 5m 24s
48:	learn: 1.9532166	test: 9.5223861	best: 9.5189835 (39)	total: 16.7s	remaining: 5m 24s
49:	learn: 1.9423671	test: 9.4957291	best: 9.4957291 (49)	total: 17s	remaining: 5m 22s
50:	learn: 1.9417486	test: 9.4957165	best: 9.4957165 (50)	total: 17.3s	remaining: 5m 22s
51:	learn: 1.9404602	test: 9.4958250	best: 9.4957165 (50)	total: 17.7s	remaining: 5m 22s
52:	learn: 1.9397528	test: 9.4957455	best: 9.4957165 (50)	total: 18s	remaining: 5m 21s
53:	learn: 1.9395772	test: 9.4956705	best: 9.4956705 (53)	total: 18.3s	remaining: 5m 20s
54:	learn: 1.9384863	test: 9.4958275	best: 9.4956705 (53)	total: 18.6s	remaining: 5m 19s
55:	learn: 1.9374777	test: 9.4958213	best: 9.4956705 (53)	total: 18.9s	remaining: 5m 18s
56:	learn: 1.9358561	test: 9.4958816	best: 9.4956705 (53)	total: 19.2s	remaining: 5m 18s
57:	learn: 1.9355292	test: 9.4954360	best: 9.4954360 (57)	total: 19.5s	remaining: 5m 17s
58:	learn: 1.9350090	test: 9.4954379	best: 9.4954360 (57)	total: 19.8s	remaining: 5m 16s
59:	learn: 1.9345830	test: 9.4953724	best: 9.4953724 (59)	total: 20.1s	remaining: 5m 15s
60:	learn: 1.9339920	test: 9.4940154	best: 9.4940154 (60)	total: 20.4s	remaining: 5m 14s
61:	learn: 1.9333693	test: 9.4938951	best: 9.4938951 (61)	total: 20.7s	remaining: 5m 13s
62:	learn: 1.9328305	test: 9.4938748	best: 9.4938748 (62)	total: 21s	remaining: 5m 12s
63:	learn: 1.9321213	test: 9.4938460	best: 9.4938460 (63)	total: 21.3s	remaining: 5m 11s
64:	learn: 1.9311226	test: 9.4937678	best: 9.4937678 (64)	total: 21.6s	remaining: 5m 11s
65:	learn: 1.9305096	test: 9.4937432	best: 9.4937432 (65)	total: 21.9s	remaining: 5m 10s
66:	learn: 1.9292910	test: 9.4936138	best: 9.4936138 (66)	total: 22.2s	remaining: 5m 9s
67:	learn: 1.9287599	test: 9.4931998	best: 9.4931998 (67)	total: 22.6s	remaining: 5m 9s
68:	learn: 1.9221245	test: 9.4932393	best: 9.4931998 (67)	total: 22.8s	remaining: 5m 8s
69:	learn: 1.9206909	test: 9.4932762	best: 9.4931998 (67)	total: 23.1s	remaining: 5m 7s
70:	learn: 1.9198678	test: 9.4933398	best: 9.4931998 (67)	total: 23.5s	remaining: 5m 6s
71:	learn: 1.9154574	test: 9.2012161	best: 9.2012161 (71)	total: 23.7s	remaining: 5m 6s
72:	learn: 1.9149297	test: 9.2021055	best: 9.2012161 (71)	total: 24s	remaining: 5m 5s
73:	learn: 1.9129130	test: 9.2020137	best: 9.2012161 (71)	total: 24.3s	remaining: 5m 4s
74:	learn: 1.9126102	test: 9.2019478	best: 9.2012161 (71)	total: 24.6s	remaining: 5m 3s
75:	learn: 1.9123056	test: 9.2019374	best: 9.2012161 (71)	total: 25s	remaining: 5m 3s
76:	learn: 1.9119048	test: 9.2019487	best: 9.2012161 (71)	total: 25.4s	remaining: 5m 3s
77:	learn: 1.9115290	test: 9.2019058	best: 9.2012161 (71)	total: 25.7s	remaining: 5m 3s
78:	learn: 1.9113093	test: 9.2019455	best: 9.2012161 (71)	total: 26s	remaining: 5m 3s
79:	learn: 1.9100641	test: 9.2019401	best: 9.2012161 (71)	total: 26.6s	remaining: 5m 6s
80:	learn: 1.9092528	test: 9.2018577	best: 9.2012161 (71)	total: 26.9s	remaining: 5m 5s
81:	learn: 1.9086414	test: 9.2009977	best: 9.2009977 (81)	total: 27.4s	remaining: 5m 6s
82:	learn: 1.9080905	test: 9.2010584	best: 9.2009977 (81)	total: 27.7s	remaining: 5m 6s
83:	learn: 1.9078817	test: 9.2009837	best: 9.2009837 (83)	total: 28s	remaining: 5m 5s
84:	learn: 1.9076017	test: 9.2009681	best: 9.2009681 (84)	total: 28.3s	remaining: 5m 5s
85:	learn: 1.9072400	test: 9.2009794	best: 9.2009681 (84)	total: 28.7s	remaining: 5m 4s
86:	learn: 1.9042095	test: 8.9681315	best: 8.9681315 (86)	total: 29s	remaining: 5m 3s
87:	learn: 1.9040063	test: 8.9679599	best: 8.9679599 (87)	total: 29.3s	remaining: 5m 3s
88:	learn: 1.9033946	test: 8.9677645	best: 8.9677645 (88)	total: 29.6s	remaining: 5m 2s
89:	learn: 1.9023357	test: 8.9677520	best: 8.9677520 (89)	total: 29.9s	remaining: 5m 1s
90:	learn: 1.9018698	test: 8.9676577	best: 8.9676577 (90)	total: 30.2s	remaining: 5m 1s
91:	learn: 1.9014233	test: 8.9676521	best: 8.9676521 (91)	total: 31.2s	remaining: 5m 7s
92:	learn: 1.9011186	test: 8.9677901	best: 8.9676521 (91)	total: 32.1s	remaining: 5m 13s
93:	learn: 1.9008316	test: 8.9677856	best: 8.9676521 (91)	total: 32.6s	remaining: 5m 14s
94:	learn: 1.8998135	test: 8.9678121	best: 8.9676521 (91)	total: 33.3s	remaining: 5m 16s
95:	learn: 1.8988977	test: 8.9677911	best: 8.9676521 (91)	total: 33.6s	remaining: 5m 16s
96:	learn: 1.8986541	test: 8.9675947	best: 8.9675947 (96)	total: 33.9s	remaining: 5m 15s
97:	learn: 1.8980265	test: 8.9676082	best: 8.9675947 (96)	total: 34.3s	remaining: 5m 15s
98:	learn: 1.8978497	test: 8.9675173	best: 8.9675173 (98)	total: 34.6s	remaining: 5m 15s
99:	learn: 1.8942698	test: 8.9593814	best: 8.9593814 (99)	total: 35.4s	remaining: 5m 18s
100:	learn: 1.8935714	test: 8.9591959	best: 8.9591959 (100)	total: 35.8s	remaining: 5m 18s
101:	learn: 1.8932886	test: 8.9593890	best: 8.9591959 (100)	total: 36.5s	remaining: 5m 21s
102:	learn: 1.8914082	test: 8.9595186	best: 8.9591959 (100)	total: 36.9s	remaining: 5m 21s
103:	learn: 1.8911552	test: 8.9589037	best: 8.9589037 (103)	total: 37.4s	remaining: 5m 22s
104:	learn: 1.8910254	test: 8.9589108	best: 8.9589037 (103)	total: 37.8s	remaining: 5m 22s
105:	learn: 1.8904893	test: 8.9588550	best: 8.9588550 (105)	total: 38.2s	remaining: 5m 22s
106:	learn: 1.8894389	test: 8.9588495	best: 8.9588495 (106)	total: 38.7s	remaining: 5m 22s
107:	learn: 1.8892436	test: 8.9588291	best: 8.9588291 (107)	total: 39.3s	remaining: 5m 24s
108:	learn: 1.8889646	test: 8.9588127	best: 8.9588127 (108)	total: 39.6s	remaining: 5m 24s
109:	learn: 1.8878755	test: 8.9588197	best: 8.9588127 (108)	total: 40.1s	remaining: 5m 24s
110:	learn: 1.8872669	test: 8.9585111	best: 8.9585111 (110)	total: 40.4s	remaining: 5m 23s
111:	learn: 1.8868385	test: 8.9586696	best: 8.9585111 (110)	total: 40.7s	remaining: 5m 22s
112:	learn: 1.8864233	test: 8.9586579	best: 8.9585111 (110)	total: 41.4s	remaining: 5m 24s
113:	learn: 1.8861924	test: 8.9585940	best: 8.9585111 (110)	total: 42.4s	remaining: 5m 29s
114:	learn: 1.8854541	test: 8.9587081	best: 8.9585111 (110)	total: 42.7s	remaining: 5m 28s
115:	learn: 1.8850305	test: 8.9583637	best: 8.9583637 (115)	total: 43.2s	remaining: 5m 29s
116:	learn: 1.8849010	test: 8.9583476	best: 8.9583476 (116)	total: 43.7s	remaining: 5m 29s
117:	learn: 1.8845855	test: 8.9576255	best: 8.9576255 (117)	total: 44.1s	remaining: 5m 29s
118:	learn: 1.8843162	test: 8.9578108	best: 8.9576255 (117)	total: 44.7s	remaining: 5m 30s
119:	learn: 1.8841183	test: 8.9573224	best: 8.9573224 (119)	total: 45.1s	remaining: 5m 30s
120:	learn: 1.8838699	test: 8.9572941	best: 8.9572941 (120)	total: 45.7s	remaining: 5m 31s
121:	learn: 1.8837094	test: 8.9572764	best: 8.9572764 (121)	total: 46s	remaining: 5m 31s
122:	learn: 1.8833882	test: 8.9572214	best: 8.9572214 (122)	total: 46.4s	remaining: 5m 31s
123:	learn: 1.8832684	test: 8.9572236	best: 8.9572214 (122)	total: 47s	remaining: 5m 31s
124:	learn: 1.8824690	test: 8.9574352	best: 8.9572214 (122)	total: 47.4s	remaining: 5m 31s
125:	learn: 1.8814911	test: 8.9574159	best: 8.9572214 (122)	total: 47.8s	remaining: 5m 31s
126:	learn: 1.8812084	test: 8.9575886	best: 8.9572214 (122)	total: 48.1s	remaining: 5m 30s
127:	learn: 1.8811016	test: 8.9575755	best: 8.9572214 (122)	total: 48.6s	remaining: 5m 30s
128:	learn: 1.8808306	test: 8.9575058	best: 8.9572214 (122)	total: 48.9s	remaining: 5m 30s
129:	learn: 1.8805813	test: 8.9575100	best: 8.9572214 (122)	total: 49.2s	remaining: 5m 29s
130:	learn: 1.8805152	test: 8.9574953	best: 8.9572214 (122)	total: 49.6s	remaining: 5m 28s
131:	learn: 1.8803587	test: 8.9574726	best: 8.9572214 (122)	total: 49.8s	remaining: 5m 27s
132:	learn: 1.8802771	test: 8.9576284	best: 8.9572214 (122)	total: 50.1s	remaining: 5m 26s
133:	learn: 1.8801940	test: 8.9576556	best: 8.9572214 (122)	total: 50.4s	remaining: 5m 25s
134:	learn: 1.8800759	test: 8.9576467	best: 8.9572214 (122)	total: 50.7s	remaining: 5m 24s
135:	learn: 1.8799391	test: 8.9576976	best: 8.9572214 (122)	total: 51.1s	remaining: 5m 24s
136:	learn: 1.8793609	test: 8.9577197	best: 8.9572214 (122)	total: 51.4s	remaining: 5m 23s
137:	learn: 1.8790448	test: 8.9592154	best: 8.9572214 (122)	total: 51.6s	remaining: 5m 22s
138:	learn: 1.8785808	test: 8.9588304	best: 8.9572214 (122)	total: 51.9s	remaining: 5m 21s
139:	learn: 1.8783280	test: 8.9588188	best: 8.9572214 (122)	total: 52.3s	remaining: 5m 21s
140:	learn: 1.8782473	test: 8.9587675	best: 8.9572214 (122)	total: 52.6s	remaining: 5m 20s
141:	learn: 1.8778002	test: 8.9587710	best: 8.9572214 (122)	total: 52.9s	remaining: 5m 19s
142:	learn: 1.8774486	test: 8.9587648	best: 8.9572214 (122)	total: 53.2s	remaining: 5m 18s
143:	learn: 1.8760550	test: 8.9587268	best: 8.9572214 (122)	total: 53.5s	remaining: 5m 17s
144:	learn: 1.8758821	test: 8.9586184	best: 8.9572214 (122)	total: 53.8s	remaining: 5m 17s
145:	learn: 1.8737911	test: 8.9585668	best: 8.9572214 (122)	total: 54s	remaining: 5m 16s
146:	learn: 1.8736906	test: 8.9585199	best: 8.9572214 (122)	total: 54.3s	remaining: 5m 15s
147:	learn: 1.8732627	test: 8.9584720	best: 8.9572214 (122)	total: 54.6s	remaining: 5m 14s
148:	learn: 1.8730862	test: 8.9584777	best: 8.9572214 (122)	total: 54.9s	remaining: 5m 13s
149:	learn: 1.8729792	test: 8.9584955	best: 8.9572214 (122)	total: 55.2s	remaining: 5m 13s
150:	learn: 1.8728461	test: 8.9582664	best: 8.9572214 (122)	total: 55.5s	remaining: 5m 12s
151:	learn: 1.8726593	test: 8.9582387	best: 8.9572214 (122)	total: 55.8s	remaining: 5m 11s
152:	learn: 1.8721132	test: 8.9582538	best: 8.9572214 (122)	total: 56.2s	remaining: 5m 10s
153:	learn: 1.8718073	test: 8.9582630	best: 8.9572214 (122)	total: 56.5s	remaining: 5m 10s
154:	learn: 1.8716035	test: 8.9582532	best: 8.9572214 (122)	total: 56.8s	remaining: 5m 9s
155:	learn: 1.8652943	test: 8.9806486	best: 8.9572214 (122)	total: 57.1s	remaining: 5m 8s
156:	learn: 1.8650829	test: 8.9806597	best: 8.9572214 (122)	total: 57.4s	remaining: 5m 8s
157:	learn: 1.8643521	test: 8.9806976	best: 8.9572214 (122)	total: 57.7s	remaining: 5m 7s
158:	learn: 1.8640522	test: 8.9806690	best: 8.9572214 (122)	total: 58s	remaining: 5m 6s
159:	learn: 1.8637584	test: 8.9808988	best: 8.9572214 (122)	total: 58.4s	remaining: 5m 6s
160:	learn: 1.8636074	test: 8.9808992	best: 8.9572214 (122)	total: 58.7s	remaining: 5m 5s
161:	learn: 1.8635229	test: 8.9808907	best: 8.9572214 (122)	total: 59s	remaining: 5m 5s
162:	learn: 1.8632419	test: 8.9808783	best: 8.9572214 (122)	total: 59.3s	remaining: 5m 4s
163:	learn: 1.8630281	test: 8.9809863	best: 8.9572214 (122)	total: 59.6s	remaining: 5m 3s
164:	learn: 1.8628420	test: 8.9808831	best: 8.9572214 (122)	total: 59.9s	remaining: 5m 2s
165:	learn: 1.8624684	test: 8.9813405	best: 8.9572214 (122)	total: 1m	remaining: 5m 2s
166:	learn: 1.8623708	test: 8.9815465	best: 8.9572214 (122)	total: 1m	remaining: 5m 1s
167:	learn: 1.8621560	test: 8.9811552	best: 8.9572214 (122)	total: 1m	remaining: 5m 1s
168:	learn: 1.8620841	test: 8.9811579	best: 8.9572214 (122)	total: 1m 1s	remaining: 5m
169:	learn: 1.8611429	test: 8.9811388	best: 8.9572214 (122)	total: 1m 1s	remaining: 4m 59s
170:	learn: 1.8599691	test: 8.9810791	best: 8.9572214 (122)	total: 1m 1s	remaining: 4m 59s
171:	learn: 1.8508718	test: 8.9903760	best: 8.9572214 (122)	total: 1m 1s	remaining: 4m 58s
172:	learn: 1.8474245	test: 8.9905854	best: 8.9572214 (122)	total: 1m 2s	remaining: 4m 57s
Stopped by overfitting detector  (50 iterations wait)

bestTest = 8.957221421
bestIteration = 122

Shrink model to first 123 iterations.
63.07235407829285
feature_importances = model_fit.get_feature_importance(train_pool)
feature_names = X_train.columns
for score, name in sorted(zip(feature_importances, feature_names), reverse=True):
    print('{}: {}'.format(name, score))
item_price: 33.16861862581194
shop_id: 30.35006874341807
item_id: 24.272024440825234
date_block_num: 12.209288189944767

Predict on TEST

Y_pred_train = model_fit.predict(X_train)
Y_pred_valid = model_fit.predict(X_valid)
print("done")
done