{"metadata": {"language_info": {"codemirror_mode": {"version": 3, "name": "ipython"}, "nbconvert_exporter": "python", "mimetype": "text/x-python", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython3", "version": "3.6.3"}, "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}}, "nbformat_minor": 1, "cells": [{"metadata": {"_uuid": "22ddcc3a23e0f78d90abe345228d86039c6340a7", "_cell_guid": "0cc6f137-ecc0-4aeb-a7ea-86865487b335", "collapsed": true}, "execution_count": null, "outputs": [], "source": ["import pandas\n", "train = pandas.read_csv('../input/train.csv')"], "cell_type": "code"}, {"metadata": {"scrolled": true, "_uuid": "8df1038aa28043035b701c4bf29e35f839a979df", "_cell_guid": "e55efeb8-58f7-46f6-b778-9083c3c58c5c"}, "execution_count": null, "outputs": [], "source": ["imgs = train.iloc[:,1:]\n", "i = 0 # image 0\n", "img0 = imgs.iloc[i].values.reshape(28,28)\n", "\n", "labels = train.iloc[:,:1]\n", "\n", "import matplotlib.pyplot as plot\n", "plot.figure(1, figsize=(5, 5))\n", "plot.imshow(img0, cmap=plot.cm.gray_r, interpolation='nearest')\n", "plot.title(labels.iloc[i,0])\n", "plot.show()"], "cell_type": "code"}, {"metadata": {"_uuid": "74190ceb361d6fdfdc70b30e5b0c29dabac1740c", "_cell_guid": "3b285d35-0a18-4e7b-bffd-651bee7fe85d", "collapsed": true}, "execution_count": null, "outputs": [], "source": ["training = train.iloc[:,1:] "], "cell_type": "code"}, {"metadata": {"_uuid": "76c3d8f4a1059ca09282966627b264f9240cf65e", "_cell_guid": "c2842603-69f0-45c9-94fd-7d3362311e4b", "collapsed": true}, "execution_count": null, "outputs": [], "source": ["from sklearn.neural_network import MLPClassifier\n", "c = MLPClassifier(solver='lbfgs',activation='logistic', learning_rate_init=0.1, verbose=True)"], "cell_type": "code"}, {"metadata": {"_uuid": "e616bc3f6187da5639f6d7e23278b538434c7ff3", "_cell_guid": "741d9ee3-69dc-4f83-85ba-e5d7a8df069c"}, "execution_count": null, "outputs": [], "source": ["# training ...\n", "c.fit(training,labels.iloc[:,0])"], "cell_type": "code"}, {"metadata": {"_uuid": "6bfdbada5fd569dc0605a9602410013cf5638b00", "_cell_guid": "62f803b1-08d0-45ee-b10e-5df2e0f211c1", "collapsed": true}, "execution_count": null, "outputs": [], "source": ["test = pandas.read_csv('../input/test.csv')\n", "\n", "r = c.predict(test)\n"], "cell_type": "code"}, {"metadata": {"_uuid": "8ae0f2b74fe64282c9a4f45466d832d464a3ae97", "_cell_guid": "fcf303cf-c1ed-4a8c-947f-09af5cb2cc6d"}, "execution_count": null, "outputs": [], "source": ["import pandas as pd\n", "df = pd.DataFrame(r)\n", "df.columns=['Label']\n", "df.index+=1\n", "df.index.name = 'Imageid'\n", "df.to_csv('submission.csv', header=True)"], "cell_type": "code"}, {"metadata": {"_uuid": "1df8799989095ce7dc72891a73eae4225310167d", "_cell_guid": "da6c1697-bf62-48c0-85fc-64827b477702", "collapsed": true}, "execution_count": null, "outputs": [], "source": [], "cell_type": "code"}], "nbformat": 4}