In [1]:
import os
import numpy as np 
import pandas as pd
import seaborn as sns
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import StandardScaler
import statsmodels.api as sm
from statsmodels.sandbox.regression.predstd import wls_prediction_std
from statsmodels.formula.api import ols
from  statsmodels.tsa.arima_model import ARIMA
from sklearn.metrics import mean_squared_error, mean_absolute_error, median_absolute_error, r2_score
from sklearn.model_selection import train_test_split
from tqdm import tqdm
from sklearn.ensemble import RandomForestRegressor
from sklearn.preprocessing import StandardScaler
import xgboost as xgb

# random seed
random_state=0
rng = np.random.RandomState(seed=random_state)


C:\Users\chris\Anaconda3\envs\mlp\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
  "This module will be removed in 0.20.", DeprecationWarning)

In [4]:
def mape(true, predicted):
    return np.mean(abs(((true - predicted)/true))) * (100)

def stdape(true,predicted):
    return np.std(abs(((true - predicted)/true))) * 100

Load and process data


In [5]:
#load dataset
data_process = pd.read_csv('clean_houses_95.csv',parse_dates=['Time'], index_col='Time')
data = data_process.copy(deep=True)

In [6]:
data.describe()


Out[6]:
House_1 House_2 House_4 House_5 House_6 House_7 House_8 House_9 House_10 House_12 House_13 House_15 House_16 House_17 House_18 House_19 House_20
count 12844.000000 10786.000000 12904.000000 13808.000000 11237.000000 12282.000000 11402.000000 11002.000000 12523.000000 10435.000000 8964.000000 11523.000000 10597.000000 10100.000000 9539.000000 10111.000000 9891.000000
mean 0.412006 0.357511 0.341143 0.654149 0.439971 0.468798 0.561477 0.464550 0.691112 0.307838 0.458776 0.216673 0.487613 0.321604 0.391240 0.256221 0.331514
std 0.284248 0.355437 0.135901 0.396728 0.182272 0.416472 0.429591 0.411350 0.551520 0.215136 0.350934 0.081999 0.276190 0.234905 0.163350 0.117051 0.164856
min 0.152000 0.052667 0.000000 0.127994 0.177595 0.092454 0.175323 0.107652 0.152500 0.123012 0.119870 0.072198 0.134351 0.115270 0.000000 0.131496 0.117722
25% 0.204036 0.122738 0.238103 0.345386 0.269982 0.168006 0.235547 0.176723 0.288828 0.155386 0.227653 0.162158 0.282523 0.177660 0.279276 0.165967 0.202034
50% 0.279732 0.185790 0.321434 0.538340 0.404851 0.233449 0.423248 0.238599 0.475191 0.208050 0.318241 0.178023 0.402364 0.233759 0.348697 0.210723 0.274244
75% 0.544857 0.446576 0.431228 0.849480 0.581491 0.685734 0.711342 0.660695 0.894842 0.378606 0.547833 0.252352 0.606807 0.359993 0.466000 0.314077 0.434960
max 1.382292 1.679221 0.756389 1.857446 0.920802 1.782699 2.391865 1.966144 2.169000 1.086158 1.822713 0.517512 1.417603 1.375439 1.123081 0.653684 0.938697

In [7]:
#load weather data
weather_process = pd.read_csv('weather_data.csv',parse_dates=True, index_col='dateTime')

In [8]:
# keep the same time frame for weather data and resample on hourly level by averaging
weather = weather_process.copy(deep=True)
cols = ['Wind_speed','Wind_direction_D1', 'Wind_direction_SD1', 'Average_horizontal_solar_irradiance', 'NR_Wm2_Avg', 'CNR_Wm2_Avg', 'Average_barometric_pressure']
weather = weather.drop(cols,axis=1)
weather = weather['2014-04':]
weather = weather.resample('H').mean()

In [9]:
scaler = StandardScaler()
weather[['Air_temperature','Relative_humidity', 'Total_horizontal_solar_irradiation','Total_rainfall']] = scaler.fit_transform(weather[['Air_temperature','Relative_humidity', 'Total_horizontal_solar_irradiation','Total_rainfall']])

In [10]:
data = data['2014-04':]

In [11]:
# Create seasonal variables
#data['Year'] = pd.DatetimeIndex(data.index).year
data['Month'] = pd.DatetimeIndex(data.index).month
data['Week'] = pd.DatetimeIndex(data.index).week
data['DayOfMonth'] = pd.DatetimeIndex(data.index).day
#data['DayOfWeek'] =  pd.DatetimeIndex(data.index).dayofweek
data['Day'] = pd.DatetimeIndex(data.index).weekday_name
data['Hour'] =  pd.DatetimeIndex(data.index).hour

# create weather variables
data = pd.concat([data,weather], axis=1)

Create seasonal variables


In [12]:
# Week days Feature
data.loc[(data['Day'] == 'Monday', 'WeekDays')] = 'WeekDays'
data.loc[(data['Day'] == 'Saturday', 'WeekDays')] = 'Saturday'
data.loc[(data['Day'] == 'Sunday', 'WeekDays')] = 'Sunday'
data.loc[(data['Day'] == 'Tuesday', 'WeekDays')] = 'WeekDays'
data.loc[(data['Day'] == 'Wednesday', 'WeekDays')] = 'WeekDays'
data.loc[(data['Day'] == 'Thursday', 'WeekDays')] = 'WeekDays'
data.loc[(data['Day'] == 'Friday', 'WeekDays')] = 'WeekDays'

In [13]:
# Season feature
data.loc[ (data['Month'] == 1), 'Season'] = 'Winter'
data.loc[ (data['Month'] == 2), 'Season'] = 'Winter'
data.loc[ (data['Month'] == 12), 'Season'] = 'Winter'
data.loc[ (data['Month'] == 3),  'Season'] = 'Spring'
data.loc[ (data['Month'] == 4),  'Season'] = 'Spring'
data.loc[ (data['Month'] == 5),  'Season'] = 'Spring'
data.loc[ (data['Month'] == 6), 'Season'] = 'Summer'
data.loc[ (data['Month'] == 7), 'Season'] = 'Summer'
data.loc[ (data['Month'] == 8), 'Season'] = 'Summer'
data.loc[ (data['Month'] == 9), 'Season'] = 'Autumn' 
data.loc[ (data['Month'] == 10), 'Season'] = 'Autumn' 
data.loc[ (data['Month'] == 11), 'Season'] = 'Autumn'

In [14]:
# Time bulk feature
time_bulk_1 = [1,2,3,4]
time_bulk_2 = [5,6,7,8]
time_bulk_3 = [9,10,11,12]
time_bulk_4 = [13,14,15,16]
time_bulk_5 = [17,18,19,20]
time_bulk_6 = [21,22,23,0]
for i in range(0,24):
    if i in time_bulk_1:
        data.loc[(data['Hour'] == i), 'Time_bulk'] = 'Midnight'
    elif i in time_bulk_2:
        data.loc[(data['Hour']== i), 'Time_bulk'] = 'Morning'
    elif i in time_bulk_3:
        data.loc[(data['Hour']== i), 'Time_bulk'] = 'Noon'
    elif i in time_bulk_4:
        data.loc[(data['Hour']== i), 'Time_bulk'] = 'Afternoon'
    elif i in time_bulk_5:
        data.loc[(data['Hour']== i), 'Time_bulk'] = 'Evening'
    else:
        data.loc[(data['Hour']== i), 'Time_bulk'] = 'Night'

In [15]:
# create trend 
data = data.assign(Trend = pd.Series(np.arange(len(data))+1).values)

In [16]:
# create trend square
x = (np.arange(data.shape[0]))**2 + 1
data = data.assign(Trend_square = pd.Series(x).values)

Prepare data for modeling


In [17]:
data_modeling = data.copy(deep=True)

In [18]:
data_modeling.columns


Out[18]:
Index(['House_1', 'House_2', 'House_4', 'House_5', 'House_6', 'House_7',
       'House_8', 'House_9', 'House_10', 'House_12', 'House_13', 'House_15',
       'House_16', 'House_17', 'House_18', 'House_19', 'House_20', 'Month',
       'Week', 'DayOfMonth', 'Day', 'Hour', 'Air_temperature',
       'Relative_humidity', 'Total_horizontal_solar_irradiation',
       'Total_rainfall', 'WeekDays', 'Season', 'Time_bulk', 'Trend',
       'Trend_square'],
      dtype='object')

In [19]:
# drop unwanted features
cols = ['Week','WeekDays','Season','Time_bulk','Trend','Trend_square']
data_modeling = data_modeling.drop(cols, axis=1)

In [20]:
data_modeling.columns


Out[20]:
Index(['House_1', 'House_2', 'House_4', 'House_5', 'House_6', 'House_7',
       'House_8', 'House_9', 'House_10', 'House_12', 'House_13', 'House_15',
       'House_16', 'House_17', 'House_18', 'House_19', 'House_20', 'Month',
       'DayOfMonth', 'Day', 'Hour', 'Air_temperature', 'Relative_humidity',
       'Total_horizontal_solar_irradiation', 'Total_rainfall'],
      dtype='object')

In [21]:
# columns for one hot encoding
cols =  ['Month','DayOfMonth', 'Hour', 'Day']

In [22]:
data_modeling.House_18 = data_modeling.House_18.replace(0.0, np.nan)

Linear Regression model


In [18]:
houses=[1,2,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20]
thesaurus = {}
all_results=pd.DataFrame()

for house_nr in houses:
    #create dummy variables
    data_ook = pd.get_dummies(data_modeling, columns=cols, prefix=cols, drop_first=True)
    data_ook = pd.get_dummies(data_ook, columns=['Month'], prefix='Month', drop_first=False)
    
    # keep the house you want for modeling
    drop_houses = ['House_'+str(i) for i in houses if i != house_nr]
    data_ook = data_ook.drop(drop_houses, axis=1)

    # drop nan values
    data_ook = data_ook.dropna(axis=0,how='any')

    # split train and test sets
    house = 'House_' + str(house_nr)
    x = data_ook.drop(house,axis=1).values.astype(np.float)
    y = data_ook[house].values
    
    
    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
    
    
    
    
    # train the model
    model = sm.OLS(endog=y_train,exog=x_train)
    results = model.fit()
    fit = results.fittedvalues
    
    form = 'House_' + str(house_nr) + ' ~ C(Month) + C(DayOfMonth) + C(WeekDays) + C(Hour) -1'
    mod = ols(formula=form, data=data_modeling, missing='drop').fit()
    anova = sm.stats.anova_lm(mod, typ=2)
    
    # save results from training time
    key= 'House'
    thesaurus[key] = house_nr
    key = 'train_r_squared'
    thesaurus[key] = results.rsquared
    key = 'train_r_squared_adj'
    thesaurus[key] = results.rsquared_adj
    key = 'train_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mape'
    thesaurus[key] = mape(y_train, fit)
    key = 'train_' + 'stdape'
    thesaurus[key] = stdape(y_train, fit)
    key = 'train_F_Month'
    thesaurus[key] = anova['F'][0]
    key = 'train_F_DayOfMonth'
    thesaurus[key] = anova['F'][1]
    key = 'train_F_WeekDays'
    thesaurus[key] = anova['F'][2]
    key = 'train_F_Hour'
    thesaurus[key] = anova['F'][3]
    key = 'train_PF_Month'
    thesaurus[key] = anova['PR(>F)'][0]
    key = 'train_PF_DayOfMonth'
    thesaurus[key] = anova['PR(>F)'][1]
    key = 'train_PF_WeekDays'
    thesaurus[key] = anova['PR(>F)'][2]
    key = 'train_PF_Hour'
    thesaurus[key] = anova['PR(>F)'][3]
    key = 'train_sq_Month'
    thesaurus[key] = anova['sum_sq'][0]
    key = 'train_sq_DayOfMonth'
    thesaurus[key] = anova['sum_sq'][1]
    key = 'train_sq_WeekDays'
    thesaurus[key] = anova['sum_sq'][2]
    key = 'train_sq_Hour'
    thesaurus[key] = anova['sum_sq'][3]
    
    
    # save results from testing time with rolling forecasting time technique

    predictions = results.predict(x_test)
    
    key = 'test_r_squared'
    thesaurus[key] = r2_score(y_true=y_test,y_pred=predictions)
    key = 'test_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_test,y_pred=predictions))*(len(y_test)-1)/(len(y_test)-x_test.shape[1]-1)
    key = 'test_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mape'
    thesaurus[key] = mape(y_test, predictions)
    key = 'test_' + 'stdape'
    thesaurus[key] = stdape(y_test, predictions)
    
    df1  = pd.DataFrame(thesaurus, index=[house_nr])
    all_results = pd.concat([all_results,df1])

In [20]:
all_results


Out[20]:
House test_mae test_mape test_mde test_mse test_r_squared test_r_squared_adj test_stdape train_F_DayOfMonth train_F_Hour ... train_mape train_mde train_mse train_r_squared train_r_squared_adj train_sq_DayOfMonth train_sq_Hour train_sq_Month train_sq_WeekDays train_stdape
1 1 0.178967 52.235575 0.130949 0.061578 0.115792 0.091651 39.591655 3.435350 18.267633 ... 52.322206 0.132900 0.057183 0.140348 0.132781 6.030216 24.583895 73.024904 0.696957 40.071536
2 2 0.222111 87.056806 0.144349 0.104265 0.240094 0.216761 99.064561 4.992025 98.341943 ... 86.201331 0.143371 0.091891 0.261228 0.253932 14.293578 215.878568 72.547132 0.349610 97.912065
4 4 0.087732 30.605260 0.071534 0.012646 0.273518 0.252884 31.303458 2.202778 156.768364 ... 31.266847 0.071701 0.012355 0.285337 0.278799 0.824949 45.011299 16.650833 0.070185 33.543347
5 5 0.266374 52.698633 0.215471 0.118248 0.223799 0.202335 61.179030 4.047185 88.651788 ... 50.247485 0.210186 0.111634 0.249562 0.242874 13.804344 231.823137 124.409816 58.339945 57.170681
6 6 0.103437 26.506716 0.073961 0.019317 0.399321 0.381677 29.059392 5.922642 243.822752 ... 27.114253 0.077358 0.019933 0.393063 0.387323 3.534026 111.541117 23.806624 0.350051 28.400947
7 7 0.227111 70.200541 0.169120 0.096859 0.349705 0.331648 70.590528 4.780833 221.162890 ... 71.796076 0.169738 0.105135 0.362979 0.357278 14.850394 526.687788 50.485779 0.244125 70.899572
8 8 0.254758 61.546434 0.165050 0.140317 0.254657 0.231707 71.125945 3.021297 136.649615 ... 59.546621 0.169104 0.129877 0.300136 0.293203 12.060371 418.198314 90.038098 0.278150 68.958409
9 9 0.234787 67.829398 0.156240 0.113152 0.354967 0.336363 69.517795 1.839077 220.376238 ... 67.075996 0.152611 0.114500 0.365965 0.360075 6.330179 581.550525 43.883461 18.100111 69.764320
10 10 0.246830 50.617283 0.181617 0.116598 0.282765 0.262608 49.075953 3.090912 163.132196 ... 50.882580 0.182555 0.117721 0.296955 0.290590 10.949724 443.060241 46.340772 1.150843 48.528173
12 12 0.129065 44.375928 0.091882 0.035253 0.267770 0.247346 42.763364 1.417606 155.844357 ... 43.932161 0.085651 0.032655 0.275611 0.269098 1.422337 119.879493 8.443047 0.581473 43.204422
13 13 0.201006 50.445792 0.137131 0.087933 0.220723 0.194565 48.779887 1.568409 110.037387 ... 49.921255 0.140022 0.090764 0.268950 0.261070 4.259616 229.117435 30.290950 13.276250 47.541401
15 15 0.050720 22.622782 0.037993 0.004799 0.241766 0.220258 16.290901 4.163523 123.267088 ... 22.564991 0.038394 0.004771 0.251073 0.244229 0.599412 13.605615 7.556726 0.138674 16.181769
16 16 0.190003 46.930474 0.146810 0.065146 0.145630 0.120030 43.930361 2.234088 56.827317 ... 46.509979 0.143224 0.061450 0.162408 0.154330 4.200886 81.922711 48.641620 1.188589 43.515380
17 17 0.133219 41.377086 0.082004 0.043560 0.226412 0.203955 36.343879 1.066907 119.504861 ... 41.065494 0.077626 0.042113 0.248551 0.241524 1.366705 117.365515 18.430772 1.671877 37.791965
18 18 0.091994 26.008663 0.059524 0.018360 0.257472 0.234524 35.698574 3.576818 132.946104 ... 25.350128 0.060120 0.018335 0.306783 0.299892 1.976736 56.329256 25.830514 0.100609 30.566020
19 19 0.075782 30.230766 0.057775 0.010437 0.240863 0.218912 23.269798 4.238580 106.956885 ... 30.146150 0.056907 0.010112 0.260404 0.253514 1.301815 25.185137 16.754388 0.081339 23.499527
20 20 0.094653 28.812114 0.067092 0.018290 0.359591 0.341262 25.070379 3.240399 235.063906 ... 28.937996 0.064578 0.016098 0.395000 0.389422 1.625099 90.380340 16.141367 0.136332 26.960323

17 rows × 27 columns


In [21]:
all_results.to_csv('results_linear_regression.csv')

Linear Regression Model with Weather Variables


In [24]:
houses=[1,2,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20]
thesaurus = {}
all_results=pd.DataFrame()

for house_nr in houses:
    #create dummy variables
    data_ook = pd.get_dummies(data_modeling, columns=cols, prefix=cols, drop_first=True)
    data_ook = pd.get_dummies(data_ook, columns=['Month'], prefix='Month', drop_first=False)
    
    # keep the house you want for modeling
    drop_houses = ['House_'+str(i) for i in houses if i != house_nr]
    data_ook = data_ook.drop(drop_houses, axis=1)

    # drop nan values
    data_ook = data_ook.dropna(axis=0,how='any')

    # split train and test sets
    house = 'House_' + str(house_nr)
    x = data_ook.drop(house,axis=1).values.astype(np.float)
    y = data_ook[house].values
    
    
    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
    
    
    
    
    # train the model
    model = sm.OLS(endog=y_train,exog=x_train)
    results = model.fit()
    fit = results.fittedvalues
    
    form = 'House_' + str(house_nr) + ' ~ C(Month) + C(DayOfMonth) + C(WeekDays) + C(Hour) + Air_temperature + Relative_humidity +Total_horizontal_solar_irradiation + Total_rainfall  -1'
    mod = ols(formula=form, data=data_modeling, missing='drop').fit()
    anova = sm.stats.anova_lm(mod, typ=2)
    
    # save results from training time
    key= 'House'
    thesaurus[key] = house_nr
    key = 'train_r_squared'
    thesaurus[key] = results.rsquared
    key = 'train_r_squared_adj'
    thesaurus[key] = results.rsquared_adj
    key = 'train_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mape'
    thesaurus[key] = mape(y_train, fit)
    key = 'train_' + 'stdape'
    thesaurus[key] = stdape(y_train, fit)
    key = 'train_F_Month'
    thesaurus[key] = anova['F'][0]
    key = 'train_F_DayOfMonth'
    thesaurus[key] = anova['F'][1]
    key = 'train_F_WeekDays'
    thesaurus[key] = anova['F'][2]
    key = 'train_F_Hour'
    thesaurus[key] = anova['F'][3]
    key = 'train_F_AirTemperature'
    thesaurus[key] = anova['F'][4]
    key = 'train_F_Relative_humitidity'
    thesaurus[key] = anova['F'][5]
    key = 'train_F_Total_horizontal_solar_irradiation'
    thesaurus[key] = anova['F'][6]
    key = 'train_F_Total_rainfall'
    thesaurus[key] = anova['F'][7]
    key = 'train_PF_Month'
    thesaurus[key] = anova['PR(>F)'][0]
    key = 'train_PF_DayOfMonth'
    thesaurus[key] = anova['PR(>F)'][1]
    key = 'train_PF_WeekDays'
    thesaurus[key] = anova['PR(>F)'][2]
    key = 'train_PF_Hour'
    thesaurus[key] = anova['PR(>F)'][3]
    key = 'train_PF_AirTemperature'
    thesaurus[key] = anova['PR(>F)'][4]
    key = 'train_PF_Relative_humitidity'
    thesaurus[key] = anova['PR(>F)'][5]
    key = 'train_PF_Total_horizontal_solar_irradiation'
    thesaurus[key] = anova['PR(>F)'][6]
    key = 'train_PF_Total_rainfall'
    thesaurus[key] = anova['PR(>F)'][7]
    key = 'train_sq_Month'
    thesaurus[key] = anova['sum_sq'][0]
    key = 'train_sq_DayOfMonth'
    thesaurus[key] = anova['sum_sq'][1]
    key = 'train_sq_WeekDays'
    thesaurus[key] = anova['sum_sq'][2]
    key = 'train_sq_Hour'
    thesaurus[key] = anova['sum_sq'][3]
    key = 'train_sq_AirTemperature'
    thesaurus[key] = anova['sum_sq'][4]
    key = 'train_sq_Relative_humitidity'
    thesaurus[key] = anova['sum_sq'][5]
    key = 'train_sq_Total_horizontal_solar_irradiation'
    thesaurus[key] = anova['sum_sq'][6]
    key = 'train_sq_Total_rainfall'
    thesaurus[key] = anova['sum_sq'][7]
    
    
    # save results from testing time with rolling forecasting time technique

    predictions = results.predict(x_test)
    
    key = 'test_r_squared'
    thesaurus[key] = r2_score(y_true=y_test,y_pred=predictions)
    key = 'test_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_test,y_pred=predictions))*(len(y_test)-1)/(len(y_test)-x_test.shape[1]-1)
    key = 'test_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mape'
    thesaurus[key] = mape(y_test, predictions)
    key = 'test_' + 'stdape'
    thesaurus[key] = stdape(y_test, predictions)
    
    df1  = pd.DataFrame(thesaurus, index=[house_nr])
    all_results = pd.concat([all_results,df1])

In [25]:
all_results


Out[25]:
House test_mae test_mape test_mde test_mse test_r_squared test_r_squared_adj test_stdape train_F_AirTemperature train_F_DayOfMonth ... train_r_squared_adj train_sq_AirTemperature train_sq_DayOfMonth train_sq_Hour train_sq_Month train_sq_Relative_humitidity train_sq_Total_horizontal_solar_irradiation train_sq_Total_rainfall train_sq_WeekDays train_stdape
1 1 0.181865 53.343661 0.138438 0.063595 0.127871 0.100497 42.127739 2.934384 4.110145 ... 0.139554 0.174511 7.333052 29.285508 35.894878 0.053633 2.647075 0.110293 0.669910 41.026246
2 2 0.223145 87.910561 0.144049 0.104546 0.238044 0.213205 99.613405 4.730395 4.902340 ... 0.256394 0.450614 14.009795 190.643399 36.407641 0.648650 0.757229 0.619974 0.361076 98.247845
4 4 0.088127 30.046517 0.072536 0.012800 0.289845 0.267315 30.079863 1.499990 2.315296 ... 0.290243 0.018417 0.852810 40.221538 14.239091 0.893675 0.001918 0.010315 0.071836 33.288200
5 5 0.265088 53.630040 0.218344 0.114980 0.218652 0.194062 60.175716 7.847249 4.569725 ... 0.250879 0.911215 15.918957 217.103111 72.890939 0.582157 0.108596 0.045777 55.433062 56.771385
6 6 0.104258 26.688371 0.071971 0.019455 0.409163 0.389956 29.030731 1.292837 5.244636 ... 0.410334 0.024650 2.999883 90.151098 20.626734 0.023033 0.243476 0.025441 0.342953 28.679583
7 7 0.234082 69.145876 0.162517 0.104185 0.367688 0.347610 68.496548 16.151543 4.890325 ... 0.360275 1.692527 15.373774 436.833523 16.465349 2.429099 0.803571 0.020549 0.217678 71.910354
8 8 0.253882 61.121533 0.165814 0.139161 0.260794 0.236631 70.440003 37.408344 3.173440 ... 0.297857 4.942055 12.577392 332.923114 43.312684 0.116868 0.455986 4.111831 0.343115 68.442998
9 9 0.240024 67.475256 0.154405 0.121905 0.346134 0.324501 71.063324 3.295478 1.891999 ... 0.366358 0.380335 6.550732 502.602937 33.725959 2.565686 0.583846 0.985845 16.090159 68.386670
10 10 0.245231 50.980182 0.177723 0.116838 0.302649 0.280663 49.625618 2.944904 3.751085 ... 0.310659 0.352955 13.487344 425.412152 25.753715 8.234095 0.066039 0.156845 1.367876 50.361947
12 12 0.126675 44.480650 0.085047 0.034166 0.268752 0.245471 43.535855 4.150947 1.674026 ... 0.271077 0.139206 1.684199 104.524098 6.163470 0.327482 0.428319 0.060191 0.692626 43.530698
13 13 0.201368 50.647922 0.134965 0.087791 0.221985 0.194255 48.578650 3.137249 1.658493 ... 0.264836 0.282784 4.484783 191.133929 26.604344 0.383096 2.755629 0.843039 13.465407 47.374519
15 15 0.051456 22.384538 0.037777 0.004967 0.268051 0.244310 16.365377 11.654206 4.869402 ... 0.257073 0.055700 0.698177 11.819500 6.200929 0.352803 0.004181 0.052697 0.131597 15.783524
16 16 0.187620 45.204954 0.147934 0.062502 0.153050 0.123830 40.920608 20.185378 2.690641 ... 0.163191 1.264858 5.058037 75.703395 33.674924 3.065178 0.576844 0.357168 1.413775 41.435331
17 17 0.136581 41.073037 0.081203 0.046051 0.242326 0.218332 36.707236 1.074901 0.971751 ... 0.239399 0.045996 1.247454 90.615590 15.021754 0.365787 0.137503 0.000203 1.787999 37.107675
18 18 0.091057 25.698310 0.057366 0.018249 0.261944 0.237729 35.703816 19.808109 3.816399 ... 0.310007 0.360344 2.082806 45.740229 23.547602 0.290256 0.747791 0.011133 0.065242 30.249440
19 19 0.076123 30.344029 0.057225 0.010621 0.246426 0.222625 23.866019 0.364072 4.215819 ... 0.260935 0.003709 1.288488 23.928822 11.657761 0.351531 0.010953 0.007633 0.080327 23.590612
20 20 0.094799 29.556247 0.066264 0.018318 0.368669 0.348765 27.486581 3.936766 3.120862 ... 0.385464 0.065495 1.557642 78.906262 12.844109 0.006586 0.054306 0.005850 0.126570 26.772711

17 rows × 39 columns


In [26]:
all_results.to_csv('results_linear_weather.csv')

Dynamic model with exogenous variables


In [18]:
houses=[1,2,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20]
thesaurus = {}
all_results=pd.DataFrame()

for house_nr in houses:
    data_copied = data_modeling.copy(deep=True)
    
    #create dummy variables
    data_ook = pd.get_dummies(data_modeling, columns=cols, prefix=cols, drop_first=True)
    data_ook = pd.get_dummies(data_ook, columns=['Month'], prefix='Month', drop_first=False)
    
    # keep the house you want for modeling
    drop_houses = ['House_'+str(i) for i in houses if i != house_nr]
    data_ook = data_ook.drop(drop_houses, axis=1)
    data_copied = data_copied.drop(drop_houses, axis=1)
    
    # create lagged predictors
    data_copied['t1'] = data_copied['House_'+str(house_nr)].shift(+1)
    data_copied['t24'] = data_copied['House_'+str(house_nr)].shift(+24)
    data_ook['t1'] = data_ook['House_'+str(house_nr)].shift(+1)
    data_ook['t24'] = data_ook['House_'+str(house_nr)].shift(+24)

    # drop nan values
    data_ook = data_ook.dropna(axis=0,how='any')
    data_copied = data_copied.dropna(axis=0,how='any')
    

    # split train and test sets
    house = 'House_' + str(house_nr)
    x = data_ook.drop(house,axis=1).values.astype(np.float)
    y = data_ook[house].values
    
    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
    
    # train the model
    model = sm.OLS(endog=y_train,exog=x_train)
    results = model.fit()
    fit = results.fittedvalues
    
    form = 'House_' + str(house_nr) + ' ~ C(Month) + C(DayOfMonth) + C(WeekDays) + C(Hour) + t1 + t24 -1'
    mod = ols(formula=form, data=data_copied, missing='drop').fit()
    anova = sm.stats.anova_lm(mod, typ=2)
    
    # save results from training time
    key= 'House'
    thesaurus[key] = house_nr
    key = 'train_r_squared'
    thesaurus[key] = results.rsquared
    key = 'train_r_squared_adj'
    thesaurus[key] = results.rsquared_adj
    key = 'train_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mape'
    thesaurus[key] = mape(y_train, fit)
    key = 'train_' + 'stdape'
    thesaurus[key] = stdape(y_train, fit)
    key = 'train_F_Month'
    thesaurus[key] = anova['F'][0]
    key = 'train_F_DayOfMonth'
    thesaurus[key] = anova['F'][1]
    key = 'train_F_WeekDays'
    thesaurus[key] = anova['F'][2]
    key = 'train_F_Hour'
    thesaurus[key] = anova['F'][3]
    key = 'train_F_t1'
    thesaurus[key] = anova['F'][4]
    key = 'train_F_t24'
    thesaurus[key] = anova['F'][5]
    key = 'train_PF_Month'
    thesaurus[key] = anova['PR(>F)'][0]
    key = 'train_PF_DayOfMonth'
    thesaurus[key] = anova['PR(>F)'][1]
    key = 'train_PF_WeekDays'
    thesaurus[key] = anova['PR(>F)'][2]
    key = 'train_PF_Hour'
    thesaurus[key] = anova['PR(>F)'][3]
    key = 'train_PF_t1'
    thesaurus[key] = anova['PR(>F)'][4]
    key = 'train_PF_t24'
    thesaurus[key] = anova['PR(>F)'][5]
    key = 'train_sq_Month'
    thesaurus[key] = anova['sum_sq'][0]
    key = 'train_sq_DayOfMonth'
    thesaurus[key] = anova['sum_sq'][1]
    key = 'train_sq_WeekDays'
    thesaurus[key] = anova['sum_sq'][2]
    key = 'train_sq_Hour'
    thesaurus[key] = anova['sum_sq'][3]
    key = 'train_sq_t1'
    thesaurus[key] = anova['sum_sq'][4]
    key = 'train_sq_t24'
    thesaurus[key] = anova['sum_sq'][5]
    
    
    # save results from testing time with rolling forecasting time technique

    predictions = results.predict(x_test)
    
    key = 'test_r_squared'
    thesaurus[key] = r2_score(y_true=y_test,y_pred=predictions)
    key = 'test_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_test,y_pred=predictions))*(len(y_test)-1)/(len(y_test)-x_test.shape[1]-1)
    key = 'test_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mape'
    thesaurus[key] = mape(y_test, predictions)
    key = 'test_' + 'stdape'
    thesaurus[key] = stdape(y_test, predictions)
    
    df1  = pd.DataFrame(thesaurus, index=[house_nr])
    all_results = pd.concat([all_results,df1])

In [19]:
all_results


Out[19]:
House test_mae test_mape test_mde test_mse test_r_squared test_r_squared_adj test_stdape train_F_DayOfMonth train_F_Hour ... train_mse train_r_squared train_r_squared_adj train_sq_DayOfMonth train_sq_Hour train_sq_Month train_sq_WeekDays train_sq_t1 train_sq_t24 train_stdape
1 1 0.135517 39.602279 0.083189 0.042856 0.312054 0.291189 38.475065 1.147296 9.110717 ... 0.041685 0.332958 0.326443 1.452631 8.843805 6.900958 0.368102 53.899682 33.243210 34.892491
2 2 0.174195 65.570635 0.097669 0.073588 0.363471 0.340959 78.210567 1.899426 33.557641 ... 0.067021 0.411001 0.404317 3.924730 53.160051 9.049915 0.038023 112.209751 10.844576 75.396464
4 4 0.084468 30.118399 0.069074 0.011817 0.289366 0.266171 30.636396 1.510538 66.149243 ... 0.011578 0.283571 0.276054 0.530120 17.798115 8.741517 0.059832 0.013395 1.929882 32.483635
5 5 0.202795 35.103217 0.144086 0.078478 0.412537 0.394079 31.074076 0.912680 30.760933 ... 0.076273 0.437189 0.431502 2.112711 54.591817 14.892171 7.943981 197.312610 22.029400 32.290503
6 6 0.077301 18.521167 0.055665 0.011459 0.638835 0.626553 17.379759 1.585598 44.942786 ... 0.011201 0.633205 0.629200 0.539237 11.717991 0.540364 0.016635 53.994409 1.254021 17.831947
7 7 0.183494 52.881877 0.108982 0.076347 0.466068 0.449152 56.742828 1.688538 60.418611 ... 0.077381 0.457944 0.452422 3.924115 107.648545 6.306275 0.224855 131.636318 8.267168 57.128409
8 8 0.200901 47.581512 0.135003 0.088415 0.351170 0.328852 49.582860 1.816931 29.303522 ... 0.098537 0.359162 0.352083 5.264441 65.093898 20.936540 0.028396 55.450462 65.780045 50.675066
9 9 0.189317 50.744601 0.107449 0.082358 0.486314 0.469323 56.694909 0.938745 54.596370 ... 0.083929 0.467932 0.462278 2.365007 105.452087 5.347031 5.109571 133.852566 10.429121 59.828051
10 10 0.199220 38.809710 0.122343 0.089943 0.404766 0.385909 38.831228 1.024271 46.057493 ... 0.087503 0.420720 0.414817 2.720862 93.799075 8.341707 0.366118 170.619791 7.451877 37.787212
12 12 0.104948 37.478595 0.063178 0.025770 0.347099 0.326067 38.850262 0.655065 50.407033 ... 0.026164 0.353699 0.347006 0.515122 30.389472 1.898313 0.078602 29.000283 1.468887 38.000693
13 13 0.152493 34.421632 0.071384 0.068069 0.373963 0.349572 40.875850 0.739256 28.968709 ... 0.060076 0.426913 0.419767 1.383697 41.570179 5.287358 2.124284 96.919874 12.829468 38.090869
15 15 0.037721 16.445637 0.023344 0.003128 0.425873 0.407335 14.563722 1.720313 30.343428 ... 0.003066 0.456640 0.451000 0.159878 2.161983 0.761435 0.015260 7.820135 0.843805 14.243415
16 16 0.145523 35.177947 0.099244 0.043581 0.336496 0.313696 34.545735 1.097308 14.405857 ... 0.045588 0.330968 0.323589 1.492635 15.023489 4.827155 0.242439 86.194350 9.808125 31.717864
17 17 0.111880 32.979239 0.060243 0.036529 0.313238 0.290738 31.837652 0.497344 40.374242 ... 0.031642 0.311666 0.304416 0.492761 30.668370 4.744979 0.579067 31.135964 2.293458 32.763814
18 18 0.060607 15.676255 0.034356 0.009957 0.546174 0.530132 19.475570 1.506940 26.135568 ... 0.009654 0.537896 0.532656 0.442469 5.883363 1.696486 0.076117 25.149341 5.160178 20.575741
19 19 0.062504 24.563742 0.043875 0.008031 0.339009 0.317124 19.577290 1.435530 31.679577 ... 0.008078 0.370544 0.363848 0.349283 5.909511 2.235411 0.026643 12.138326 0.782325 19.700891
20 20 0.071920 22.414942 0.045066 0.011601 0.520003 0.504178 21.338410 1.525946 56.971386 ... 0.011388 0.525355 0.520328 0.526570 15.072333 2.020861 0.079431 21.004824 4.337540 21.294458

17 rows × 33 columns


In [20]:
all_results.to_csv('results_dynamic_regression.csv')

Random Forest Regressor


In [30]:
houses=[1,2,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20]
thesaurus = {}
all_results=pd.DataFrame()

for house_nr in houses:
    
    #create dummy variables
    data_ook = pd.get_dummies(data_modeling, columns=cols, prefix=cols, drop_first=True)
    data_ook = pd.get_dummies(data_ook, columns=['Month'], prefix='Month', drop_first=False)
    
    # keep the house you want for modeling
    drop_houses = ['House_'+str(i) for i in houses if i != house_nr]
    data_ook = data_ook.drop(drop_houses, axis=1)
    
    # create lagged predictors
    data_ook['t1'] = data_ook['House_'+str(house_nr)].shift(+1)
    data_ook['t24'] = data_ook['House_'+str(house_nr)].shift(+24)

    # drop nan values
    data_ook = data_ook.dropna(axis=0,how='any')
    
    
    # split train and test sets
    house = 'House_' + str(house_nr)
    x = data_ook.drop(house,axis=1).values.astype(np.float)
    y = data_ook[house].values
    
    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
    
    # fit random forest model
    model = RandomForestRegressor(n_estimators=500, max_features=x_train.shape[1], random_state=rng, oob_score=True, n_jobs=-1)
    results = model.fit(X=x_train, y=y_train)
    fit = model.predict(x_train)
    
    # create importance scores per variable
    DayOfMonth = model.feature_importances_[0:30].sum()
    Hour = model.feature_importances_[30:53].sum()
    WeekDays = model.feature_importances_[53:55].sum()
    Month = model.feature_importances_[55:67].sum()
    t1 = model.feature_importances_[67]
    t24 = model.feature_importances_[68]
    
    # save results from training time
    key= 'House'
    thesaurus[key] = house_nr
    key = 'train_r_squared'
    thesaurus[key] = r2_score(y_true=y_train,y_pred=fit)
    key = 'train_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_train,y_pred=fit))*(len(y_train)-1)/(len(y_train)-x_train.shape[1]-1)
    key = 'train_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mape'
    thesaurus[key] = mape(y_train, fit)
    key = 'train_' + 'stdape'
    thesaurus[key] = stdape(y_train, fit)
    key = 'importance_Month'
    thesaurus[key] = Month
    key = 'importance_DayOfMonth'
    thesaurus[key] = DayOfMonth
    key = 'importance_WeekDays'
    thesaurus[key] = WeekDays
    key = 'importance_Hour'
    thesaurus[key] = Hour
    key = 'importance_t1'
    thesaurus[key] = t1
    key = 'importance_t24'
    thesaurus[key] = t24
   
    
    
    # save results from testing time with rolling forecasting time technique

    predictions = model.predict(x_test)
    
    key = 'test_r_squared'
    thesaurus[key] = r2_score(y_true=y_test,y_pred=predictions)
    key = 'test_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_test,y_pred=predictions))*(len(y_test)-1)/(len(y_test)-x_test.shape[1]-1)
    key = 'test_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mape'
    thesaurus[key] = mape(y_test, predictions)
    key = 'test_' + 'stdape'
    thesaurus[key] = stdape(y_test, predictions)
    key = 'oob_score'
    thesaurus[key] = model.oob_score_
    
    df1  = pd.DataFrame(thesaurus, index=[house_nr])
    all_results = pd.concat([all_results,df1])

In [35]:
all_results


Out[35]:
House importance_DayOfMonth importance_Hour importance_Month importance_WeekDays importance_t1 importance_t24 oob_score test_mae test_mape ... test_r_squared test_r_squared_adj test_stdape train_mae train_mape train_mde train_mse train_r_squared train_r_squared_adj train_stdape
1 1 0.148395 0.162514 0.106953 0.017855 0.347662 0.216622 0.380492 0.118894 32.653053 ... 0.354065 0.334474 37.375745 0.043774 11.869066 0.023086 0.005243 0.916104 0.915273 13.281476
2 2 0.136615 0.147537 0.089838 0.017180 0.456672 0.152157 0.419622 0.160245 53.277753 ... 0.397102 0.375780 71.136417 0.056225 18.708491 0.022617 0.009040 0.920553 0.919638 27.231116
4 4 0.182966 0.206616 0.115910 0.022807 0.211411 0.260291 0.278860 0.080153 27.538026 ... 0.312760 0.290328 28.663037 0.029918 10.540856 0.022721 0.001583 0.902042 0.900999 11.530009
5 5 0.126181 0.150617 0.078654 0.031597 0.472775 0.140176 0.475763 0.184553 28.212842 ... 0.468789 0.452098 26.344670 0.067632 10.662669 0.045038 0.009657 0.928742 0.928012 10.504171
6 6 0.085879 0.098455 0.052208 0.010778 0.643980 0.108700 0.622977 0.074214 16.964757 ... 0.630517 0.617952 18.056870 0.027277 6.307120 0.017329 0.001563 0.948803 0.948236 6.815702
7 7 0.140800 0.140647 0.089709 0.016867 0.416056 0.195921 0.431528 0.167898 42.266122 ... 0.458473 0.441317 58.332500 0.062869 15.713127 0.024646 0.011043 0.922642 0.921843 22.460649
8 8 0.141310 0.181473 0.091047 0.022452 0.282778 0.280940 0.416287 0.177288 39.306105 ... 0.436782 0.417409 45.611289 0.069703 14.864254 0.042120 0.012170 0.920853 0.919966 17.321630
9 9 0.136131 0.133788 0.075626 0.029978 0.464118 0.160360 0.449068 0.177441 42.501021 ... 0.458679 0.440773 62.205622 0.063282 15.642706 0.024545 0.011781 0.925313 0.924508 23.839837
10 10 0.142824 0.148589 0.093238 0.018954 0.421956 0.174440 0.409473 0.194758 36.596399 ... 0.382529 0.362967 41.654548 0.070505 13.227793 0.038670 0.012070 0.920093 0.919267 14.587615
12 12 0.174056 0.155750 0.098665 0.025854 0.355605 0.190070 0.294297 0.106004 36.351046 ... 0.296656 0.273999 42.191125 0.038623 12.981869 0.021341 0.003861 0.904614 0.903611 15.439255
13 13 0.127987 0.146198 0.082560 0.023687 0.444764 0.174804 0.430849 0.131797 26.858914 ... 0.439228 0.417380 40.142875 0.048730 9.822650 0.015313 0.008103 0.922703 0.921724 14.541716
15 15 0.130785 0.135811 0.087365 0.017929 0.468911 0.159199 0.464536 0.034640 14.827627 ... 0.441097 0.423051 15.727384 0.012422 5.221404 0.005893 0.000412 0.927073 0.926305 5.686744
16 16 0.153221 0.148634 0.090191 0.022062 0.431668 0.154224 0.311453 0.140518 31.636187 ... 0.347065 0.324629 32.277611 0.053416 11.740177 0.033133 0.006396 0.906138 0.905087 11.295792
17 17 0.187000 0.158971 0.100439 0.025892 0.307552 0.220146 0.279653 0.107842 29.950338 ... 0.280939 0.257380 33.841902 0.037106 10.859800 0.017007 0.004483 0.902474 0.901431 12.648418
18 18 0.100226 0.109226 0.062634 0.011524 0.559247 0.157143 0.549162 0.055736 13.729965 ... 0.593774 0.579415 18.101956 0.021157 5.249810 0.010931 0.001279 0.938755 0.938050 7.321117
19 19 0.159052 0.147562 0.097929 0.018417 0.418391 0.158648 0.356543 0.060624 23.014900 ... 0.320611 0.298117 21.158383 0.022323 8.467828 0.013405 0.001118 0.912866 0.911925 7.903972
20 20 0.114797 0.130279 0.072005 0.015909 0.409597 0.257414 0.513717 0.063500 19.009514 ... 0.559147 0.544613 20.748322 0.024393 7.346522 0.012067 0.001583 0.934018 0.933308 8.381424

17 rows × 22 columns


In [36]:
all_results.to_csv('results_forest_regression.csv')

XGBoost


In [23]:
houses=[1,2,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20]
thesaurus = {}
all_results=pd.DataFrame()

for house_nr in houses:
    
    #create dummy variables
    data_ook = pd.get_dummies(data_modeling, columns=cols, prefix=cols, drop_first=True)
    #data_ook = pd.get_dummies(data_ook, columns=['Month'], prefix='Month', drop_first=False)
    
    # keep the house you want for modeling
    drop_houses = ['House_'+str(i) for i in houses if i != house_nr]
    data_ook = data_ook.drop(drop_houses, axis=1)
    
    # create lagged predictors
    data_ook['t1'] = data_ook['House_'+str(house_nr)].shift(+1)
    data_ook['t24'] = data_ook['House_'+str(house_nr)].shift(+24)

    # drop nan values
    data_ook = data_ook.dropna(axis=0,how='any')
    
    
    # split train and test sets
    house = 'House_' + str(house_nr)
    x = data_ook.drop(house,axis=1).values.astype(np.float)
    y = data_ook[house].values
    
    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
    
    
    # fit xgboost model
    d_train = xgb.DMatrix(x_train, label=y_train)
    d_test = xgb.DMatrix(x_test,label=y_test)
    
    params = {}
    params['eta'] = 0.02
    params['objective'] = 'reg:linear'
    params['eval_metric'] = 'mae'
    params['max_depth'] = 4
    params['silent'] = 1

    watchlist = [(d_train, 'train'), (d_test, 'valid')]
    model = xgb.train(params, d_train, 1000, watchlist, early_stopping_rounds=100, verbose_eval=10)
    fit = model.predict(d_train)
    predictions = model.predict(d_test)
    
    # create importance scores per variable
    importances = model.get_fscore()
    air_temperature  = importances['f0']
    humidity = importances['f1']
    irradiation = importances['f2']
    rainfall = importances['f3']
    month=0
    for i in range (4,15):
        key = 'f'+str(i)
        if key in importances:
            month += importances[key]
    day_of_month=0
    for i in range(15,45):
        key='f'+str(i)
        if key in importances:
            day_of_month += importances[key]
    hour=0
    for i in range(45,68):
        key='f'+str(i)
        if key in importances:
            hour += importances[key]
    day=0
    for i in range(68,74):
        key='f'+str(i)
        if key in importances:
            day += importances[key]
    t1 = importances['f74']
    t24 = importances['f75']

    # save results from training time
    key= 'House'
    thesaurus[key] = house_nr
    key = 'train_r_squared'
    thesaurus[key] = r2_score(y_true=y_train,y_pred=fit)
    key = 'train_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_train,y_pred=fit))*(len(y_train)-1)/(len(y_train)-x_train.shape[1]-1)
    key = 'train_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_train, y_pred=fit)
    key = 'train_' + 'mape'
    thesaurus[key] = mape(y_train, fit)
    key = 'train_' + 'stdape'
    thesaurus[key] = stdape(y_train, fit)
    key = 'importance_air_temperature'
    thesaurus[key] = air_temperature
    key = 'importance_humidity'
    thesaurus[key] = humidity
    key = 'importance_irradiation'
    thesaurus[key] = irradiation
    key = 'importance_rainfall'
    thesaurus[key] = rainfall
    key = 'importance_Month'
    thesaurus[key] = month
    key = 'importance_DayOfMonth'
    thesaurus[key] = day_of_month
    key = 'importance_WeekDays'
    thesaurus[key] = day
    key = 'importance_Hour'
    thesaurus[key] = hour
    key = 'importance_t1'
    thesaurus[key] = t1
    key = 'importance_t24'
    thesaurus[key] = t24

    
    
    # save results from testing time with rolling forecasting time technique

    #predictions = model.predict(x_test)
    
    key = 'test_r_squared'
    thesaurus[key] = r2_score(y_true=y_test,y_pred=predictions)
    key = 'test_r_squared_adj'
    thesaurus[key] = 1 - (1-r2_score(y_true=y_test,y_pred=predictions))*(len(y_test)-1)/(len(y_test)-x_test.shape[1]-1)
    key = 'test_' + 'mse'
    thesaurus[key] = mean_squared_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mae'
    thesaurus[key] = mean_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mde'
    thesaurus[key] = median_absolute_error(y_true=y_test, y_pred=predictions)
    key = 'test_' + 'mape'
    thesaurus[key] = mape(y_test, predictions)
    key = 'test_' + 'stdape'
    thesaurus[key] = stdape(y_test, predictions)
    
    df1  = pd.DataFrame(thesaurus, index=[house_nr])
    all_results = pd.concat([all_results,df1])


[0]	train-mae:0.244622	valid-mae:0.240576
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.220179	valid-mae:0.216308
[20]	train-mae:0.200774	valid-mae:0.197113
[30]	train-mae:0.185179	valid-mae:0.181645
[40]	train-mae:0.172541	valid-mae:0.169109
[50]	train-mae:0.162384	valid-mae:0.159276
[60]	train-mae:0.153905	valid-mae:0.151174
[70]	train-mae:0.147088	valid-mae:0.14492
[80]	train-mae:0.141514	valid-mae:0.139937
[90]	train-mae:0.136904	valid-mae:0.135803
[100]	train-mae:0.133223	valid-mae:0.132727
[110]	train-mae:0.130032	valid-mae:0.13017
[120]	train-mae:0.127415	valid-mae:0.128133
[130]	train-mae:0.125323	valid-mae:0.126599
[140]	train-mae:0.123568	valid-mae:0.125358
[150]	train-mae:0.122164	valid-mae:0.124445
[160]	train-mae:0.120901	valid-mae:0.123706
[170]	train-mae:0.119769	valid-mae:0.123129
[180]	train-mae:0.118828	valid-mae:0.122704
[190]	train-mae:0.118083	valid-mae:0.122379
[200]	train-mae:0.117438	valid-mae:0.122122
[210]	train-mae:0.116947	valid-mae:0.121996
[220]	train-mae:0.116425	valid-mae:0.121823
[230]	train-mae:0.116	valid-mae:0.121788
[240]	train-mae:0.115563	valid-mae:0.121646
[250]	train-mae:0.115214	valid-mae:0.121573
[260]	train-mae:0.114904	valid-mae:0.121488
[270]	train-mae:0.114624	valid-mae:0.121417
[280]	train-mae:0.114359	valid-mae:0.121381
[290]	train-mae:0.114101	valid-mae:0.121323
[300]	train-mae:0.113861	valid-mae:0.121276
[310]	train-mae:0.113647	valid-mae:0.121229
[320]	train-mae:0.113462	valid-mae:0.121238
[330]	train-mae:0.113239	valid-mae:0.121251
[340]	train-mae:0.113027	valid-mae:0.121189
[350]	train-mae:0.112787	valid-mae:0.121179
[360]	train-mae:0.112569	valid-mae:0.121158
[370]	train-mae:0.112335	valid-mae:0.121139
[380]	train-mae:0.112134	valid-mae:0.121165
[390]	train-mae:0.111924	valid-mae:0.121165
[400]	train-mae:0.111705	valid-mae:0.121145
[410]	train-mae:0.111446	valid-mae:0.121152
[420]	train-mae:0.11122	valid-mae:0.121135
[430]	train-mae:0.110993	valid-mae:0.121106
[440]	train-mae:0.110742	valid-mae:0.121078
[450]	train-mae:0.110479	valid-mae:0.121078
[460]	train-mae:0.11026	valid-mae:0.121068
[470]	train-mae:0.110063	valid-mae:0.121056
[480]	train-mae:0.109843	valid-mae:0.121057
[490]	train-mae:0.109612	valid-mae:0.12104
[500]	train-mae:0.109367	valid-mae:0.120981
[510]	train-mae:0.109138	valid-mae:0.120958
[520]	train-mae:0.108917	valid-mae:0.120988
[530]	train-mae:0.108665	valid-mae:0.121006
[540]	train-mae:0.108465	valid-mae:0.121009
[550]	train-mae:0.108251	valid-mae:0.121064
[560]	train-mae:0.10799	valid-mae:0.121074
[570]	train-mae:0.107815	valid-mae:0.121084
[580]	train-mae:0.107599	valid-mae:0.121095
[590]	train-mae:0.107376	valid-mae:0.121118
[600]	train-mae:0.107213	valid-mae:0.121135
[610]	train-mae:0.10702	valid-mae:0.121163
Stopping. Best iteration:
[510]	train-mae:0.109138	valid-mae:0.120958

[0]	train-mae:0.32439	valid-mae:0.325649
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.289879	valid-mae:0.293403
[20]	train-mae:0.262256	valid-mae:0.26769
[30]	train-mae:0.239798	valid-mae:0.247052
[40]	train-mae:0.221725	valid-mae:0.230543
[50]	train-mae:0.207146	valid-mae:0.217188
[60]	train-mae:0.195234	valid-mae:0.206239
[70]	train-mae:0.185537	valid-mae:0.197433
[80]	train-mae:0.177749	valid-mae:0.190385
[90]	train-mae:0.171462	valid-mae:0.184727
[100]	train-mae:0.166114	valid-mae:0.179839
[110]	train-mae:0.161611	valid-mae:0.175877
[120]	train-mae:0.157926	valid-mae:0.172917
[130]	train-mae:0.154907	valid-mae:0.170591
[140]	train-mae:0.152344	valid-mae:0.168652
[150]	train-mae:0.150217	valid-mae:0.167091
[160]	train-mae:0.148462	valid-mae:0.165972
[170]	train-mae:0.14699	valid-mae:0.165024
[180]	train-mae:0.145907	valid-mae:0.164352
[190]	train-mae:0.145061	valid-mae:0.163945
[200]	train-mae:0.144291	valid-mae:0.163665
[210]	train-mae:0.143622	valid-mae:0.163316
[220]	train-mae:0.143042	valid-mae:0.163064
[230]	train-mae:0.142579	valid-mae:0.162859
[240]	train-mae:0.142079	valid-mae:0.162649
[250]	train-mae:0.141703	valid-mae:0.162546
[260]	train-mae:0.141331	valid-mae:0.162461
[270]	train-mae:0.140943	valid-mae:0.162389
[280]	train-mae:0.140553	valid-mae:0.162296
[290]	train-mae:0.140224	valid-mae:0.162258
[300]	train-mae:0.139901	valid-mae:0.162143
[310]	train-mae:0.139605	valid-mae:0.162103
[320]	train-mae:0.139345	valid-mae:0.162059
[330]	train-mae:0.139036	valid-mae:0.162027
[340]	train-mae:0.138827	valid-mae:0.162038
[350]	train-mae:0.138585	valid-mae:0.162043
[360]	train-mae:0.138287	valid-mae:0.16199
[370]	train-mae:0.138036	valid-mae:0.161989
[380]	train-mae:0.137733	valid-mae:0.161936
[390]	train-mae:0.137533	valid-mae:0.16193
[400]	train-mae:0.137299	valid-mae:0.161885
[410]	train-mae:0.137107	valid-mae:0.161895
[420]	train-mae:0.136799	valid-mae:0.161893
[430]	train-mae:0.136586	valid-mae:0.161903
[440]	train-mae:0.13634	valid-mae:0.161858
[450]	train-mae:0.136042	valid-mae:0.161814
[460]	train-mae:0.135792	valid-mae:0.161809
[470]	train-mae:0.135495	valid-mae:0.16177
[480]	train-mae:0.135242	valid-mae:0.161763
[490]	train-mae:0.134941	valid-mae:0.16174
[500]	train-mae:0.134686	valid-mae:0.161718
[510]	train-mae:0.134395	valid-mae:0.16169
[520]	train-mae:0.134102	valid-mae:0.161722
[530]	train-mae:0.133836	valid-mae:0.161732
[540]	train-mae:0.13356	valid-mae:0.161776
[550]	train-mae:0.133275	valid-mae:0.161803
[560]	train-mae:0.133014	valid-mae:0.161803
[570]	train-mae:0.132775	valid-mae:0.161862
[580]	train-mae:0.132519	valid-mae:0.161861
[590]	train-mae:0.1323	valid-mae:0.161903
[600]	train-mae:0.132053	valid-mae:0.161991
[610]	train-mae:0.131794	valid-mae:0.161989
Stopping. Best iteration:
[510]	train-mae:0.134395	valid-mae:0.16169

[0]	train-mae:0.189748	valid-mae:0.191167
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.16373	valid-mae:0.164749
[20]	train-mae:0.143756	valid-mae:0.144399
[30]	train-mae:0.128619	valid-mae:0.128859
[40]	train-mae:0.117107	valid-mae:0.117426
[50]	train-mae:0.10827	valid-mae:0.108784
[60]	train-mae:0.101629	valid-mae:0.102264
[70]	train-mae:0.096627	valid-mae:0.097371
[80]	train-mae:0.092823	valid-mae:0.093703
[90]	train-mae:0.089921	valid-mae:0.090984
[100]	train-mae:0.087624	valid-mae:0.088842
[110]	train-mae:0.085864	valid-mae:0.087242
[120]	train-mae:0.084468	valid-mae:0.085963
[130]	train-mae:0.083308	valid-mae:0.084917
[140]	train-mae:0.082402	valid-mae:0.084137
[150]	train-mae:0.081629	valid-mae:0.083487
[160]	train-mae:0.08096	valid-mae:0.082942
[170]	train-mae:0.080414	valid-mae:0.082498
[180]	train-mae:0.079925	valid-mae:0.082114
[190]	train-mae:0.079471	valid-mae:0.081776
[200]	train-mae:0.079079	valid-mae:0.081503
[210]	train-mae:0.078692	valid-mae:0.081284
[220]	train-mae:0.078356	valid-mae:0.081072
[230]	train-mae:0.078027	valid-mae:0.080877
[240]	train-mae:0.077712	valid-mae:0.080717
[250]	train-mae:0.077424	valid-mae:0.080543
[260]	train-mae:0.077155	valid-mae:0.08038
[270]	train-mae:0.076893	valid-mae:0.080251
[280]	train-mae:0.076637	valid-mae:0.080137
[290]	train-mae:0.076379	valid-mae:0.08002
[300]	train-mae:0.076161	valid-mae:0.079932
[310]	train-mae:0.075963	valid-mae:0.079862
[320]	train-mae:0.07577	valid-mae:0.079797
[330]	train-mae:0.075573	valid-mae:0.079734
[340]	train-mae:0.07539	valid-mae:0.079692
[350]	train-mae:0.075202	valid-mae:0.07964
[360]	train-mae:0.075039	valid-mae:0.079608
[370]	train-mae:0.07487	valid-mae:0.079569
[380]	train-mae:0.074692	valid-mae:0.079528
[390]	train-mae:0.074503	valid-mae:0.079479
[400]	train-mae:0.074342	valid-mae:0.079462
[410]	train-mae:0.074182	valid-mae:0.079442
[420]	train-mae:0.074025	valid-mae:0.079408
[430]	train-mae:0.073884	valid-mae:0.079367
[440]	train-mae:0.073719	valid-mae:0.079366
[450]	train-mae:0.073586	valid-mae:0.079344
[460]	train-mae:0.073438	valid-mae:0.079327
[470]	train-mae:0.07332	valid-mae:0.079304
[480]	train-mae:0.073165	valid-mae:0.07927
[490]	train-mae:0.07303	valid-mae:0.079237
[500]	train-mae:0.072908	valid-mae:0.07923
[510]	train-mae:0.072762	valid-mae:0.079202
[520]	train-mae:0.072648	valid-mae:0.079176
[530]	train-mae:0.072489	valid-mae:0.079148
[540]	train-mae:0.07236	valid-mae:0.079149
[550]	train-mae:0.07223	valid-mae:0.079134
[560]	train-mae:0.072097	valid-mae:0.079124
[570]	train-mae:0.071972	valid-mae:0.079125
[580]	train-mae:0.071845	valid-mae:0.079115
[590]	train-mae:0.071712	valid-mae:0.079096
[600]	train-mae:0.071596	valid-mae:0.07907
[610]	train-mae:0.071502	valid-mae:0.079068
[620]	train-mae:0.071366	valid-mae:0.079051
[630]	train-mae:0.071255	valid-mae:0.079036
[640]	train-mae:0.071143	valid-mae:0.079016
[650]	train-mae:0.071036	valid-mae:0.078989
[660]	train-mae:0.070898	valid-mae:0.078988
[670]	train-mae:0.070779	valid-mae:0.078968
[680]	train-mae:0.070662	valid-mae:0.078971
[690]	train-mae:0.07056	valid-mae:0.07896
[700]	train-mae:0.07042	valid-mae:0.078966
[710]	train-mae:0.070331	valid-mae:0.078968
[720]	train-mae:0.070189	valid-mae:0.078936
[730]	train-mae:0.07009	valid-mae:0.07892
[740]	train-mae:0.069968	valid-mae:0.078929
[750]	train-mae:0.069859	valid-mae:0.07891
[760]	train-mae:0.069764	valid-mae:0.078903
[770]	train-mae:0.069643	valid-mae:0.078898
[780]	train-mae:0.069532	valid-mae:0.078898
[790]	train-mae:0.069427	valid-mae:0.078883
[800]	train-mae:0.069318	valid-mae:0.078868
[810]	train-mae:0.069211	valid-mae:0.078848
[820]	train-mae:0.069089	valid-mae:0.07883
[830]	train-mae:0.069007	valid-mae:0.078835
[840]	train-mae:0.068897	valid-mae:0.078802
[850]	train-mae:0.068795	valid-mae:0.078801
[860]	train-mae:0.068699	valid-mae:0.07881
[870]	train-mae:0.068599	valid-mae:0.078801
[880]	train-mae:0.068467	valid-mae:0.078787
[890]	train-mae:0.068352	valid-mae:0.078768
[900]	train-mae:0.068247	valid-mae:0.078758
[910]	train-mae:0.068142	valid-mae:0.078759
[920]	train-mae:0.068048	valid-mae:0.078753
[930]	train-mae:0.067943	valid-mae:0.078732
[940]	train-mae:0.067846	valid-mae:0.078729
[950]	train-mae:0.067732	valid-mae:0.078711
[960]	train-mae:0.067638	valid-mae:0.078704
[970]	train-mae:0.067544	valid-mae:0.078693
[980]	train-mae:0.067429	valid-mae:0.078679
[990]	train-mae:0.067332	valid-mae:0.078668
[0]	train-mae:0.280719	valid-mae:0.279131
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.255257	valid-mae:0.254232
[20]	train-mae:0.237206	valid-mae:0.236898
[30]	train-mae:0.224512	valid-mae:0.225252
[40]	train-mae:0.215323	valid-mae:0.216709
[50]	train-mae:0.20868	valid-mae:0.210638
[60]	train-mae:0.203776	valid-mae:0.206182
[70]	train-mae:0.200153	valid-mae:0.202966
[80]	train-mae:0.197246	valid-mae:0.200448
[90]	train-mae:0.19506	valid-mae:0.198691
[100]	train-mae:0.193333	valid-mae:0.197232
[110]	train-mae:0.191863	valid-mae:0.196094
[120]	train-mae:0.190457	valid-mae:0.195192
[130]	train-mae:0.18926	valid-mae:0.194524
[140]	train-mae:0.188096	valid-mae:0.193793
[150]	train-mae:0.187079	valid-mae:0.193189
[160]	train-mae:0.186194	valid-mae:0.192679
[170]	train-mae:0.185324	valid-mae:0.192238
[180]	train-mae:0.184557	valid-mae:0.191903
[190]	train-mae:0.183783	valid-mae:0.191592
[200]	train-mae:0.183082	valid-mae:0.191366
[210]	train-mae:0.182293	valid-mae:0.190983
[220]	train-mae:0.18161	valid-mae:0.1907
[230]	train-mae:0.180939	valid-mae:0.190416
[240]	train-mae:0.180331	valid-mae:0.190141
[250]	train-mae:0.179679	valid-mae:0.18983
[260]	train-mae:0.179038	valid-mae:0.189499
[270]	train-mae:0.178466	valid-mae:0.189313
[280]	train-mae:0.177952	valid-mae:0.189166
[290]	train-mae:0.177476	valid-mae:0.189097
[300]	train-mae:0.176945	valid-mae:0.188947
[310]	train-mae:0.176511	valid-mae:0.188934
[320]	train-mae:0.176051	valid-mae:0.188772
[330]	train-mae:0.175659	valid-mae:0.188695
[340]	train-mae:0.175216	valid-mae:0.188575
[350]	train-mae:0.174822	valid-mae:0.188501
[360]	train-mae:0.174488	valid-mae:0.188434
[370]	train-mae:0.174132	valid-mae:0.188382
[380]	train-mae:0.173829	valid-mae:0.188359
[390]	train-mae:0.173511	valid-mae:0.188367
[400]	train-mae:0.173158	valid-mae:0.188267
[410]	train-mae:0.172821	valid-mae:0.188248
[420]	train-mae:0.172503	valid-mae:0.188244
[430]	train-mae:0.172195	valid-mae:0.188266
[440]	train-mae:0.171927	valid-mae:0.188242
[450]	train-mae:0.171634	valid-mae:0.188218
[460]	train-mae:0.171303	valid-mae:0.188179
[470]	train-mae:0.171024	valid-mae:0.188155
[480]	train-mae:0.170771	valid-mae:0.188124
[490]	train-mae:0.170457	valid-mae:0.188079
[500]	train-mae:0.170215	valid-mae:0.188062
[510]	train-mae:0.169946	valid-mae:0.188016
[520]	train-mae:0.169694	valid-mae:0.188003
[530]	train-mae:0.1694	valid-mae:0.187979
[540]	train-mae:0.169144	valid-mae:0.187985
[550]	train-mae:0.168899	valid-mae:0.187947
[560]	train-mae:0.168663	valid-mae:0.187928
[570]	train-mae:0.168422	valid-mae:0.187885
[580]	train-mae:0.16816	valid-mae:0.187897
[590]	train-mae:0.167921	valid-mae:0.187827
[600]	train-mae:0.16768	valid-mae:0.187867
[610]	train-mae:0.167381	valid-mae:0.187782
[620]	train-mae:0.167155	valid-mae:0.1878
[630]	train-mae:0.166905	valid-mae:0.187756
[640]	train-mae:0.16662	valid-mae:0.187697
[650]	train-mae:0.16642	valid-mae:0.187709
[660]	train-mae:0.166132	valid-mae:0.187668
[670]	train-mae:0.165823	valid-mae:0.187557
[680]	train-mae:0.165507	valid-mae:0.187586
[690]	train-mae:0.165277	valid-mae:0.187567
[700]	train-mae:0.165008	valid-mae:0.187611
[710]	train-mae:0.164749	valid-mae:0.187592
[720]	train-mae:0.164482	valid-mae:0.187594
[730]	train-mae:0.164211	valid-mae:0.187587
[740]	train-mae:0.163963	valid-mae:0.187566
[750]	train-mae:0.163697	valid-mae:0.187546
[760]	train-mae:0.163466	valid-mae:0.187547
[770]	train-mae:0.163152	valid-mae:0.187528
[780]	train-mae:0.162838	valid-mae:0.187568
[790]	train-mae:0.162529	valid-mae:0.18752
[800]	train-mae:0.162215	valid-mae:0.187577
[810]	train-mae:0.161978	valid-mae:0.187573
[820]	train-mae:0.161752	valid-mae:0.187555
[830]	train-mae:0.161425	valid-mae:0.187508
[840]	train-mae:0.161189	valid-mae:0.187529
[850]	train-mae:0.160874	valid-mae:0.187506
[860]	train-mae:0.160514	valid-mae:0.187483
[870]	train-mae:0.160204	valid-mae:0.187463
[880]	train-mae:0.159981	valid-mae:0.187527
[890]	train-mae:0.159718	valid-mae:0.187514
[900]	train-mae:0.15949	valid-mae:0.187512
[910]	train-mae:0.159247	valid-mae:0.187502
[920]	train-mae:0.158985	valid-mae:0.187494
[930]	train-mae:0.158727	valid-mae:0.187461
[940]	train-mae:0.1585	valid-mae:0.187455
[950]	train-mae:0.158298	valid-mae:0.187482
[960]	train-mae:0.15808	valid-mae:0.187454
[970]	train-mae:0.157892	valid-mae:0.187488
[980]	train-mae:0.157653	valid-mae:0.187462
[990]	train-mae:0.157436	valid-mae:0.187445
[0]	train-mae:0.165977	valid-mae:0.168256
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.146407	valid-mae:0.148909
[20]	train-mae:0.13094	valid-mae:0.133604
[30]	train-mae:0.118736	valid-mae:0.121456
[40]	train-mae:0.109042	valid-mae:0.111835
[50]	train-mae:0.101288	valid-mae:0.104115
[60]	train-mae:0.095038	valid-mae:0.09792
[70]	train-mae:0.090001	valid-mae:0.092959
[80]	train-mae:0.085957	valid-mae:0.088965
[90]	train-mae:0.082695	valid-mae:0.085769
[100]	train-mae:0.080053	valid-mae:0.083196
[110]	train-mae:0.077957	valid-mae:0.08117
[120]	train-mae:0.076265	valid-mae:0.079562
[130]	train-mae:0.074829	valid-mae:0.07826
[140]	train-mae:0.073696	valid-mae:0.077226
[150]	train-mae:0.072746	valid-mae:0.076363
[160]	train-mae:0.071973	valid-mae:0.075663
[170]	train-mae:0.071339	valid-mae:0.075117
[180]	train-mae:0.07079	valid-mae:0.074664
[190]	train-mae:0.070341	valid-mae:0.074336
[200]	train-mae:0.069956	valid-mae:0.07407
[210]	train-mae:0.069638	valid-mae:0.073868
[220]	train-mae:0.069304	valid-mae:0.073642
[230]	train-mae:0.069027	valid-mae:0.073516
[240]	train-mae:0.068764	valid-mae:0.073405
[250]	train-mae:0.068526	valid-mae:0.073329
[260]	train-mae:0.068309	valid-mae:0.073264
[270]	train-mae:0.0681	valid-mae:0.073196
[280]	train-mae:0.067912	valid-mae:0.073146
[290]	train-mae:0.067723	valid-mae:0.073084
[300]	train-mae:0.067552	valid-mae:0.073047
[310]	train-mae:0.067374	valid-mae:0.072985
[320]	train-mae:0.067217	valid-mae:0.07296
[330]	train-mae:0.067077	valid-mae:0.072923
[340]	train-mae:0.066896	valid-mae:0.072886
[350]	train-mae:0.066768	valid-mae:0.072864
[360]	train-mae:0.066623	valid-mae:0.072845
[370]	train-mae:0.066456	valid-mae:0.072815
[380]	train-mae:0.066322	valid-mae:0.072783
[390]	train-mae:0.066164	valid-mae:0.072729
[400]	train-mae:0.066051	valid-mae:0.072716
[410]	train-mae:0.06592	valid-mae:0.072702
[420]	train-mae:0.065794	valid-mae:0.072682
[430]	train-mae:0.065657	valid-mae:0.072663
[440]	train-mae:0.065528	valid-mae:0.072659
[450]	train-mae:0.065386	valid-mae:0.072646
[460]	train-mae:0.065258	valid-mae:0.072644
[470]	train-mae:0.065149	valid-mae:0.072663
[480]	train-mae:0.065018	valid-mae:0.072651
[490]	train-mae:0.064901	valid-mae:0.072674
[500]	train-mae:0.064787	valid-mae:0.072676
[510]	train-mae:0.064657	valid-mae:0.072658
[520]	train-mae:0.064547	valid-mae:0.072664
[530]	train-mae:0.064442	valid-mae:0.07268
[540]	train-mae:0.064327	valid-mae:0.072672
Stopping. Best iteration:
[448]	train-mae:0.065414	valid-mae:0.072634

[0]	train-mae:0.33024	valid-mae:0.338229
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.297649	valid-mae:0.305944
[20]	train-mae:0.271947	valid-mae:0.280451
[30]	train-mae:0.251308	valid-mae:0.260165
[40]	train-mae:0.2349	valid-mae:0.244274
[50]	train-mae:0.221566	valid-mae:0.231151
[60]	train-mae:0.210559	valid-mae:0.220198
[70]	train-mae:0.201568	valid-mae:0.211326
[80]	train-mae:0.194194	valid-mae:0.204286
[90]	train-mae:0.188084	valid-mae:0.198465
[100]	train-mae:0.182927	valid-mae:0.193543
[110]	train-mae:0.178734	valid-mae:0.189656
[120]	train-mae:0.175182	valid-mae:0.186444
[130]	train-mae:0.172295	valid-mae:0.184027
[140]	train-mae:0.169865	valid-mae:0.182026
[150]	train-mae:0.167799	valid-mae:0.180373
[160]	train-mae:0.16597	valid-mae:0.178903
[170]	train-mae:0.164382	valid-mae:0.177712
[180]	train-mae:0.163102	valid-mae:0.176729
[190]	train-mae:0.16203	valid-mae:0.175918
[200]	train-mae:0.16102	valid-mae:0.175203
[210]	train-mae:0.160109	valid-mae:0.174636
[220]	train-mae:0.159353	valid-mae:0.174124
[230]	train-mae:0.158736	valid-mae:0.173813
[240]	train-mae:0.158149	valid-mae:0.173516
[250]	train-mae:0.157639	valid-mae:0.173251
[260]	train-mae:0.157127	valid-mae:0.173031
[270]	train-mae:0.156639	valid-mae:0.172781
[280]	train-mae:0.156153	valid-mae:0.172541
[290]	train-mae:0.155687	valid-mae:0.17235
[300]	train-mae:0.155291	valid-mae:0.172245
[310]	train-mae:0.1549	valid-mae:0.172071
[320]	train-mae:0.154505	valid-mae:0.171948
[330]	train-mae:0.154145	valid-mae:0.171839
[340]	train-mae:0.153843	valid-mae:0.171818
[350]	train-mae:0.153541	valid-mae:0.171745
[360]	train-mae:0.15325	valid-mae:0.171653
[370]	train-mae:0.152931	valid-mae:0.171598
[380]	train-mae:0.152631	valid-mae:0.171559
[390]	train-mae:0.152339	valid-mae:0.171519
[400]	train-mae:0.152031	valid-mae:0.171446
[410]	train-mae:0.151745	valid-mae:0.171438
[420]	train-mae:0.15148	valid-mae:0.171435
[430]	train-mae:0.151089	valid-mae:0.17141
[440]	train-mae:0.150811	valid-mae:0.171347
[450]	train-mae:0.150536	valid-mae:0.171331
[460]	train-mae:0.150243	valid-mae:0.171285
[470]	train-mae:0.149899	valid-mae:0.171308
[480]	train-mae:0.149587	valid-mae:0.17128
[490]	train-mae:0.149252	valid-mae:0.171323
[500]	train-mae:0.148981	valid-mae:0.171326
[510]	train-mae:0.148674	valid-mae:0.171357
[520]	train-mae:0.148317	valid-mae:0.171436
[530]	train-mae:0.148031	valid-mae:0.171495
[540]	train-mae:0.147697	valid-mae:0.171529
[550]	train-mae:0.147408	valid-mae:0.171505
[560]	train-mae:0.147047	valid-mae:0.171553
[570]	train-mae:0.146754	valid-mae:0.17157
[580]	train-mae:0.146428	valid-mae:0.171551
Stopping. Best iteration:
[481]	train-mae:0.149553	valid-mae:0.171267

[0]	train-mae:0.274885	valid-mae:0.26676
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.257854	valid-mae:0.251186
[20]	train-mae:0.244164	valid-mae:0.238032
[30]	train-mae:0.233594	valid-mae:0.228168
[40]	train-mae:0.225092	valid-mae:0.220326
[50]	train-mae:0.218396	valid-mae:0.21446
[60]	train-mae:0.213125	valid-mae:0.209826
[70]	train-mae:0.208793	valid-mae:0.20608
[80]	train-mae:0.205024	valid-mae:0.20287
[90]	train-mae:0.201767	valid-mae:0.20011
[100]	train-mae:0.198981	valid-mae:0.197922
[110]	train-mae:0.196429	valid-mae:0.195877
[120]	train-mae:0.194201	valid-mae:0.194174
[130]	train-mae:0.19227	valid-mae:0.192865
[140]	train-mae:0.190588	valid-mae:0.191797
[150]	train-mae:0.189071	valid-mae:0.190705
[160]	train-mae:0.187691	valid-mae:0.189701
[170]	train-mae:0.1865	valid-mae:0.188762
[180]	train-mae:0.185394	valid-mae:0.188067
[190]	train-mae:0.184408	valid-mae:0.187437
[200]	train-mae:0.183438	valid-mae:0.186808
[210]	train-mae:0.182671	valid-mae:0.186334
[220]	train-mae:0.181908	valid-mae:0.185911
[230]	train-mae:0.18118	valid-mae:0.185574
[240]	train-mae:0.180568	valid-mae:0.185315
[250]	train-mae:0.179891	valid-mae:0.184927
[260]	train-mae:0.179246	valid-mae:0.18461
[270]	train-mae:0.178636	valid-mae:0.18422
[280]	train-mae:0.178078	valid-mae:0.183965
[290]	train-mae:0.177473	valid-mae:0.183671
[300]	train-mae:0.176925	valid-mae:0.183417
[310]	train-mae:0.176417	valid-mae:0.18319
[320]	train-mae:0.175938	valid-mae:0.183012
[330]	train-mae:0.175486	valid-mae:0.182807
[340]	train-mae:0.175012	valid-mae:0.182672
[350]	train-mae:0.174567	valid-mae:0.182546
[360]	train-mae:0.174177	valid-mae:0.182414
[370]	train-mae:0.173802	valid-mae:0.182323
[380]	train-mae:0.173375	valid-mae:0.18226
[390]	train-mae:0.173007	valid-mae:0.182115
[400]	train-mae:0.172661	valid-mae:0.182014
[410]	train-mae:0.172248	valid-mae:0.181928
[420]	train-mae:0.171914	valid-mae:0.181849
[430]	train-mae:0.171499	valid-mae:0.181743
[440]	train-mae:0.171134	valid-mae:0.181725
[450]	train-mae:0.170801	valid-mae:0.181632
[460]	train-mae:0.1704	valid-mae:0.181573
[470]	train-mae:0.170099	valid-mae:0.181502
[480]	train-mae:0.169733	valid-mae:0.181387
[490]	train-mae:0.169372	valid-mae:0.181266
[500]	train-mae:0.169094	valid-mae:0.1812
[510]	train-mae:0.168713	valid-mae:0.181143
[520]	train-mae:0.168328	valid-mae:0.181082
[530]	train-mae:0.167947	valid-mae:0.180979
[540]	train-mae:0.167546	valid-mae:0.180922
[550]	train-mae:0.167178	valid-mae:0.180839
[560]	train-mae:0.16686	valid-mae:0.180829
[570]	train-mae:0.16649	valid-mae:0.180751
[580]	train-mae:0.166208	valid-mae:0.180664
[590]	train-mae:0.165808	valid-mae:0.18064
[600]	train-mae:0.165532	valid-mae:0.180615
[610]	train-mae:0.165213	valid-mae:0.18058
[620]	train-mae:0.164965	valid-mae:0.180545
[630]	train-mae:0.164686	valid-mae:0.180513
[640]	train-mae:0.164358	valid-mae:0.180449
[650]	train-mae:0.164161	valid-mae:0.180464
[660]	train-mae:0.163872	valid-mae:0.180533
[670]	train-mae:0.163605	valid-mae:0.18052
[680]	train-mae:0.1633	valid-mae:0.180513
[690]	train-mae:0.163055	valid-mae:0.180525
[700]	train-mae:0.162777	valid-mae:0.180493
[710]	train-mae:0.162574	valid-mae:0.180517
[720]	train-mae:0.162268	valid-mae:0.180491
[730]	train-mae:0.161984	valid-mae:0.180468
Stopping. Best iteration:
[638]	train-mae:0.164425	valid-mae:0.180396

[0]	train-mae:0.331964	valid-mae:0.33989
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.2984	valid-mae:0.306486
[20]	train-mae:0.271261	valid-mae:0.279792
[30]	train-mae:0.250051	valid-mae:0.258835
[40]	train-mae:0.233645	valid-mae:0.242629
[50]	train-mae:0.220586	valid-mae:0.229868
[60]	train-mae:0.210201	valid-mae:0.219674
[70]	train-mae:0.201829	valid-mae:0.211744
[80]	train-mae:0.194999	valid-mae:0.205349
[90]	train-mae:0.189482	valid-mae:0.200244
[100]	train-mae:0.185032	valid-mae:0.196098
[110]	train-mae:0.18121	valid-mae:0.192529
[120]	train-mae:0.178128	valid-mae:0.189742
[130]	train-mae:0.175483	valid-mae:0.18754
[140]	train-mae:0.173227	valid-mae:0.185759
[150]	train-mae:0.171321	valid-mae:0.184184
[160]	train-mae:0.169645	valid-mae:0.182996
[170]	train-mae:0.168197	valid-mae:0.181959
[180]	train-mae:0.16689	valid-mae:0.181058
[190]	train-mae:0.165751	valid-mae:0.180236
[200]	train-mae:0.16477	valid-mae:0.17962
[210]	train-mae:0.163838	valid-mae:0.17912
[220]	train-mae:0.162951	valid-mae:0.178625
[230]	train-mae:0.16226	valid-mae:0.178301
[240]	train-mae:0.16163	valid-mae:0.17802
[250]	train-mae:0.160957	valid-mae:0.17776
[260]	train-mae:0.160339	valid-mae:0.177493
[270]	train-mae:0.159743	valid-mae:0.177313
[280]	train-mae:0.159191	valid-mae:0.177205
[290]	train-mae:0.158606	valid-mae:0.177005
[300]	train-mae:0.158078	valid-mae:0.176848
[310]	train-mae:0.157559	valid-mae:0.176733
[320]	train-mae:0.157163	valid-mae:0.176773
[330]	train-mae:0.156746	valid-mae:0.176697
[340]	train-mae:0.156425	valid-mae:0.176659
[350]	train-mae:0.156072	valid-mae:0.176587
[360]	train-mae:0.15578	valid-mae:0.176556
[370]	train-mae:0.155457	valid-mae:0.176459
[380]	train-mae:0.155136	valid-mae:0.176349
[390]	train-mae:0.154791	valid-mae:0.176208
[400]	train-mae:0.154512	valid-mae:0.176113
[410]	train-mae:0.154216	valid-mae:0.176075
[420]	train-mae:0.153901	valid-mae:0.176014
[430]	train-mae:0.153585	valid-mae:0.175926
[440]	train-mae:0.153243	valid-mae:0.175851
[450]	train-mae:0.152979	valid-mae:0.175881
[460]	train-mae:0.152667	valid-mae:0.175824
[470]	train-mae:0.152355	valid-mae:0.175784
[480]	train-mae:0.152103	valid-mae:0.175796
[490]	train-mae:0.151786	valid-mae:0.175714
[500]	train-mae:0.151421	valid-mae:0.175602
[510]	train-mae:0.151156	valid-mae:0.17555
[520]	train-mae:0.150916	valid-mae:0.175618
[530]	train-mae:0.15061	valid-mae:0.17555
[540]	train-mae:0.150256	valid-mae:0.175499
[550]	train-mae:0.149922	valid-mae:0.175528
[560]	train-mae:0.149598	valid-mae:0.17547
[570]	train-mae:0.149282	valid-mae:0.175496
[580]	train-mae:0.149024	valid-mae:0.175511
[590]	train-mae:0.148725	valid-mae:0.175442
[600]	train-mae:0.148467	valid-mae:0.175413
[610]	train-mae:0.14819	valid-mae:0.175406
[620]	train-mae:0.147905	valid-mae:0.175404
[630]	train-mae:0.147603	valid-mae:0.175413
[640]	train-mae:0.14735	valid-mae:0.175403
[650]	train-mae:0.147035	valid-mae:0.175367
[660]	train-mae:0.146719	valid-mae:0.175364
[670]	train-mae:0.146351	valid-mae:0.17537
[680]	train-mae:0.146031	valid-mae:0.175361
[690]	train-mae:0.145723	valid-mae:0.175377
[700]	train-mae:0.145422	valid-mae:0.175388
[710]	train-mae:0.14509	valid-mae:0.175435
[720]	train-mae:0.144756	valid-mae:0.175426
[730]	train-mae:0.144448	valid-mae:0.17545
[740]	train-mae:0.144177	valid-mae:0.175468
[750]	train-mae:0.143921	valid-mae:0.17549
[760]	train-mae:0.143673	valid-mae:0.175505
[770]	train-mae:0.143388	valid-mae:0.175508
[780]	train-mae:0.143106	valid-mae:0.175493
Stopping. Best iteration:
[682]	train-mae:0.145982	valid-mae:0.175332

[0]	train-mae:0.285066	valid-mae:0.288629
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.262016	valid-mae:0.265842
[20]	train-mae:0.245284	valid-mae:0.249506
[30]	train-mae:0.23282	valid-mae:0.237659
[40]	train-mae:0.223707	valid-mae:0.228566
[50]	train-mae:0.216861	valid-mae:0.22184
[60]	train-mae:0.211645	valid-mae:0.216672
[70]	train-mae:0.207619	valid-mae:0.212706
[80]	train-mae:0.204369	valid-mae:0.20947
[90]	train-mae:0.20177	valid-mae:0.207002
[100]	train-mae:0.199691	valid-mae:0.205009
[110]	train-mae:0.197952	valid-mae:0.203357
[120]	train-mae:0.196459	valid-mae:0.202046
[130]	train-mae:0.195251	valid-mae:0.200934
[140]	train-mae:0.193905	valid-mae:0.199893
[150]	train-mae:0.192803	valid-mae:0.199129
[160]	train-mae:0.191822	valid-mae:0.198429
[170]	train-mae:0.19106	valid-mae:0.197933
[180]	train-mae:0.190325	valid-mae:0.197417
[190]	train-mae:0.189643	valid-mae:0.197078
[200]	train-mae:0.189078	valid-mae:0.19688
[210]	train-mae:0.188543	valid-mae:0.196698
[220]	train-mae:0.188016	valid-mae:0.196466
[230]	train-mae:0.187484	valid-mae:0.196194
[240]	train-mae:0.186997	valid-mae:0.195942
[250]	train-mae:0.186498	valid-mae:0.195687
[260]	train-mae:0.186059	valid-mae:0.195511
[270]	train-mae:0.185549	valid-mae:0.195307
[280]	train-mae:0.185097	valid-mae:0.195083
[290]	train-mae:0.184736	valid-mae:0.194912
[300]	train-mae:0.184339	valid-mae:0.194805
[310]	train-mae:0.183949	valid-mae:0.194661
[320]	train-mae:0.183521	valid-mae:0.194535
[330]	train-mae:0.183165	valid-mae:0.194432
[340]	train-mae:0.182776	valid-mae:0.194347
[350]	train-mae:0.182424	valid-mae:0.194266
[360]	train-mae:0.182073	valid-mae:0.194162
[370]	train-mae:0.181748	valid-mae:0.194106
[380]	train-mae:0.181407	valid-mae:0.193974
[390]	train-mae:0.181087	valid-mae:0.193928
[400]	train-mae:0.180792	valid-mae:0.193908
[410]	train-mae:0.180533	valid-mae:0.193933
[420]	train-mae:0.180235	valid-mae:0.193883
[430]	train-mae:0.179948	valid-mae:0.193876
[440]	train-mae:0.179682	valid-mae:0.193891
[450]	train-mae:0.179402	valid-mae:0.193913
[460]	train-mae:0.17911	valid-mae:0.193939
[470]	train-mae:0.178799	valid-mae:0.193891
[480]	train-mae:0.178454	valid-mae:0.193848
[490]	train-mae:0.178105	valid-mae:0.193826
[500]	train-mae:0.177735	valid-mae:0.193724
[510]	train-mae:0.177367	valid-mae:0.193681
[520]	train-mae:0.177114	valid-mae:0.193681
[530]	train-mae:0.176825	valid-mae:0.193631
[540]	train-mae:0.176546	valid-mae:0.193604
[550]	train-mae:0.176226	valid-mae:0.193591
[560]	train-mae:0.17589	valid-mae:0.19355
[570]	train-mae:0.175624	valid-mae:0.193571
[580]	train-mae:0.175356	valid-mae:0.193602
[590]	train-mae:0.175018	valid-mae:0.193605
[600]	train-mae:0.174688	valid-mae:0.193629
[610]	train-mae:0.174477	valid-mae:0.193669
[620]	train-mae:0.174148	valid-mae:0.193692
[630]	train-mae:0.173856	valid-mae:0.193696
[640]	train-mae:0.173593	valid-mae:0.193712
[650]	train-mae:0.173337	valid-mae:0.193766
[660]	train-mae:0.173045	valid-mae:0.193742
Stopping. Best iteration:
[560]	train-mae:0.17589	valid-mae:0.19355

[0]	train-mae:0.266715	valid-mae:0.264611
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.233464	valid-mae:0.231926
[20]	train-mae:0.206859	valid-mae:0.205894
[30]	train-mae:0.185714	valid-mae:0.185124
[40]	train-mae:0.168978	valid-mae:0.168752
[50]	train-mae:0.155553	valid-mae:0.155695
[60]	train-mae:0.14487	valid-mae:0.145299
[70]	train-mae:0.136291	valid-mae:0.136931
[80]	train-mae:0.129401	valid-mae:0.130238
[90]	train-mae:0.123757	valid-mae:0.124839
[100]	train-mae:0.119088	valid-mae:0.120438
[110]	train-mae:0.115263	valid-mae:0.116929
[120]	train-mae:0.112073	valid-mae:0.114067
[130]	train-mae:0.109377	valid-mae:0.111778
[140]	train-mae:0.107184	valid-mae:0.109915
[150]	train-mae:0.105351	valid-mae:0.108405
[160]	train-mae:0.103793	valid-mae:0.107159
[170]	train-mae:0.102504	valid-mae:0.106148
[180]	train-mae:0.101403	valid-mae:0.105327
[190]	train-mae:0.100485	valid-mae:0.104707
[200]	train-mae:0.099718	valid-mae:0.104215
[210]	train-mae:0.099017	valid-mae:0.103809
[220]	train-mae:0.098407	valid-mae:0.103539
[230]	train-mae:0.09784	valid-mae:0.103321
[240]	train-mae:0.097367	valid-mae:0.103101
[250]	train-mae:0.096903	valid-mae:0.102951
[260]	train-mae:0.096529	valid-mae:0.102841
[270]	train-mae:0.09618	valid-mae:0.102732
[280]	train-mae:0.095849	valid-mae:0.102686
[290]	train-mae:0.095561	valid-mae:0.102618
[300]	train-mae:0.09529	valid-mae:0.102574
[310]	train-mae:0.095002	valid-mae:0.102515
[320]	train-mae:0.094701	valid-mae:0.10247
[330]	train-mae:0.094453	valid-mae:0.102453
[340]	train-mae:0.094216	valid-mae:0.102434
[350]	train-mae:0.093967	valid-mae:0.102436
[360]	train-mae:0.09373	valid-mae:0.102413
[370]	train-mae:0.093481	valid-mae:0.102399
[380]	train-mae:0.093275	valid-mae:0.102408
[390]	train-mae:0.09306	valid-mae:0.102428
[400]	train-mae:0.092847	valid-mae:0.102456
[410]	train-mae:0.09263	valid-mae:0.102483
[420]	train-mae:0.092414	valid-mae:0.10251
[430]	train-mae:0.092214	valid-mae:0.102506
[440]	train-mae:0.092013	valid-mae:0.10255
[450]	train-mae:0.091854	valid-mae:0.102578
[460]	train-mae:0.091672	valid-mae:0.102585
[470]	train-mae:0.091484	valid-mae:0.10262
Stopping. Best iteration:
[378]	train-mae:0.093323	valid-mae:0.102392

[0]	train-mae:0.253768	valid-mae:0.256633
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.228542	valid-mae:0.232952
[20]	train-mae:0.208762	valid-mae:0.214161
[30]	train-mae:0.193179	valid-mae:0.199309
[40]	train-mae:0.180717	valid-mae:0.187606
[50]	train-mae:0.170619	valid-mae:0.177892
[60]	train-mae:0.162276	valid-mae:0.169996
[70]	train-mae:0.155615	valid-mae:0.163831
[80]	train-mae:0.150182	valid-mae:0.158818
[90]	train-mae:0.145676	valid-mae:0.154667
[100]	train-mae:0.141866	valid-mae:0.151161
[110]	train-mae:0.138664	valid-mae:0.148232
[120]	train-mae:0.136057	valid-mae:0.145955
[130]	train-mae:0.133974	valid-mae:0.144235
[140]	train-mae:0.132247	valid-mae:0.142791
[150]	train-mae:0.130708	valid-mae:0.141654
[160]	train-mae:0.129459	valid-mae:0.140948
[170]	train-mae:0.128345	valid-mae:0.140313
[180]	train-mae:0.12737	valid-mae:0.139785
[190]	train-mae:0.126641	valid-mae:0.139391
[200]	train-mae:0.125992	valid-mae:0.139082
[210]	train-mae:0.12547	valid-mae:0.138844
[220]	train-mae:0.124954	valid-mae:0.138665
[230]	train-mae:0.124419	valid-mae:0.138496
[240]	train-mae:0.123964	valid-mae:0.138389
[250]	train-mae:0.123565	valid-mae:0.138224
[260]	train-mae:0.123205	valid-mae:0.138216
[270]	train-mae:0.122893	valid-mae:0.138175
[280]	train-mae:0.122459	valid-mae:0.138042
[290]	train-mae:0.122026	valid-mae:0.137891
[300]	train-mae:0.121593	valid-mae:0.137824
[310]	train-mae:0.121198	valid-mae:0.137698
[320]	train-mae:0.120811	valid-mae:0.13761
[330]	train-mae:0.12049	valid-mae:0.137635
[340]	train-mae:0.120161	valid-mae:0.137608
[350]	train-mae:0.11987	valid-mae:0.137585
[360]	train-mae:0.119501	valid-mae:0.137508
[370]	train-mae:0.119144	valid-mae:0.137452
[380]	train-mae:0.118808	valid-mae:0.137398
[390]	train-mae:0.118465	valid-mae:0.137215
[400]	train-mae:0.118191	valid-mae:0.137111
[410]	train-mae:0.117914	valid-mae:0.137054
[420]	train-mae:0.117676	valid-mae:0.136933
[430]	train-mae:0.117451	valid-mae:0.136879
[440]	train-mae:0.117231	valid-mae:0.136762
[450]	train-mae:0.116984	valid-mae:0.136706
[460]	train-mae:0.116733	valid-mae:0.136683
[470]	train-mae:0.116551	valid-mae:0.136646
[480]	train-mae:0.116353	valid-mae:0.136715
[490]	train-mae:0.11614	valid-mae:0.13664
[500]	train-mae:0.115895	valid-mae:0.136649
[510]	train-mae:0.115682	valid-mae:0.136627
[520]	train-mae:0.115469	valid-mae:0.136662
[530]	train-mae:0.115202	valid-mae:0.136639
[540]	train-mae:0.114971	valid-mae:0.136654
[550]	train-mae:0.114818	valid-mae:0.136633
[560]	train-mae:0.114559	valid-mae:0.136631
[570]	train-mae:0.114309	valid-mae:0.136658
[580]	train-mae:0.114086	valid-mae:0.13668
[590]	train-mae:0.113831	valid-mae:0.136662
[600]	train-mae:0.113628	valid-mae:0.136649
[610]	train-mae:0.113376	valid-mae:0.136646
[620]	train-mae:0.113179	valid-mae:0.136657
[630]	train-mae:0.112958	valid-mae:0.136674
[640]	train-mae:0.112766	valid-mae:0.136662
Stopping. Best iteration:
[545]	train-mae:0.114882	valid-mae:0.136602

[0]	train-mae:0.279142	valid-mae:0.276554
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.228694	valid-mae:0.22626
[20]	train-mae:0.188192	valid-mae:0.186037
[30]	train-mae:0.155891	valid-mae:0.153985
[40]	train-mae:0.130296	valid-mae:0.128776
[50]	train-mae:0.110218	valid-mae:0.10916
[60]	train-mae:0.094458	valid-mae:0.093986
[70]	train-mae:0.082014	valid-mae:0.081994
[80]	train-mae:0.07216	valid-mae:0.072464
[90]	train-mae:0.064204	valid-mae:0.064865
[100]	train-mae:0.05778	valid-mae:0.058731
[110]	train-mae:0.05262	valid-mae:0.053832
[120]	train-mae:0.048484	valid-mae:0.049972
[130]	train-mae:0.045183	valid-mae:0.046867
[140]	train-mae:0.042557	valid-mae:0.044404
[150]	train-mae:0.040461	valid-mae:0.042466
[160]	train-mae:0.038798	valid-mae:0.04093
[170]	train-mae:0.037476	valid-mae:0.039722
[180]	train-mae:0.036411	valid-mae:0.038767
[190]	train-mae:0.035543	valid-mae:0.038004
[200]	train-mae:0.034841	valid-mae:0.037395
[210]	train-mae:0.034271	valid-mae:0.036902
[220]	train-mae:0.033808	valid-mae:0.036511
[230]	train-mae:0.033418	valid-mae:0.036203
[240]	train-mae:0.033104	valid-mae:0.035961
[250]	train-mae:0.032852	valid-mae:0.035772
[260]	train-mae:0.032626	valid-mae:0.0356
[270]	train-mae:0.032442	valid-mae:0.035462
[280]	train-mae:0.032269	valid-mae:0.03536
[290]	train-mae:0.032124	valid-mae:0.035265
[300]	train-mae:0.031994	valid-mae:0.035179
[310]	train-mae:0.031873	valid-mae:0.035108
[320]	train-mae:0.031749	valid-mae:0.035035
[330]	train-mae:0.03163	valid-mae:0.034979
[340]	train-mae:0.031535	valid-mae:0.034927
[350]	train-mae:0.031441	valid-mae:0.034889
[360]	train-mae:0.031354	valid-mae:0.034849
[370]	train-mae:0.031265	valid-mae:0.034804
[380]	train-mae:0.031164	valid-mae:0.034772
[390]	train-mae:0.031083	valid-mae:0.034739
[400]	train-mae:0.031006	valid-mae:0.034715
[410]	train-mae:0.030933	valid-mae:0.034697
[420]	train-mae:0.030868	valid-mae:0.034682
[430]	train-mae:0.0308	valid-mae:0.034658
[440]	train-mae:0.030725	valid-mae:0.034637
[450]	train-mae:0.030666	valid-mae:0.034627
[460]	train-mae:0.030608	valid-mae:0.034609
[470]	train-mae:0.030556	valid-mae:0.034607
[480]	train-mae:0.030491	valid-mae:0.034588
[490]	train-mae:0.030435	valid-mae:0.034582
[500]	train-mae:0.030375	valid-mae:0.034566
[510]	train-mae:0.030327	valid-mae:0.034565
[520]	train-mae:0.030266	valid-mae:0.034555
[530]	train-mae:0.030214	valid-mae:0.034562
[540]	train-mae:0.030162	valid-mae:0.034564
[550]	train-mae:0.030108	valid-mae:0.034556
[560]	train-mae:0.030057	valid-mae:0.034566
[570]	train-mae:0.029998	valid-mae:0.034551
[580]	train-mae:0.02994	valid-mae:0.034544
[590]	train-mae:0.029888	valid-mae:0.034557
[600]	train-mae:0.029836	valid-mae:0.034566
[610]	train-mae:0.029775	valid-mae:0.034566
[620]	train-mae:0.029719	valid-mae:0.034577
[630]	train-mae:0.029662	valid-mae:0.034577
[640]	train-mae:0.029608	valid-mae:0.03459
[650]	train-mae:0.029559	valid-mae:0.034596
[660]	train-mae:0.029501	valid-mae:0.034601
[670]	train-mae:0.029441	valid-mae:0.034603
[680]	train-mae:0.029371	valid-mae:0.034599
Stopping. Best iteration:
[580]	train-mae:0.02994	valid-mae:0.034544

[0]	train-mae:0.2059	valid-mae:0.2054
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.19129	valid-mae:0.191856
[20]	train-mae:0.180116	valid-mae:0.181615
[30]	train-mae:0.171456	valid-mae:0.173861
[40]	train-mae:0.164735	valid-mae:0.168015
[50]	train-mae:0.159546	valid-mae:0.163618
[60]	train-mae:0.155344	valid-mae:0.160233
[70]	train-mae:0.151956	valid-mae:0.157517
[80]	train-mae:0.149225	valid-mae:0.155368
[90]	train-mae:0.146966	valid-mae:0.153759
[100]	train-mae:0.14508	valid-mae:0.152448
[110]	train-mae:0.143506	valid-mae:0.151379
[120]	train-mae:0.142191	valid-mae:0.15061
[130]	train-mae:0.141071	valid-mae:0.150018
[140]	train-mae:0.14002	valid-mae:0.149502
[150]	train-mae:0.139052	valid-mae:0.149071
[160]	train-mae:0.138166	valid-mae:0.148677
[170]	train-mae:0.137478	valid-mae:0.148429
[180]	train-mae:0.136846	valid-mae:0.148164
[190]	train-mae:0.136265	valid-mae:0.147952
[200]	train-mae:0.135762	valid-mae:0.147774
[210]	train-mae:0.135269	valid-mae:0.14755
[220]	train-mae:0.13487	valid-mae:0.147423
[230]	train-mae:0.134424	valid-mae:0.147261
[240]	train-mae:0.134071	valid-mae:0.147128
[250]	train-mae:0.133648	valid-mae:0.146989
[260]	train-mae:0.133311	valid-mae:0.146917
[270]	train-mae:0.133005	valid-mae:0.146824
[280]	train-mae:0.132635	valid-mae:0.14673
[290]	train-mae:0.132318	valid-mae:0.146672
[300]	train-mae:0.131938	valid-mae:0.146634
[310]	train-mae:0.131608	valid-mae:0.146598
[320]	train-mae:0.131358	valid-mae:0.14654
[330]	train-mae:0.131053	valid-mae:0.146489
[340]	train-mae:0.130793	valid-mae:0.146468
[350]	train-mae:0.130496	valid-mae:0.146444
[360]	train-mae:0.130241	valid-mae:0.146399
[370]	train-mae:0.129966	valid-mae:0.146386
[380]	train-mae:0.12969	valid-mae:0.146394
[390]	train-mae:0.129428	valid-mae:0.146381
[400]	train-mae:0.129174	valid-mae:0.146368
[410]	train-mae:0.128905	valid-mae:0.146362
[420]	train-mae:0.128625	valid-mae:0.146345
[430]	train-mae:0.128401	valid-mae:0.146369
[440]	train-mae:0.128151	valid-mae:0.1464
[450]	train-mae:0.127941	valid-mae:0.146398
[460]	train-mae:0.1277	valid-mae:0.146434
[470]	train-mae:0.127436	valid-mae:0.146456
[480]	train-mae:0.127186	valid-mae:0.146458
[490]	train-mae:0.126995	valid-mae:0.146474
[500]	train-mae:0.126751	valid-mae:0.146477
[510]	train-mae:0.126516	valid-mae:0.146508
[520]	train-mae:0.126273	valid-mae:0.146547
Stopping. Best iteration:
[421]	train-mae:0.12861	valid-mae:0.146335

[0]	train-mae:0.260521	valid-mae:0.257053
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.228932	valid-mae:0.226498
[20]	train-mae:0.20353	valid-mae:0.201882
[30]	train-mae:0.183013	valid-mae:0.182234
[40]	train-mae:0.166439	valid-mae:0.166588
[50]	train-mae:0.15306	valid-mae:0.154095
[60]	train-mae:0.142256	valid-mae:0.144177
[70]	train-mae:0.133541	valid-mae:0.136217
[80]	train-mae:0.126521	valid-mae:0.12989
[90]	train-mae:0.120868	valid-mae:0.124934
[100]	train-mae:0.116194	valid-mae:0.120949
[110]	train-mae:0.112357	valid-mae:0.117782
[120]	train-mae:0.109282	valid-mae:0.115335
[130]	train-mae:0.106749	valid-mae:0.113348
[140]	train-mae:0.104725	valid-mae:0.111738
[150]	train-mae:0.103081	valid-mae:0.110571
[160]	train-mae:0.101749	valid-mae:0.109696
[170]	train-mae:0.100632	valid-mae:0.109001
[180]	train-mae:0.099764	valid-mae:0.108461
[190]	train-mae:0.099022	valid-mae:0.108021
[200]	train-mae:0.098374	valid-mae:0.10763
[210]	train-mae:0.097784	valid-mae:0.107267
[220]	train-mae:0.097277	valid-mae:0.107061
[230]	train-mae:0.096789	valid-mae:0.106845
[240]	train-mae:0.096363	valid-mae:0.106754
[250]	train-mae:0.095994	valid-mae:0.106657
[260]	train-mae:0.095648	valid-mae:0.106567
[270]	train-mae:0.095289	valid-mae:0.106471
[280]	train-mae:0.094941	valid-mae:0.106372
[290]	train-mae:0.09462	valid-mae:0.106336
[300]	train-mae:0.094374	valid-mae:0.106319
[310]	train-mae:0.094131	valid-mae:0.10632
[320]	train-mae:0.093908	valid-mae:0.106283
[330]	train-mae:0.093679	valid-mae:0.106228
[340]	train-mae:0.093432	valid-mae:0.106178
[350]	train-mae:0.093166	valid-mae:0.106109
[360]	train-mae:0.09295	valid-mae:0.106094
[370]	train-mae:0.092708	valid-mae:0.106064
[380]	train-mae:0.092496	valid-mae:0.10605
[390]	train-mae:0.092352	valid-mae:0.106066
[400]	train-mae:0.092178	valid-mae:0.106067
[410]	train-mae:0.092037	valid-mae:0.106057
[420]	train-mae:0.091837	valid-mae:0.106046
[430]	train-mae:0.091664	valid-mae:0.106026
[440]	train-mae:0.091512	valid-mae:0.106021
[450]	train-mae:0.091369	valid-mae:0.106018
[460]	train-mae:0.091205	valid-mae:0.106021
[470]	train-mae:0.090972	valid-mae:0.10603
[480]	train-mae:0.090792	valid-mae:0.106006
[490]	train-mae:0.090595	valid-mae:0.106025
[500]	train-mae:0.090429	valid-mae:0.106027
[510]	train-mae:0.090258	valid-mae:0.106039
[520]	train-mae:0.090095	valid-mae:0.106034
[530]	train-mae:0.089876	valid-mae:0.106051
[540]	train-mae:0.089656	valid-mae:0.106018
[550]	train-mae:0.089516	valid-mae:0.106007
[560]	train-mae:0.089323	valid-mae:0.106013
[570]	train-mae:0.08914	valid-mae:0.106047
[580]	train-mae:0.088964	valid-mae:0.106053
Stopping. Best iteration:
[483]	train-mae:0.090709	valid-mae:0.105997

[0]	train-mae:0.163177	valid-mae:0.163467
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.141134	valid-mae:0.14146
[20]	train-mae:0.123342	valid-mae:0.123744
[30]	train-mae:0.108966	valid-mae:0.10957
[40]	train-mae:0.097296	valid-mae:0.098107
[50]	train-mae:0.087921	valid-mae:0.088936
[60]	train-mae:0.080404	valid-mae:0.081589
[70]	train-mae:0.074376	valid-mae:0.075714
[80]	train-mae:0.06954	valid-mae:0.071116
[90]	train-mae:0.06569	valid-mae:0.067364
[100]	train-mae:0.062726	valid-mae:0.064432
[110]	train-mae:0.060385	valid-mae:0.062175
[120]	train-mae:0.058568	valid-mae:0.060457
[130]	train-mae:0.057171	valid-mae:0.059147
[140]	train-mae:0.056044	valid-mae:0.058252
[150]	train-mae:0.055171	valid-mae:0.057541
[160]	train-mae:0.054438	valid-mae:0.056929
[170]	train-mae:0.053848	valid-mae:0.056475
[180]	train-mae:0.053403	valid-mae:0.056141
[190]	train-mae:0.053024	valid-mae:0.055903
[200]	train-mae:0.052709	valid-mae:0.055733
[210]	train-mae:0.05246	valid-mae:0.055615
[220]	train-mae:0.052221	valid-mae:0.055542
[230]	train-mae:0.052002	valid-mae:0.055502
[240]	train-mae:0.051802	valid-mae:0.055466
[250]	train-mae:0.051629	valid-mae:0.055425
[260]	train-mae:0.051443	valid-mae:0.05537
[270]	train-mae:0.05126	valid-mae:0.055329
[280]	train-mae:0.051092	valid-mae:0.055287
[290]	train-mae:0.050925	valid-mae:0.055288
[300]	train-mae:0.050764	valid-mae:0.055289
[310]	train-mae:0.050627	valid-mae:0.055277
[320]	train-mae:0.050506	valid-mae:0.05527
[330]	train-mae:0.050411	valid-mae:0.055273
[340]	train-mae:0.050316	valid-mae:0.055262
[350]	train-mae:0.050223	valid-mae:0.055257
[360]	train-mae:0.050132	valid-mae:0.055254
[370]	train-mae:0.050052	valid-mae:0.055278
[380]	train-mae:0.049965	valid-mae:0.055305
[390]	train-mae:0.049878	valid-mae:0.055323
[400]	train-mae:0.049781	valid-mae:0.05531
[410]	train-mae:0.0497	valid-mae:0.05533
[420]	train-mae:0.049586	valid-mae:0.055349
[430]	train-mae:0.049503	valid-mae:0.055376
[440]	train-mae:0.049423	valid-mae:0.055394
[450]	train-mae:0.049337	valid-mae:0.055418
Stopping. Best iteration:
[351]	train-mae:0.050218	valid-mae:0.055254

[0]	train-mae:0.253764	valid-mae:0.25074
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.212844	valid-mae:0.20983
[20]	train-mae:0.180489	valid-mae:0.177675
[30]	train-mae:0.154799	valid-mae:0.152442
[40]	train-mae:0.134436	valid-mae:0.132532
[50]	train-mae:0.1183	valid-mae:0.116704
[60]	train-mae:0.105511	valid-mae:0.10438
[70]	train-mae:0.095422	valid-mae:0.094731
[80]	train-mae:0.087454	valid-mae:0.087142
[90]	train-mae:0.081155	valid-mae:0.081124
[100]	train-mae:0.076169	valid-mae:0.076436
[110]	train-mae:0.072208	valid-mae:0.072774
[120]	train-mae:0.069041	valid-mae:0.069875
[130]	train-mae:0.066525	valid-mae:0.067615
[140]	train-mae:0.064513	valid-mae:0.065828
[150]	train-mae:0.062914	valid-mae:0.064424
[160]	train-mae:0.061626	valid-mae:0.063338
[170]	train-mae:0.0606	valid-mae:0.062461
[180]	train-mae:0.059773	valid-mae:0.061814
[190]	train-mae:0.059084	valid-mae:0.061271
[200]	train-mae:0.058531	valid-mae:0.060868
[210]	train-mae:0.058058	valid-mae:0.060536
[220]	train-mae:0.057658	valid-mae:0.060248
[230]	train-mae:0.057307	valid-mae:0.060027
[240]	train-mae:0.057014	valid-mae:0.059847
[250]	train-mae:0.056753	valid-mae:0.059711
[260]	train-mae:0.056499	valid-mae:0.059566
[270]	train-mae:0.056295	valid-mae:0.059469
[280]	train-mae:0.056097	valid-mae:0.059359
[290]	train-mae:0.055931	valid-mae:0.059273
[300]	train-mae:0.055787	valid-mae:0.059214
[310]	train-mae:0.055638	valid-mae:0.059165
[320]	train-mae:0.055495	valid-mae:0.059125
[330]	train-mae:0.055357	valid-mae:0.05908
[340]	train-mae:0.055231	valid-mae:0.059042
[350]	train-mae:0.055099	valid-mae:0.059033
[360]	train-mae:0.054967	valid-mae:0.059006
[370]	train-mae:0.054862	valid-mae:0.059004
[380]	train-mae:0.054745	valid-mae:0.059
[390]	train-mae:0.054635	valid-mae:0.058987
[400]	train-mae:0.054522	valid-mae:0.058982
[410]	train-mae:0.054422	valid-mae:0.05898
[420]	train-mae:0.054302	valid-mae:0.058963
[430]	train-mae:0.05421	valid-mae:0.05897
[440]	train-mae:0.054111	valid-mae:0.058952
[450]	train-mae:0.054013	valid-mae:0.058951
[460]	train-mae:0.053914	valid-mae:0.058936
[470]	train-mae:0.053812	valid-mae:0.058933
[480]	train-mae:0.053723	valid-mae:0.058939
[490]	train-mae:0.053612	valid-mae:0.058933
[500]	train-mae:0.053545	valid-mae:0.058934
[510]	train-mae:0.053457	valid-mae:0.058926
[520]	train-mae:0.05338	valid-mae:0.058921
[530]	train-mae:0.053303	valid-mae:0.058928
[540]	train-mae:0.053217	valid-mae:0.058933
[550]	train-mae:0.053137	valid-mae:0.058948
[560]	train-mae:0.053065	valid-mae:0.058956
[570]	train-mae:0.052973	valid-mae:0.058958
[580]	train-mae:0.052898	valid-mae:0.058966
[590]	train-mae:0.052821	valid-mae:0.058958
[600]	train-mae:0.05273	valid-mae:0.058954
Stopping. Best iteration:
[508]	train-mae:0.053471	valid-mae:0.05892

[0]	train-mae:0.21214	valid-mae:0.210057
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.181882	valid-mae:0.180877
[20]	train-mae:0.157506	valid-mae:0.157603
[30]	train-mae:0.137976	valid-mae:0.138956
[40]	train-mae:0.12228	valid-mae:0.124016
[50]	train-mae:0.109796	valid-mae:0.112184
[60]	train-mae:0.099765	valid-mae:0.102736
[70]	train-mae:0.091667	valid-mae:0.095174
[80]	train-mae:0.085237	valid-mae:0.0892
[90]	train-mae:0.080101	valid-mae:0.084454
[100]	train-mae:0.07597	valid-mae:0.080592
[110]	train-mae:0.072653	valid-mae:0.077512
[120]	train-mae:0.069997	valid-mae:0.075093
[130]	train-mae:0.067852	valid-mae:0.073193
[140]	train-mae:0.066152	valid-mae:0.071791
[150]	train-mae:0.064806	valid-mae:0.070714
[160]	train-mae:0.063771	valid-mae:0.069927
[170]	train-mae:0.062952	valid-mae:0.069298
[180]	train-mae:0.062332	valid-mae:0.068812
[190]	train-mae:0.061817	valid-mae:0.068437
[200]	train-mae:0.061369	valid-mae:0.068145
[210]	train-mae:0.060973	valid-mae:0.067905
[220]	train-mae:0.060611	valid-mae:0.067711
[230]	train-mae:0.060342	valid-mae:0.067543
[240]	train-mae:0.060081	valid-mae:0.067417
[250]	train-mae:0.059818	valid-mae:0.06732
[260]	train-mae:0.059587	valid-mae:0.067232
[270]	train-mae:0.059354	valid-mae:0.067128
[280]	train-mae:0.059166	valid-mae:0.06706
[290]	train-mae:0.058974	valid-mae:0.066997
[300]	train-mae:0.058814	valid-mae:0.066926
[310]	train-mae:0.058646	valid-mae:0.06685
[320]	train-mae:0.058495	valid-mae:0.066823
[330]	train-mae:0.058352	valid-mae:0.066766
[340]	train-mae:0.058208	valid-mae:0.06672
[350]	train-mae:0.05807	valid-mae:0.066655
[360]	train-mae:0.057921	valid-mae:0.066615
[370]	train-mae:0.057795	valid-mae:0.066605
[380]	train-mae:0.05766	valid-mae:0.066571
[390]	train-mae:0.057551	valid-mae:0.066565
[400]	train-mae:0.057434	valid-mae:0.066529
[410]	train-mae:0.057315	valid-mae:0.06649
[420]	train-mae:0.057199	valid-mae:0.066484
[430]	train-mae:0.05709	valid-mae:0.066459
[440]	train-mae:0.056971	valid-mae:0.066448
[450]	train-mae:0.056859	valid-mae:0.066449
[460]	train-mae:0.056753	valid-mae:0.066433
[470]	train-mae:0.056631	valid-mae:0.066423
[480]	train-mae:0.056513	valid-mae:0.066412
[490]	train-mae:0.056404	valid-mae:0.066409
[500]	train-mae:0.056286	valid-mae:0.066394
[510]	train-mae:0.056153	valid-mae:0.066382
[520]	train-mae:0.056036	valid-mae:0.066381
[530]	train-mae:0.055903	valid-mae:0.066381
[540]	train-mae:0.055793	valid-mae:0.066371
[550]	train-mae:0.055687	valid-mae:0.066383
[560]	train-mae:0.055565	valid-mae:0.066394
[570]	train-mae:0.055427	valid-mae:0.066369
[580]	train-mae:0.055311	valid-mae:0.06636
[590]	train-mae:0.05521	valid-mae:0.066363
[600]	train-mae:0.055104	valid-mae:0.066373
[610]	train-mae:0.054985	valid-mae:0.066348
[620]	train-mae:0.054875	valid-mae:0.06636
[630]	train-mae:0.054779	valid-mae:0.066347
[640]	train-mae:0.054674	valid-mae:0.066358
[650]	train-mae:0.054568	valid-mae:0.06636
[660]	train-mae:0.054459	valid-mae:0.066352
[670]	train-mae:0.054351	valid-mae:0.066365
[680]	train-mae:0.054234	valid-mae:0.066345
[690]	train-mae:0.054134	valid-mae:0.066331
[700]	train-mae:0.054034	valid-mae:0.066336
[710]	train-mae:0.053925	valid-mae:0.066328
[720]	train-mae:0.053816	valid-mae:0.066352
[730]	train-mae:0.053711	valid-mae:0.06634
[740]	train-mae:0.053607	valid-mae:0.066365
[750]	train-mae:0.053496	valid-mae:0.066358
[760]	train-mae:0.053376	valid-mae:0.066358
[770]	train-mae:0.053295	valid-mae:0.066375
[780]	train-mae:0.053175	valid-mae:0.066379
[790]	train-mae:0.053057	valid-mae:0.066412
Stopping. Best iteration:
[691]	train-mae:0.054121	valid-mae:0.066321


In [24]:
all_results.to_csv('results_xgboost_regression.csv')

In [23]:
house_nr = 18
houses=[1,2,4,5,6,7,8,9,10,12,13,15,16,17,18,19,20]
if house_nr == 18:
    #create dummy variables
    data_ook = pd.get_dummies(data_modeling, columns=cols, prefix=cols, drop_first=True)
    #data_ook = pd.get_dummies(data_ook, columns=['Month'], prefix='Month', drop_first=False)
    
    # keep the house you want for modeling
    drop_houses = ['House_'+str(i) for i in houses if i != house_nr]
    data_ook = data_ook.drop(drop_houses, axis=1)
    
    # create lagged predictors
    data_ook['t1'] = data_ook['House_'+str(house_nr)].shift(+1)
    data_ook['t24'] = data_ook['House_'+str(house_nr)].shift(+24)

    # drop nan values
    data_ook = data_ook.dropna(axis=0,how='any')
    
    
    # split train and test sets
    house = 'House_' + str(house_nr)
    x = data_ook.drop(house,axis=1).values.astype(np.float)
    y = data_ook[house].values
    
    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.25, random_state=0)
    
    
    # fit xgboost model
    d_train = xgb.DMatrix(x_train, label=y_train)
    d_test = xgb.DMatrix(x_test,label=y_test)
    
    params = {}
    params['eta'] = 0.02
    params['objective'] = 'reg:linear'
    params['eval_metric'] = 'mae'
    params['max_depth'] = 4
    params['silent'] = 1

    watchlist = [(d_train, 'train'), (d_test, 'valid')]
    model = xgb.train(params, d_train, 1000, watchlist, early_stopping_rounds=100, verbose_eval=10)
    fit = model.predict(d_train)
    predictions = model.predict(d_test)


[0]	train-mae:0.163177	valid-mae:0.163467
Multiple eval metrics have been passed: 'valid-mae' will be used for early stopping.

Will train until valid-mae hasn't improved in 100 rounds.
[10]	train-mae:0.141134	valid-mae:0.14146
[20]	train-mae:0.123342	valid-mae:0.123744
[30]	train-mae:0.108966	valid-mae:0.10957
[40]	train-mae:0.097296	valid-mae:0.098107
[50]	train-mae:0.087921	valid-mae:0.088936
[60]	train-mae:0.080404	valid-mae:0.081589
[70]	train-mae:0.074376	valid-mae:0.075714
[80]	train-mae:0.06954	valid-mae:0.071116
[90]	train-mae:0.06569	valid-mae:0.067364
[100]	train-mae:0.062726	valid-mae:0.064432
[110]	train-mae:0.060385	valid-mae:0.062175
[120]	train-mae:0.058568	valid-mae:0.060457
[130]	train-mae:0.057171	valid-mae:0.059147
[140]	train-mae:0.056044	valid-mae:0.058252
[150]	train-mae:0.055171	valid-mae:0.057541
[160]	train-mae:0.054438	valid-mae:0.056929
[170]	train-mae:0.053848	valid-mae:0.056475
[180]	train-mae:0.053403	valid-mae:0.056141
[190]	train-mae:0.053024	valid-mae:0.055903
[200]	train-mae:0.052709	valid-mae:0.055733
[210]	train-mae:0.05246	valid-mae:0.055615
[220]	train-mae:0.052221	valid-mae:0.055542
[230]	train-mae:0.052002	valid-mae:0.055502
[240]	train-mae:0.051802	valid-mae:0.055466
[250]	train-mae:0.051629	valid-mae:0.055425
[260]	train-mae:0.051443	valid-mae:0.05537
[270]	train-mae:0.05126	valid-mae:0.055329
[280]	train-mae:0.051092	valid-mae:0.055287
[290]	train-mae:0.050925	valid-mae:0.055288
[300]	train-mae:0.050764	valid-mae:0.055289
[310]	train-mae:0.050627	valid-mae:0.055277
[320]	train-mae:0.050506	valid-mae:0.05527
[330]	train-mae:0.050411	valid-mae:0.055273
[340]	train-mae:0.050316	valid-mae:0.055262
[350]	train-mae:0.050223	valid-mae:0.055257
[360]	train-mae:0.050132	valid-mae:0.055254
[370]	train-mae:0.050052	valid-mae:0.055278
[380]	train-mae:0.049965	valid-mae:0.055305
[390]	train-mae:0.049878	valid-mae:0.055323
[400]	train-mae:0.049781	valid-mae:0.05531
[410]	train-mae:0.0497	valid-mae:0.05533
[420]	train-mae:0.049586	valid-mae:0.055349
[430]	train-mae:0.049503	valid-mae:0.055376
[440]	train-mae:0.049423	valid-mae:0.055394
[450]	train-mae:0.049337	valid-mae:0.055418
Stopping. Best iteration:
[351]	train-mae:0.050218	valid-mae:0.055254


In [27]:
fig, ax = plt.subplots(1)
x = np.arange(100)
ax.plot(x,y_train[0:100], 'b-', label="Data")
ax.plot(x,fit[0:100], 'r-', label="XGBoost Fit")
ax.set_ylabel('Electricity Conumption (kWh)')
ax.set_xlabel('Time (hours)')
ax.legend(loc='best')
ax.set_title('Hourly Electricity Consumption during Training Time')
plt.savefig('figures/xgboost/train.eps')
plt.savefig('figures/xgboost/train.pdf')



In [28]:
fig, ax = plt.subplots(1)
x = np.arange(100)
ax.plot(x,y_test[0:100], 'b-', label="Data")
ax.plot(x,predictions[0:100], 'r-', label="XGBoost Predictions")
ax.set_ylabel('Electricity Conumption (kWh)')
ax.set_xlabel('Time (hours)')
ax.legend(loc='best')
ax.set_title('Hourly Electricity Consumption during Testing Time')
plt.savefig('figures/xgboost/test.eps')
plt.savefig('figures/xgboost/test.pdf')



In [ ]: