Kaggle competition: Grupo Bimbo Inventory Demand
<SOS> metric: RMSLE Kaggle data source: grupo-bimbo-inventory-demand<normalization>
train_data=pd.read_csv(".. /input/train.csv",usecols=['Producto_ID','Demanda_uni_equil'])
alldata = pd.concat([X_tr,
X_test])
 scaler = StandardScaler()
alldata = pd.DataFrame(scaler.fit_transform(alldata), columns=alldata.columns )<compute_test_metric>
train_data['log_Dem']=np.log(np.array(train_data['Demanda_uni_equil'].tolist())+1)
mean_absolute_error(y_tr,GPI(alldata[:X_tr.shape[0]]))<save_to_csv>
mean_data=train_data.groupby(train_data['Producto_ID'] ).mean()
print(mean_data )
submission.time_to_failure = GPI(alldata[X_tr.shape[0]:] ).values
submission.to_csv('gpsubmission.csv',index=True)
 submission.head()<import_modules>
test_data=pd.read_csv(".. /input/test.csv",usecols=['id','Producto_ID'])
 target=np.zeros(test_data.shape[0])
 log_target=np.zeros(test_data.shape[0])
 for pid in mean_data.index:
target[test_data[test_data['Producto_ID']==pid]['id'].values]=mean_data.ix[pid]['Demanda_uni_equil']
log_target[test_data[test_data['Producto_ID']==pid]['id'].values]=mean_data.ix[pid]['log_Dem']
warnings.simplefilter(action='ignore', category=FutureWarning)
 warnings.simplefilter(action='ignore', category=UserWarning)
 sns.set()
init_notebook_mode(connected=True )<load_from_csv>
test_data['Demanda_uni_equil']=np.exp(log_target)-1
print(test_data)
 test_data.to_csv('result_groupmean_log.csv',index=False,columns=['id','Demanda_uni_equil'] )
data_type = {'acoustic_data': np.int16, 'time_to_failure': np.float32}
train = pd.read_csv('.. /input/train.csv', dtype=data_type)
 train.head()<feature_engineering>
test_data[test_data['Producto_ID']==41]['id']