Kaggle competition: Digit Recognizer
<SOS> metric: categorizationaccuracy Kaggle data source: digit-recognizer<data_type_conversions>
import numpy as np
import pandas as pd
train['brand_name'] = train['brand_name'].fillna('Nobrand')
 test['brand_name'] = test['brand_name'].fillna('Nobrand' )<data_type_conversions>
training_data = pd.read_csv(".. /input/digit-recognizer/train.csv")
 test_images = pd.read_csv(".. /input/digit-recognizer/test.csv")
 train_images = training_data.drop("label", axis=1)
 train_labels = training_data["label"]
train['category_name'] = train['category_name'].fillna('No/No/No')
 test['category_name'] =test['category_name'].fillna('No/No/No' )<data_type_conversions>
train_images.to_numpy()
train_labels.to_numpy()
test_images.to_numpy()
train['item_description'] = train['item_description'].fillna('No Description')
 test['item_description'] = test['item_description'].fillna('No Description' )<string_transform>
train_images = train_images / 255.0
test_images = test_images / 255.0
def split_cat(category_name):
try:
return category_name.split('/')
 return("done")
 except:
return ['Null', 'Null', 'Null']<feature_engineering>
train_labels = to_categorical(train_labels )
train['cat_1'], train['cat_2'], train['cat_3'] = zip(*train['category_name'].apply(lambda x:split_cat(x)))
 test['cat_1'], test['cat_2'], test['cat_3'] = zip(*test['category_name'].apply(lambda x: split_cat(x)))
<count_values>
network = models.Sequential()
network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))
 network.add(layers.Dense(10, activation='softmax'))
network.summary()
( train['shipping'].value_counts())*100/train.shape[0]<count_values>
network.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'] )
brands =train['brand_name'].value_counts()
print(brands[:10] )<count_unique_values>
network.fit(train_images, train_labels, epochs = 5, batch_size=128 )
<count_unique_values><EOS> 
submit = pd.DataFrame(np.argmax(network.predict(test_images), axis=1),
columns=['Label'],
index=pd.read_csv('.. /input/digit-recognizer/sample_submission.csv')['ImageId'])
 submit.index.name = 'ImageId'
submit.to_csv('submittion.csv' )