Kaggle competition: M5 Forecasting - Uncertainty
<SOS> metric: WeightedRowwisePinballLoss Kaggle data source: m5-forecasting-uncertainty<prepare_x_and_y>
%matplotlib inline
submission = pd.Series()
for i in test_stores:
store = train_stores[i]
X_train = store.drop(["Sales", "Store", "Customers"],axis=1)
 Y_train = store["Sales"]
X_test = test_stores[i].copy()
store_ids = X_test["Id"]
X_test.drop(["Id","Store"], axis=1,inplace=True)
 X_train = X_train.fillna(X_train.mean())
 X_test = X_test.fillna(X_train.mean())
 rfr = RandomForestRegressor(random_state=123, n_estimators = best_n_estimators,
max_depth = best_max_depth, criterion = 'mse')
 rfr.fit(X_train, Y_train)
 Y_pred = rfr.predict(X_test)
 submission = submission.append(pd.Series(Y_pred, index=store_ids))
submission = pd.DataFrame({ "Id": submission.index, "Sales": submission.values})
 submission.to_csv('rossmann_submission_good.csv', index=False)
 print(submission.shape )<feature_engineering>
file_1 = pd.read_csv('.. /input/m5-uncertainity/submission-0.11719.csv')
 file_2 = pd.read_csv('.. /input/m5-uncertainity/submission-0.11440.csv')
 file_3 = pd.read_csv('.. /input/m5-uncertainity/submission-0.11407.csv')
 file_4 = pd.read_csv('.. /input/m5-uncertainity/submission-0.11238.csv')
 file_5 = pd.read_csv('.. /input/m5-uncertainity/submission-0.11248.csv')
 file_6 = pd.read_csv('.. /input/m5-uncertainity/submission-.11029.csv')
 file = file_1
sns.set_style('whitegrid')
 %matplotlib inline
df_train = pd.read_csv(".. /input/train.csv")
 df_store = pd.read_csv(".. /input/store.csv")
 df_test = pd.read_csv(".. /input/test.csv")
 df_train['Year'] = df_train['Date'].apply(lambda x: int(x[:4]))
df_train['Month'] = df_train['Date'].apply(lambda x: int(x[5:7]))
df_train.head()<groupby>
file['F1'] =(file_3['F1']+file_2['F1']+file_1['F1']+file_4['F1']+file_5['F1']+file_6['F1'])/6
file['F2'] =(file_3['F2']+file_2['F2']+file_1['F2']+file_4['F2']+file_5['F2']+file_6['F2'])/6
file['F3'] =(file_3['F3']+file_2['F3']+file_1['F3']+file_4['F3']+file_5['F3']+file_6['F3'])/6
file['F4'] =(file_3['F4']+file_2['F4']+file_1['F4']+file_4['F4']+file_5['F4']+file_6['F4'])/6
file['F5'] =(file_3['F5']+file_2['F5']+file_1['F5']+file_4['F5']+file_5['F5']+file_6['F5'])/6
file['F6'] =(file_3['F6']+file_2['F6']+file_1['F6']+file_4['F6']+file_5['F6']+file_6['F6'])/6
file['F7'] =(file_3['F7']+file_2['F7']+file_1['F7']+file_4['F7']+file_5['F7']+file_6['F7'])/6
file['F8'] =(file_3['F8']+file_2['F8']+file_1['F8']+file_4['F8']+file_5['F8']+file_6['F8'])/6
file['F9'] =(file_3['F9']+file_2['F9']+file_1['F9']+file_4['F9']+file_5['F9']+file_6['F9'])/6
file['F10'] =(file_3['F10']+file_2['F10']+file_1['F10']+file_4['F10']+file_5['F10']+file_6['F10'])/6
file['F11'] =(file_3['F11']+file_2['F11']+file_1['F11']+file_4['F11']+file_5['F11']+file_6['F11'])/6
file['F12'] =(file_3['F12']+file_2['F12']+file_1['F12']+file_4['F12']+file_5['F12']+file_6['F12'])/6
file['F13'] =(file_3['F13']+file_2['F13']+file_1['F13']+file_4['F13']+file_5['F13']+file_6['F13'])/6
file['F14'] =(file_3['F14']+file_2['F14']+file_1['F14']+file_4['F14']+file_5['F14']+file_6['F14'])/6
file['F15'] =(file_3['F15']+file_2['F15']+file_1['F15']+file_4['F15']+file_5['F15']+file_6['F15'])/6
file['F16'] =(file_3['F16']+file_2['F16']+file_1['F16']+file_4['F16']+file_5['F16']+file_6['F16'])/6
file['F17'] =(file_3['F17']+file_2['F17']+file_1['F17']+file_4['F17']+file_5['F17']+file_6['F17'])/6
file['F18'] =(file_3['F18']+file_2['F18']+file_1['F18']+file_4['F18']+file_5['F18']+file_6['F18'])/6
file['F19'] =(file_3['F19']+file_2['F19']+file_1['F19']+file_4['F19']+file_5['F19']+file_6['F19'])/6
file['F20'] =(file_3['F20']+file_2['F20']+file_1['F20']+file_4['F20']+file_5['F20']+file_6['F20'])/6
file['F21'] =(file_3['F21']+file_2['F21']+file_1['F21']+file_4['F21']+file_5['F21']+file_6['F21'])/6
file['F22'] =(file_3['F22']+file_2['F22']+file_1['F22']+file_4['F22']+file_5['F22']+file_6['F22'])/6
file['F23'] =(file_3['F23']+file_2['F23']+file_1['F23']+file_4['F23']+file_5['F23']+file_6['F23'])/6
file['F24'] =(file_3['F24']+file_2['F24']+file_1['F24']+file_4['F24']+file_5['F24']+file_6['F24'])/6
file['F25'] =(file_3['F25']+file_2['F25']+file_1['F25']+file_4['F25']+file_5['F25']+file_6['F25'])/6
file['F26'] =(file_3['F26']+file_2['F26']+file_1['F26']+file_4['F26']+file_5['F26']+file_6['F26'])/6
file['F27'] =(file_3['F27']+file_2['F27']+file_1['F27']+file_4['F27']+file_5['F27']+file_6['F27'])/6
file['F28'] =(file_3['F28']+file_2['F28']+file_1['F28']+file_4['F28']+file_5['F28']+file_6['F28'])/6
avg = df_train.groupby('Month')["Customers"].mean()
avg_sales = df_train.groupby('Month')['Sales'].mean()
total_sales_customers = df_train.groupby('Store')['Sales', 'Customers'].sum()
total_sales_customers.head()<create_dataframe>
file.to_csv("submission.csv", index=False )