Kaggle competition: Digit Recognizer
clf.fit(X_train, y_train, epochs=epochs, batch_size=batch_size, verbose=2 )<drop_column>
import keras
import numpy as np
import pandas as pd
del X_train
del y_train<find_best_params>
train_df=pd.read_csv("/kaggle/input/digit-recognizer/train.csv")
 test_df=pd.read_csv("/kaggle/input/digit-recognizer/test.csv" )
models = []
models.append(clf)
 th = 0.503<categorify>
target=train_df["label"]
train_df.drop("label",axis=1,inplace=True )
env = janestreet.make_env()
for(test_df, pred_df)in tqdm(env.iter_test()):
if test_df['weight'].item() > 0:
x_tt = test_df.loc[:, features].values
if np.isnan(x_tt[:, 1:].sum()):
x_tt[:, 1:] = np.nan_to_num(x_tt[:, 1:])+ np.isnan(x_tt[:, 1:])* f_mean
pred = np.mean([model(x_tt, training = False ).numpy() for model in models],axis=0)
 pred = f(pred)
 pred_df.action = np.where(pred >= th, 1, 0 ).astype(int)
 else:
pred_df.action = 0
env.predict(pred_df )<set_options>
train_df=train_df/255
test_df=test_df/255
warnings.filterwarnings("ignore")
<load_from_csv>
X_train=train_df.values.reshape(-1,28,28,1)
 test=test_df.values.reshape(-1,28,28,1 )
%%time
train = pd.read_csv('.. /input/jane-street-market-prediction/train.csv')
 train = train.astype({c: np.float32 for c in train.select_dtypes(include='float64' ).columns} )<data_type_conversions>
y_train=to_categorical(target,num_classes=10 )
train.fillna(train.mean() ,inplace=True )<data_type_conversions>
X_train,X_test,y_train,y_test=train_test_split(X_train,y_train,test_size=0.10,random_state=42 )
train['action'] =(train['resp'] > 0 ).astype('int' )<define_variables>
batch_size=128
num_classes=10
epochs=20
inputshape=(28,28,1 )
resp_cols = ['resp_1', 'resp_2', 'resp_3', 'resp_4', 'resp']<split>
model=Sequential()
model.add(Conv2D(32,kernel_size=(5,5),activation="relu",input_shape=inputshape))
model.add(Conv2D(64,(3,3),activation="relu"))
model.add(MaxPooling2D(pool_size=(2,2)))
 model.add(Conv2D(128,kernel_size=(5,5),activation="relu"))
model.add(Conv2D(128,(3,3),activation="relu"))
model.add(Dropout(0.25))
model.add(Flatten())
 model.add(Dense(256,activation="relu"))
model.add(Dense(128,activation="relu"))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
features_train_data = train.iloc[:,7:137]<define_variables>
reduce_learning_rate = ReduceLROnPlateau(monitor = 'val_accuracy', patience = 3, verbose = 1, factor = 0.3, min_lr = 0.00001)
 checkpoint = ModelCheckpoint('save_weights.h5', monitor = 'val_accuracy', verbose = 1, save_best_only = True, mode = 'max')
 early_stopping = EarlyStopping(monitor = 'val_loss', min_delta = 1e-10, patience = 10, verbose = 1, restore_best_weights = True)
 callbacks = [reduce_learning_rate, checkpoint, early_stopping]
all_drop_cols = set(high_correlations.index.get_level_values(0))<compute_train_metric>
model.fit(X_train,y_train,batch_size=batch_size,epochs=epochs,validation_data=(X_test,y_test),callbacks=callbacks)
 accuracy=model.evaluate(X_test,y_test )
<prepare_x_and_y><EOS> 
pred = model.predict_classes(test)
 res = pd.DataFrame({"ImageId":list(range(1,28001)) ,"Label":pred})
 res.to_csv("output.csv", index = False )