{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"b845853f-2e5e-2a5c-8fda-2c827c51641d"},"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)\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":"c25012a4-1fd4-d7e6-05ff-200f09e756ad"},"outputs":[],"source":"train = pd.read_csv(\"../input/train.csv\")\ntrain"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"ce23cacf-f843-b9ba-968f-2bdb22cc3cd9"},"outputs":[],"source":"y=train[\"label\"]\ntrain = train.drop(\"label\",1)\nx_train = train[2000:]\nx_valid = train[:2000]\n\ny_train = y[2000:]\ny_valid = y[:2000]\n\nprint(x_train.shape)\nprint(y_train.shape)"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"e4310293-d9b4-3d1f-4a1d-84da529ba361"},"outputs":[],"source":"from sklearn.preprocessing import StandardScaler\nx_train = StandardScaler().fit(x_train).transform(x_train)\nx_valid = StandardScaler().fit(x_valid).transform(x_valid)\nx_train = x_train.reshape(x_train.shape[0],28,28,1).astype('float32')\nx_valid = x_valid.reshape(x_valid.shape[0],28,28,1).astype('float32')"},{"cell_type":"code","execution_count":null,"metadata":{"_cell_guid":"25115bb9-dbb7-d342-3699-2965206a2d90"},"outputs":[],"source":"x_train = x_train / 255\nx_valid = x_valid / 255\n# one hot encode output\nfrom keras.utils import np_utils\ny_train = np_utils.to_catagorical(y_train)\ny_valid = np_utils.to_catagorical(y_valid)\ny_train"}],"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}