Kaggle competition: Bike Sharing Demand
values = {}
models = os.listdir(model_name)
 for model in models:
converted = model.replace(".h5", "")
 accuracy = float(converted.split("-")[-1])
 values.update({accuracy: model})
 key = max(values, key = values.get)
 best = values.get(key)
 print("Best model found: {}".format(best))<train_model>
train = pd.read_csv(".. /input/train.csv", parse_dates = ["datetime"])
 test = pd.read_csv(".. /input/test.csv", parse_dates = ["datetime"])
 train["year"] = train["datetime"].dt.year
train["hour"] = train["datetime"].dt.hour
train["dayofweek"] = train["datetime"].dt.dayofweek
test["year"] = test["datetime"].dt.year
test["hour"] = test["datetime"].dt.hour
test["dayofweek"] = test["datetime"].dt.dayofweek
y_casual = np.log1p(train.casual)
 y_registered = np.log1p(train.registered)
 train.drop(["datetime", "windspeed", "casual", "registered", "count"], 1, inplace=True)
 test.drop(["datetime", "windspeed", ], 1, inplace=True)
 hyperparameters = { 'colsample_bytree': 0.725, 'learning_rate': 0.013,
'num_leaves': 56, 'reg_alpha': 0.754, 'reg_lambda': 0.071,
'subsample': 0.523, 'n_estimators': 1093}
model = lgb.LGBMRegressor(**hyperparameters)
 model.fit(train, y_casual)
 preds1 = model.predict(test)
 hyperparameters = { 'colsample_bytree': 0.639, 'learning_rate': 0.011,
'num_leaves': 30, 'reg_alpha': 0.351, 'reg_lambda': 0.587,
'subsample': 0.916, 'n_estimators': 2166}
model = lgb.LGBMRegressor(**hyperparameters,)
 model.fit(train, y_registered)
 preds2 = model.predict(test)
 submission=pd.read_csv(".. /input/sampleSubmission.csv")
 submission["count"] = np.expm1(preds1)+ np.expm1(preds2)
model_path = model_name + best
print("Absolute path found: {}".format(model_path))<load_pretrained>
pd.options.display.max_rows = 200
submission["holiday"] = test["holiday"]
submission.loc[(submission["holiday"]==1)]
model = load_model(model_path )<predict_on_test>
submission.iloc[1258:1269, 1]= submission.iloc[1258:1269, 1]*0.5
submission.iloc[4492:4515, 1]= submission.iloc[4492:4515, 1]*0.5
submission.iloc[6308:6330, 1]= submission.iloc[6308:6330, 1]*0.5
submission.iloc[3041:3063, 1]= submission.iloc[3041:3063, 1]*0.5
submission.iloc[6332:6354, 1]= submission.iloc[6332:6354, 1]*0.5
submission.iloc[3065:3087, 1]= submission.iloc[3065:3087, 1]*0.5
submission.iloc[5992:6015, 1]= submission.iloc[5992:6015, 1]*0.5
submission.iloc[2771:2794, 1]= submission.iloc[2771:2794, 1]*0.5
predictions = model.predict([test, test] )<prepare_output>
submission.drop("holiday",1,inplace=True)
 submission.to_csv("allrf2.csv", index=False )