Kaggle competition: Digit Recognizer
<SOS> metric: categorizationaccuracy Kaggle data source: digit-recognizer<feature_engineering>
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
train['Fare'] = train['Fare'].map(lambda x: np.log(x)if x > 0 else 0 )<feature_engineering>
train_data = pd.read_csv('.. /input/train.csv')
 train_y = train_data["label"]
train_data.drop(["label"], axis=1, inplace=True)
 train_X = train_data
train_X = train_X.values.reshape(-1, 28, 28, 1)
 train_y = train_y.values
train_y = tf.keras.utils.to_categorical(train_y)
 train_X = train_X/255.00
test_X = pd.read_csv('.. /input/test.csv')
 test_X = test_X.values.reshape(-1,28,28,1)
 test_X = test_X / 255.0
combine['Title'] = [name.split(',')[1].split('.')[0].strip() for name in combine['Name']]
combine[['Name', 'Title']].head()<count_values>
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(32, kernel_size =(3,3), padding = 'same', activation ='relu', input_shape =(28,28,1)) ,
tf.keras.layers.Conv2D(32, kernel_size =(3,3), padding = 'same', activation ='relu'),
tf.keras.layers.Dropout(0.7),
tf.keras.layers.Conv2D(32, kernel_size =(3,3), padding = 'same', activation ='relu'),
tf.keras.layers.Conv2D(32, kernel_size =(3,3), padding = 'same', activation ='relu'),
tf.keras.layers.MaxPool2D(pool_size=(2,2), strides=2),
tf.keras.layers.Conv2D(32, kernel_size =(7,7), padding = 'same', activation ='relu'),
tf.keras.layers.Conv2D(32, kernel_size =(7,7), padding = 'same', activation ='relu'),
tf.keras.layers.MaxPool2D(pool_size=(2,2), strides=2),
tf.keras.layers.Flatten() ,
tf.keras.layers.Dense(1024, activation = "relu"),
tf.keras.layers.Dense(256, activation = "relu"),
tf.keras.layers.Dense(10, activation = "softmax")
 ] )
combine['Title'].value_counts()<count_unique_values>
datagen = tf.keras.preprocessing.image.ImageDataGenerator(rotation_range=43, zoom_range=0.24)
 datagen.fit(train_X)
 ln_fc = lambda x: 1e-3 * 0.99 ** x
lrng_rt = tf.keras.callbacks.LearningRateScheduler(ln_fc)
 digitizer = model.fit_generator(datagen.flow(train_X, train_y, batch_size=1024), epochs=80, callbacks=[lrng_rt] )
<categorify><EOS> 
predictions = model.predict(test_X)
 predictions[354]
pred = np.argmax(predictions, axis=1)
 plt.imshow(test_X[354][:,:,0],cmap='gray')
 plt.show()
pred[354]
pred_digits = pd.DataFrame({'ImageId': range(1,len(test_X)+1),'Label':pred })
 pred_digits.to_csv("pre_digits.csv",index=False )