Kaggle competition: Digit Recognizer
<SOS> metric: categorizationaccuracy Kaggle data source: digit-recognizer<categorify>
%run.. /input/python-recipes/dhtml.py
%run.. /input/python-recipes/load_kaggle_digits.py
%run.. /input/python-recipes/classify_kaggle_digits.py
dhtml('Data Processing' )
shops.loc[shops.shop_name == 'Сергиев Посад ТЦ "7Я"', 'shop_name'] = 'СергиевПосад ТЦ "7Я"'
shops['city'] = shops['shop_name'].str.split(' ' ).map(lambda x: x[0])
 shops.loc[shops.city == '!Якутск', 'city'] = 'Якутск'
shops['city_code'] = LabelEncoder().fit_transform(shops['city'])
 shops = shops[['shop_id','city_code']]
cats['split'] = cats['item_category_name'].str.split('-')
 cats['type'] = cats['split'].map(lambda x: x[0].strip())
 cats['type_code'] = LabelEncoder().fit_transform(cats['type'])
 cats['subtype'] = cats['split'].map(lambda x: x[1].strip() if len(x)> 1 else x[0].strip())
 cats['subtype_code'] = LabelEncoder().fit_transform(cats['subtype'])
 cats = cats[['item_category_id','type_code', 'subtype_code']]
items.drop(['item_name'], axis=1, inplace=True )<concatenate>
k=.75; cmap='Pastel1_r'
x_train,y_train,x_valid,y_valid,x_test,y_test,\
test_images,num_classes=\
load_kaggle_digits(k,cmap )
len(list(set(test.item_id)- set(test.item_id ).intersection(set(train.item_id)))) , len(list(set(test.item_id))), len(test )<data_type_conversions>
num_test=100
model_evaluation(cnn_model,x_test,y_test,
weights,color,num_test )
<feature_engineering><EOS> 
cnn_model.load_weights(weights)
 predict_test_labels=\
cnn_model.predict_classes(test_images)
 submission=pd.DataFrame(
 {'ImageId':range(1,len(predict_test_labels)+1),
'Label':predict_test_labels})
 submission.to_csv('kaggle_digits.csv',index=False)
 fig=pl.figure(figsize=(10,6))
for i in range(15):
ax=fig.add_subplot(3,5,i+1,xticks=[],yticks=[])
 ax.imshow(test_images[i].reshape(28,28),
cmap=pl.get_cmap('Pastel1'))
ax.set_title('%d'%submission['Label'][i],
fontsize=10)
 pl.show()