{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","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\nimport warnings\nwarnings.filterwarnings(\"ignore\")\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/digit-recognizer/train.csv')\ndf.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c3d83a16ccfd5ff36e8aaba3e7553ba5d8b46ab2"},"cell_type":"code","source":"train_df = df.sample(frac=0.8,random_state=200)\ntest_df = df.drop(train_df.index)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d4a696b8166019963298de3a0f3cf78a776cc3bd"},"cell_type":"code","source":"train_rbf = np.load('../input/ml-assignment-3/train_rbf.npy')\ntest_rbf = np.load('../input/ml-assignment-3/test_rbf.npy')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b8ae92a38b2cd748dcd7b333670f9f119c2eaf31"},"cell_type":"code","source":"train_rbf.shape,test_rbf.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"018ed7d0a745466e291e968b09f4945a625488d6"},"cell_type":"code","source":"import tensorflow as tf \nlabel_train = train_df['label'].values\ntrain_df = train_df.drop(['label'],axis=1)\ntrain_x = train_df.as_matrix()/255","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dfba74c0c76b23a73288f63f4fe2bda6b5b5343d"},"cell_type":"code","source":"label_test = test_df['label'].values\ntest_df = test_df.drop(['label'],axis=1)\ntest_x = test_df.as_matrix()/255","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6b6835e85724484c9ad90dbe12d193ea3c3a64c6"},"cell_type":"code","source":"train_rbf = np.power(train_rbf,6)\ntest_rbf = np.power(test_rbf,6)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3bd0bb8c3ad6aedb84ca24a98c350f8d7df13ed0"},"cell_type":"code","source":"from sklearn.preprocessing import OneHotEncoder\nenc = OneHotEncoder(sparse=False)\ntrain_y = enc.fit_transform(label_train.reshape(-1,1),)\ntest_y = enc.transform(label_test.reshape(-1,1),)\ntrain_y","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-output":true,"trusted":true,"scrolled":true,"_uuid":"28b6f33e8136b106741a7b609e7650f96d0de299"},"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Activation\n\nmodel1=  Sequential()\nmodel1.add(Dense(10,input_shape=(784,),activation='softmax'))\n\nmodel1.compile(optimizer='adam',\n              loss='mse',\n              metrics=['accuracy'])\nhist = model1.fit(train_rbf,train_y,epochs=100,batch_size=150,verbose=1)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-output":true,"trusted":true,"scrolled":true,"_uuid":"3ffe138504d6d2441d019674dd11f0b5402313a7"},"cell_type":"code","source":"hist1 = model1.fit(train_rbf,train_y,epochs=100,batch_size=150,verbose=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0eb4e931dc71b93ab93f6d7fd0e9a399dd299a1b"},"cell_type":"code","source":"model1.evaluate(test_rbf,test_y, batch_size=150)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"917f3c0ede5598af8baf7f653df232cc3e6a329c"},"cell_type":"code","source":"model1.evaluate(train_rbf,train_y, batch_size=150)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"10c3cdd0da30ebf940e8003546aea27d0cdf1d68"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}