Kaggle competition: Bike Sharing Demand
def scheduler(epoch):
return learning_rate * 0.99 ** epoch<choose_model_class>
train = pd.read_csv(".. /input/train.csv")
 test = pd.read_csv(".. /input/test.csv" )
lr_scheduler = LearningRateScheduler(scheduler)
 model_checkpoint = ModelCheckpoint('model_best_checkpoint.h5', save_best_only=True,
save_weights_only=True, monitor='val_loss', verbose=1)
 early_stopping = EarlyStopping(monitor='val_loss', patience=10, verbose=1)
 callbacks_list = [lr_scheduler, model_checkpoint, early_stopping]<train_model>
train = pd.read_csv(".. /input/train.csv", parse_dates = ["datetime"])
 test = pd.read_csv(".. /input/test.csv", parse_dates = ["datetime"] )
history = model.fit_generator(
 train_datagen.flow(X_train,Y_train,batch_size=batch_size),
steps_per_epoch=steps_per_epoch,
epochs=epochs,
validation_data=valid_datagen.flow(X_valid,Y_valid),
validation_steps=validation_steps,
verbose=1,
callbacks=callbacks_list )<load_pretrained>
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
model.load_weights('model_best_checkpoint.h5' )<compute_test_metric>
y_train = train["count"]
results = model.evaluate(X_valid, Y_valid, batch_size=batch_size, verbose=0)
 print(f"
Loss: {results[0]}")
 print(f"Accuracy: {results[1]}" )<predict_on_test>
y_train = np.log1p(y_train )
preds_dig = model.predict_classes(x_dig/255 )<compute_test_metric>
train.drop(["datetime", "windspeed", "casual", "registered", "count"], 1, inplace=True )
print(f"Accuracy: {accuracy_score(y_dig, preds_dig)}")
 print(classification_report(y_dig, preds_dig))<predict_on_test>
test.drop(["datetime", "windspeed"], 1, inplace=True )
predictions = model.predict_classes(x_test/255)
 predictions[:10]<load_from_csv>
from sklearn.ensemble import RandomForestRegressor
submission = pd.read_csv('.. /input/Kannada-MNIST/sample_submission.csv' )<prepare_output>
from sklearn.ensemble import RandomForestRegressor
submission['label'] = predictions<save_to_csv>
rf = RandomForestRegressor(n_estimators=100 )
submission.to_csv("submission.csv",index=False )<load_from_csv>
rf.fit(train,y_train )
data = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
 print(data.shape )<load_from_csv>
preds = rf.predict(test )
test_data = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
 print(test_data.shape )<choose_model_class>
submission=pd.read_csv(".. /input/sampleSubmission.csv" )
datagen = ImageDataGenerator(
 rotation_range=10,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range = 10,
horizontal_flip = False,
zoom_range = 0.15 )<categorify>
submission["count"] = np.expm1(preds )
encoder = OneHotEncoder(sparse=False,categories='auto')
 yy = [[0],[1],[2],[3],[4],[5],[6],[7],[8],[9]]
encoder.fit(yy)
 train_label = train_label.reshape(-1,1)
 val_label = val_label.reshape(-1,1)
 train_label = encoder.transform(train_label)
 val_label = encoder.transform(val_label)
 print('train_label shape: %s'%str(train_label.shape))
print('val_label shape: %s'%str(val_label.shape))<choose_model_class>
submission.to_csv("allrf.csv", index=False )