Kaggle competition: ASHRAE - Great Energy Predictor III
<normalization><EOS> 
import pandas as pd
<SOS> metric: RMSLE Kaggle data source: ashrae-great-energy-predictor-iii<prepare_x_and_y>
import pandas as pd
%%time
NUM_FOLDS = 7
kf = KFold(n_splits=NUM_FOLDS, shuffle=True, random_state=0)
 features = loading_features + fnc_features
overal_score = 0
for target, c, w, ff, pp in [("age", 60, 0.3, 0.55, 0.6),("domain1_var1", 12, 0.175, 0.2, 0.4),("domain1_var2", 8, 0.175, 0.2, 0.5),("domain2_var1", 9, 0.175, 0.22, 0.5),("domain2_var2", 12, 0.175, 0.22, 0.5)]:
y_oof = np.zeros(df.shape[0])
 y_test = np.zeros(( test_df.shape[0], NUM_FOLDS))
for f,(train_ind, val_ind)in enumerate(kf.split(df, df)) :
train_df, val_df = df.iloc[train_ind], df.iloc[val_ind]
train_df = train_df[train_df[target].notnull() ]
model_1 = SVR(C=c, cache_size=3000.0)
 model_1.fit(train_df[features].values, train_df[target].values)
 model_2 = Ridge(alpha = 0.0001)
 model_2.fit(train_df[features].values, train_df[target].values)
 val_pred_1 = model_1.predict(val_df[features])
 val_pred_2 = model_2.predict(val_df[features])
 test_pred_1 = model_1.predict(test_df[features])
 test_pred_2 = model_2.predict(test_df[features])
 val_pred =(1-ff)*val_pred_1+ff*val_pred_2
val_pred = cp.asnumpy(val_pred.values.flatten())
 test_pred =(1-ff)*test_pred_1+ff*test_pred_2
test_pred = cp.asnumpy(test_pred.values.flatten())
 y_oof[val_ind] = val_pred
y_test[:, f] = test_pred
df["pred_{}".format(target)] = y_oof
test_df[target] = y_test.mean(axis=1)+pp
score = metric(df[df[target].notnull() ][target].values, df[df[target].notnull() ]["pred_{}".format(target)].values)
 mae = mean_absolute_error(df[df[target].notnull() ][target].values, df[df[target].notnull() ]["pred_{}".format(target)].values)
 rmse = np.sqrt(mean_squared_error(df[df[target].notnull() ][target].values, df[df[target].notnull() ]["pred_{}".format(target)].values))
overal_score += w*score
print(target, np.round(score, 8))
print(target, np.round(score, 4))
print(target, 'mean absolute error:', np.round(mae, 8))
print(target, ' root mean square error:', np.round(rmse, 8))
print()
print("Overal score:", np.round(overal_score, 8))
print("Overal score:", np.round(overal_score, 4))<data_type_conversions>
leaks = pd.read_csv('/kaggle/input/leakaggregator/leaked_test_target.csv')
 submission = pd.read_csv('/kaggle/input/bland-by-leak/submission_blend.csv' )
sub_df = cudf.melt(test_df[["Id", "age", "domain1_var1", "domain1_var2", "domain2_var1", "domain2_var2"]], id_vars=["Id"], value_name="Predicted")
 sub_df["Id"] = sub_df["Id"].astype("str")+ "_" + sub_df["variable"].astype("str")
 sub_df = sub_df.drop("variable", axis=1 ).sort_values("Id")
 assert sub_df.shape[0] == test_df.shape[0]*5
sub_df.head(10 )<save_to_csv>
( ~leaks['meter_reading'].isna() ).sum()
sub_df.to_csv("submission_rapids_ensemble.csv", index=False )<set_options>
leaks = leaks.sort_values('row_id')
 submission = submission.sort_values('row_id')
 leaks = leaks.set_index(leaks['row_id'])
 submission = submission.set_index(submission['row_id'] )
%matplotlib inline 
<define_variables>
submission.loc[~leaks['meter_reading'].isna() , 'meter_reading'] = leaks.loc[~leaks['meter_reading'].isna() , 'meter_reading']
<feature_engineering><EOS> 
submission.to_csv('bland_with_leaked.csv',index=False )