Kaggle competition: Bike Sharing Demand
conversion = np.argmax(predictions, axis=1 )<train_model>
train = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv")
 train.head(10)
print("No.f Id's available in the test dataset: {}".format(len(test_df['id'])))
 print("No.f predictions done by the model on test data: {}".format(len(result)) )<concatenate>
test = pd.read_csv("/kaggle/input/bike-sharing-demand/test.csv")
 test.head(10 )
submission = pd.concat([test_df['id'], result],axis = 1 )<save_to_csv>
y = train['count']
y.sort_values()
submission.to_csv("submission.csv", index=False )<set_options>
y = np.log(train['count'])
 y
%matplotlib inline 
<load_from_csv>
train['datetime'] = train['datetime'].astype('datetime64')
 train.dtypes
train_df = pd.read_csv("/kaggle/input/Kannada-MNIST/train.csv" )<load_from_csv>
test['datetime'] = test['datetime'].astype('datetime64')
 test.dtypes
test_df = pd.read_csv("/kaggle/input/Kannada-MNIST/test.csv" )<count_values>
train['year'] = train['datetime'].dt.year
train['weekday'] = train['datetime'].dt.weekday
train['hour'] = train['datetime'].dt.hour
train.head()
train_df['label'].value_counts()<import_modules>
test['year'] = test['datetime'].dt.year
test['weekday'] = test['datetime'].dt.weekday
test['hour'] = test['datetime'].dt.hour
test.head()
import keras
from keras import utils
from keras import models
from keras import backend as K
from keras import optimizers
from keras.layers.core import(Dense, Dropout, Activation, Flatten, Reshape)
 from keras.layers.convolutional import(Conv2D, MaxPooling2D )<choose_model_class>
BATCH_SIZE = 64
NP_EPOCHS = 50
NP_CLASSES = 10
VALIDATION_SPLIT = 0.20
OPTIMIZER = optimizers.RMSprop()<prepare_x_and_y>
train = train_df.drop('label', axis=1)
 target = train_df['label']
test = test_df.drop('id', axis=1 )<feature_engineering>
train = train.drop(['datetime', 'casual', 'registered', 'count'], 1)
 test = test.drop('datetime', 1)
train /= 255<feature_engineering>
test /= 255<categorify>
target = utils.to_categorical(target, NP_CLASSES )<define_variables>
xgb = XGBRegressor()
xgb.fit(train, y)
 preds = predict(test )
NP_OUTPUT_FUNC = "softmax"
NP_DESCRIMINATOR_FUNC = "sigmoid"
NP_DROPOUT_FIRST = 0.25
NP_DROPOUT_SECOND = 0.20<choose_model_class>
sample = pd.read_csv("/kaggle/input/bike-sharing-demand/sampleSubmission.csv")
 sample.head()
model = Sequential()
model.add(Conv2D(32,(5, 5), padding='same', input_shape=(28, 28, 1)))
 model.add(LeakyReLU(alpha=0.02))
model.add(Conv2D(32,(5, 5)))
 model.add(LeakyReLU(alpha=0.02))
model.add(MaxPooling2D(pool_size=(2, 2)))
 model.add(Dropout(NP_DROPOUT_FIRST))
model.add(Conv2D(64,(3, 3), padding='same'))
model.add(LeakyReLU(alpha=0.02))
model.add(Conv2D(64,(3, 3)))
 model.add(LeakyReLU(alpha=0.02))
model.add(MaxPooling2D(pool_size=(2, 2)))
 model.add(Dropout(NP_DROPOUT_FIRST))
model.add(Flatten())
 model.add(Dense(256))
model.add(LeakyReLU(alpha=0.02))
model.add(Dropout(NP_DROPOUT_SECOND))
model.add(Dense(256))
model.add(LeakyReLU(alpha=0.02))
model.add(Dropout(NP_DROPOUT_SECOND))
model.add(Dense(NP_CLASSES))
model.add(Activation(NP_OUTPUT_FUNC))<choose_model_class>
sample['count'] = np.exp(preds)
 sample.head()
optimizer = optimizers.RMSprop(lr=0.001, rho=0.9, epsilon=1e-06, decay=0.0)
 optimizer<choose_model_class>
sample.to_csv("sample.csv", index = False)
model.compile(
 optimizer=optimizer,
loss="categorical_crossentropy",
metrics=["categorical_accuracy"]
)<split>
train2 = pd.read_csv("/kaggle/input/bike-sharing-demand/train.csv", parse_dates=['datetime'])
 train2['year'] = train2['datetime'].dt.year
train2['month'] = train2['datetime'].dt.month
train2['day'] = train2['datetime'].dt.day
train2['weekday'] = train2['datetime'].dt.weekday
train2['hour'] = train2['datetime'].dt.hour
test2 = pd.read_csv('/kaggle/input/bike-sharing-demand/test.csv', parse_dates=['datetime'])
 test2['day'] = test2['datetime'].dt.day
train2.groupby('hour')['count'].median()
X_train, X_val, y_train, y_val = model_selection.train_test_split(train, target, test_size=0.20, random_state=123456789 )<define_variables>
train2['datetime'].dt.month.value_counts()