{"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 pandas as pd\nfrom sklearn.svm import SVC\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.model_selection import train_test_split","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-12-22T19:33:06.383233Z","iopub.execute_input":"2021-12-22T19:33:06.385713Z","iopub.status.idle":"2021-12-22T19:33:06.468574Z","shell.execute_reply.started":"2021-12-22T19:33:06.385602Z","shell.execute_reply":"2021-12-22T19:33:06.467619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data = pd.read_csv('../input/digit-recognizer/train.csv')\ntest_data = pd.read_csv('../input/digit-recognizer/test.csv')\ntrain_data","metadata":{"execution":{"iopub.status.busy":"2021-12-22T19:33:06.470871Z","iopub.execute_input":"2021-12-22T19:33:06.472257Z","iopub.status.idle":"2021-12-22T19:33:09.953515Z","shell.execute_reply.started":"2021-12-22T19:33:06.472209Z","shell.execute_reply":"2021-12-22T19:33:09.952645Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"K = train_data['label']\nP = train_data.drop('label', axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-12-22T19:33:09.954816Z","iopub.execute_input":"2021-12-22T19:33:09.955724Z","iopub.status.idle":"2021-12-22T19:33:10.068050Z","shell.execute_reply.started":"2021-12-22T19:33:09.955679Z","shell.execute_reply":"2021-12-22T19:33:10.067320Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pipe = Pipeline([('scaler', StandardScaler()), ('svc', SVC())])\npipe.fit(P, K)","metadata":{"execution":{"iopub.status.busy":"2021-12-22T19:33:10.069296Z","iopub.execute_input":"2021-12-22T19:33:10.070024Z","iopub.status.idle":"2021-12-22T19:41:34.597797Z","shell.execute_reply.started":"2021-12-22T19:33:10.069976Z","shell.execute_reply":"2021-12-22T19:41:34.596903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"k = pipe.predict(test_data)","metadata":{"execution":{"iopub.status.busy":"2021-12-22T19:41:34.599898Z","iopub.execute_input":"2021-12-22T19:41:34.600221Z","iopub.status.idle":"2021-12-22T19:48:56.216900Z","shell.execute_reply.started":"2021-12-22T19:41:34.600178Z","shell.execute_reply":"2021-12-22T19:48:56.215977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame({\n    \"ImageId\": range(1,len(k)+1),\n    \"Label\": k\n    }).to_csv('submission.csv', index=False, header=True)","metadata":{"execution":{"iopub.status.busy":"2021-12-22T19:48:56.218181Z","iopub.execute_input":"2021-12-22T19:48:56.218412Z","iopub.status.idle":"2021-12-22T19:48:56.253585Z","shell.execute_reply.started":"2021-12-22T19:48:56.218386Z","shell.execute_reply":"2021-12-22T19:48:56.252754Z"},"trusted":true},"execution_count":null,"outputs":[]}]}