{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-10-22T11:07:25.890058Z","iopub.execute_input":"2022-10-22T11:07:25.890492Z","iopub.status.idle":"2022-10-22T11:07:25.896137Z","shell.execute_reply.started":"2022-10-22T11:07:25.890446Z","shell.execute_reply":"2022-10-22T11:07:25.894869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"execution":{"iopub.status.busy":"2022-10-22T11:07:25.899026Z","iopub.execute_input":"2022-10-22T11:07:25.899804Z","iopub.status.idle":"2022-10-22T11:07:25.912453Z","shell.execute_reply.started":"2022-10-22T11:07:25.899769Z","shell.execute_reply":"2022-10-22T11:07:25.911406Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')\ntest = pd.read_csv('/kaggle/input/digit-recognizer/test.csv')\nsample = pd.read_csv('/kaggle/input/digit-recognizer/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-10-22T11:07:25.913513Z","iopub.execute_input":"2022-10-22T11:07:25.914033Z","iopub.status.idle":"2022-10-22T11:07:29.301335Z","shell.execute_reply.started":"2022-10-22T11:07:25.914001Z","shell.execute_reply":"2022-10-22T11:07:29.300068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ImageId = test.index+1\ny = train.iloc[:,0]\nx = train.iloc[::,1:]\ntestingx = test\n\n","metadata":{"execution":{"iopub.status.busy":"2022-10-22T11:07:29.302670Z","iopub.execute_input":"2022-10-22T11:07:29.303061Z","iopub.status.idle":"2022-10-22T11:07:29.314050Z","shell.execute_reply.started":"2022-10-22T11:07:29.303028Z","shell.execute_reply":"2022-10-22T11:07:29.313045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = x/255\ntestingx = testingx/255\nfrom sklearn.model_selection import train_test_split\nx_train,x_value,y_train,y_value = train_test_split (x,y, test_size=0.1, random_state = 42)\nx_train.shape, x_value.shape, y_train.shape, y_value.shape, testingx.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-22T11:07:29.316368Z","iopub.execute_input":"2022-10-22T11:07:29.317016Z","iopub.status.idle":"2022-10-22T11:07:29.674978Z","shell.execute_reply.started":"2022-10-22T11:07:29.316974Z","shell.execute_reply":"2022-10-22T11:07:29.674159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neural_network import MLPClassifier\nmodel = MLPClassifier(hidden_layer_sizes=(50,20,10), max_iter=200, alpha=1e-4, solver='sgd',verbose=10, random_state =42,learning_rate_init=0.1).fit(x_train,y_train)\nprint(model.score(x_train,y_train))","metadata":{"execution":{"iopub.status.busy":"2022-10-22T11:07:29.676213Z","iopub.execute_input":"2022-10-22T11:07:29.676706Z","iopub.status.idle":"2022-10-22T11:09:26.277072Z","shell.execute_reply.started":"2022-10-22T11:07:29.676676Z","shell.execute_reply":"2022-10-22T11:09:26.275378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = model.predict(testingx)\nsample.Label = prediction\nsample.to_csv('submission.csv', index=False)\nsubmission = pd.read_csv(\"submission.csv\")\nsubmission","metadata":{"execution":{"iopub.status.busy":"2022-10-22T11:09:26.284656Z","iopub.execute_input":"2022-10-22T11:09:26.285970Z","iopub.status.idle":"2022-10-22T11:09:26.608793Z","shell.execute_reply.started":"2022-10-22T11:09:26.285888Z","shell.execute_reply":"2022-10-22T11:09:26.607560Z"},"trusted":true},"execution_count":null,"outputs":[]}]}