Kaggle competition: M5 Forecasting - Accuracy
fnd_map = {'Slab': 0, 'BrkTil': 1, 'CBlock': 2, 'Other': 3, 'PConc': 4}
bsm_map = {'Po': 0.0, 'Fa': 0.25, 'TA': 0.5, 'Gd': 0.75, 'Ex': 1.0}
bex_map = {'NA': 0.0, 'No': 0.25, 'Mn': 0.5, 'Av': 0.75, 'Gd': 1.0}
bfi_map = {'NA': 0.0, 'Unf': 0.17, 'LwQ': 0.33, 'Rec': 0.5, 'BLQ': 0.67, 'ALQ': 0.83, 'GLQ': 1.0}
combined['BsmtFinSF1'] = combined['BsmtFinSF1'].fillna(0)
 combined['BsmtFinSF2'] = combined['BsmtFinSF2'].fillna(0)
 combined['BsmtUnfSF'] = combined['BsmtUnfSF'].fillna(0)
 combined['TotalBsmtSF'] = combined['TotalBsmtSF'].fillna(0)
 combined['BsmtFullBath'] = combined['BsmtFullBath'].fillna(0)
 combined['BsmtHalfBath'] = combined['BsmtFullBath'].fillna(0)
 for d in all_data:
d['Foundation'] = d['Foundation'].replace(['Stone', 'Wood'], 'Other')
 d['Foundation'] = d['Foundation'].map(fnd_map)
 d['BsmtQual'] = d['BsmtQual'].fillna('Po')
 d['BsmtQual'] = d['BsmtQual'].map(bsm_map)
 d['BsmtCond'] = d['BsmtCond'].fillna('Po')
 d['BsmtCond'] = d['BsmtCond'].map(bsm_map)
 d['BsmtExposure'] = d['BsmtExposure'].fillna('NA')
 d['BsmtExposure'] = d['BsmtExposure'].map(bex_map)
 d['BsmtFinType1'] = d['BsmtFinType1'].fillna('NA')
 d['BsmtFinType1'] = d['BsmtFinType1'].map(bfi_map)
 d['BsmtFinType2'] = d['BsmtFinType2'].fillna('NA')
 d['BsmtFinType2'] = d['BsmtFinType2'].map(bfi_map)
 d['BsmtFinSF1'] = d['BsmtFinSF1'].fillna(0)
 d['BsmtFinSF1'] =(d['BsmtFinSF1']-combined['BsmtFinSF1'].mean())/combined['BsmtFinSF1'].std()
d['BsmtFinSF2'] = d['BsmtFinSF2'].fillna(0)
 d['BsmtFinSF2'] =(d['BsmtFinSF2']-combined['BsmtFinSF2'].mean())/combined['BsmtFinSF2'].std()
d['BsmtUnfSF'] = d['BsmtUnfSF'].fillna(0)
 d['BsmtUnfSF'] =(d['BsmtUnfSF']-combined['BsmtUnfSF'].mean())/combined['BsmtUnfSF'].std()
d['TotalBsmtSF'] = d['TotalBsmtSF'].fillna(0)
 d['TotalBsmtSF'] =(d['TotalBsmtSF']-combined['TotalBsmtSF'].mean())/combined['TotalBsmtSF'].std()
d['BsmtFullBath'] = d['BsmtFullBath'].fillna(0)
 d['BsmtHalfBath'] = d['BsmtFullBath'].fillna(0)
 d['BsmtFullBath'] =(d['BsmtFullBath']-combined['BsmtFullBath'].mean())/combined['BsmtFullBath'].std()
d['BsmtHalfBath'] =(d['BsmtHalfBath']-combined['BsmtHalfBath'].mean())/combined['BsmtHalfBath'].std()
combined['Foundation'] = combined['Foundation'].replace(['Stone', 'Wood'], 'Other')
 combined['Foundation'] = combined['Foundation'].map(fnd_map)
 combined['BsmtQual'] = combined['BsmtQual'].fillna('Po')
 combined['BsmtQual'] = combined['BsmtQual'].map(bsm_map)
 combined['BsmtCond'] = combined['BsmtCond'].fillna('Po')
 combined['BsmtCond'] = combined['BsmtCond'].map(bsm_map)
 combined['BsmtExposure'] = combined['BsmtExposure'].fillna('NA')
 combined['BsmtExposure'] = combined['BsmtExposure'].map(bex_map)
 combined['BsmtFinType1'] = combined['BsmtFinType1'].fillna('NA')
 combined['BsmtFinType1'] = combined['BsmtFinType1'].map(bfi_map)
 combined['BsmtFinType2'] = combined['BsmtFinType2'].fillna('NA')
 combined['BsmtFinType2'] = combined['BsmtFinType2'].map(bfi_map)
 combined['BsmtFinSF1'] =(combined['BsmtFinSF1']-combined['BsmtFinSF1'].mean())/combined['BsmtFinSF1'].std()
combined['BsmtFinSF2'] =(combined['BsmtFinSF2']-combined['BsmtFinSF2'].mean())/combined['BsmtFinSF2'].std()
combined['BsmtUnfSF'] =(combined['BsmtUnfSF']-combined['BsmtUnfSF'].mean())/combined['BsmtUnfSF'].std()
combined['TotalBsmtSF'] =(combined['TotalBsmtSF']-combined['TotalBsmtSF'].mean())/combined['TotalBsmtSF'].std()
combined['BsmtFullBath'] =(combined['BsmtFullBath']-combined['BsmtFullBath'].mean())/combined['BsmtFullBath'].std()
combined['BsmtHalfBath'] =(combined['BsmtHalfBath']-combined['BsmtHalfBath'].mean())/combined['BsmtHalfBath'].std()<categorify>
<prepare_x_and_y><EOS> 
data1 = pd.read_csv('.. /input/blenddata2/M5 Darkmagic.csv' ).sort_values(by = 'id' ).reset_index(drop=True)
 data2 = pd.read_csv('.. /input/blenddata/M5 ForecasteR v2.csv' ).sort_values(by = 'id' ).reset_index(drop=True)
 submission = data1.copy()
for i in range(1,29):
data1['F'+str(i)] *= 1.02
for c in submission.columns :
if c != 'id' :
submission[c] = 0.33*data1[c] + 0.67*data2[c]
submission.to_csv('submission.csv',index=False )