{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"ffdb3e9d-029b-a72a-b25f-62d09d5d2326"},"outputs":[],"source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport numpy as np\nimport pandas as pd \nimport matplotlib\nimport matplotlib.pyplot as plt\n%matplotlib inline\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output."},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"0390f92f-1d2f-dfad-5922-4eb9a742749d"},"outputs":[],"source":"from scipy.ndimage import convolve\nfrom sklearn import linear_model, datasets, metrics, svm, decomposition\nfrom sklearn.neural_network import BernoulliRBM\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.neighbors import KNeighborsClassifier\nfrom sklearn.model_selection import GridSearchCV\nfrom PIL import Image"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"9c36fe24-d2bf-2607-3c7c-36d803bafc9b"},"outputs":[],"source":"train = pd.read_csv(\"../input/train.csv\")"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"60143cf7-a031-21e1-a8ed-69600d75526d"},"outputs":[],"source":"train_images = (train.ix[:,1:].values).astype('float32')\ntrain_labels = train.ix[:,0].values.astype('int32')\ntrain_inputs = (train.ix[:,1:].values).astype('float32')\ntrain_inputs = np.multiply(train_inputs, 1.0 / 255.0)\n\nX_train = train_inputs[:10000]\nY_train = train_labels[:10000]\n\nX_test = train_inputs[10000:15000]\nY_test = train_labels[10000:15000]"},{"cell_type":"markdown","metadata":{"_cell_guid":"3c2c3ff2-f682-1403-5ca0-ed51a57dd31f"},"source":"## Add Contaminated Images"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"15520290-1453-57ab-8f79-c4f44a4b00cd"},"outputs":[],"source":"im = Image.open(\"input/cat2.png\").convert('L')\ncat_img = np.array(im.getdata())/225.\n\nplt.imshow(cat_img.reshape((28, 28)),cmap=plt.get_cmap('gray'),\n               interpolation='nearest')\nplt.suptitle('The Cat', fontsize=16)\nplt.subplots_adjust(0.08, 0.02, 0.92, 0.85, 0.08, 0.23)\n\nplt.show()"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"0d716170-e9e4-1308-a28e-61cc3099c42c"},"outputs":[],"source":""}],"metadata":{"_change_revision":0,"_is_fork":false,"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":0}