{"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":"# 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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-05-06T02:57:28.762949Z","iopub.execute_input":"2022-05-06T02:57:28.763493Z","iopub.status.idle":"2022-05-06T02:57:28.773880Z","shell.execute_reply.started":"2022-05-06T02:57:28.763459Z","shell.execute_reply":"2022-05-06T02:57:28.772994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv('../input/digit-recognizer/train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-05-06T02:57:46.156430Z","iopub.execute_input":"2022-05-06T02:57:46.156972Z","iopub.status.idle":"2022-05-06T02:57:49.226739Z","shell.execute_reply.started":"2022-05-06T02:57:46.156938Z","shell.execute_reply":"2022-05-06T02:57:49.225822Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-06T02:58:02.856391Z","iopub.execute_input":"2022-05-06T02:58:02.856711Z","iopub.status.idle":"2022-05-06T02:58:02.883294Z","shell.execute_reply.started":"2022-05-06T02:58:02.856680Z","shell.execute_reply":"2022-05-06T02:58:02.882298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.info()","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:02:29.120002Z","iopub.execute_input":"2022-05-06T03:02:29.120323Z","iopub.status.idle":"2022-05-06T03:02:29.273533Z","shell.execute_reply.started":"2022-05-06T03:02:29.120282Z","shell.execute_reply":"2022-05-06T03:02:29.272906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:01:49.085230Z","iopub.execute_input":"2022-05-06T03:01:49.085520Z","iopub.status.idle":"2022-05-06T03:01:49.135030Z","shell.execute_reply.started":"2022-05-06T03:01:49.085491Z","shell.execute_reply":"2022-05-06T03:01:49.134435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = data.drop(['label'], axis=1)\ny = data['label']","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:16:23.012350Z","iopub.execute_input":"2022-05-06T03:16:23.012620Z","iopub.status.idle":"2022-05-06T03:16:23.126068Z","shell.execute_reply.started":"2022-05-06T03:16:23.012593Z","shell.execute_reply":"2022-05-06T03:16:23.125457Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:16:40.115339Z","iopub.execute_input":"2022-05-06T03:16:40.115611Z","iopub.status.idle":"2022-05-06T03:16:41.409505Z","shell.execute_reply.started":"2022-05-06T03:16:40.115584Z","shell.execute_reply":"2022-05-06T03:16:41.408570Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.svm import SVC\n\n\n# import metrics to compute accuracy\nfrom sklearn.metrics import accuracy_score\n\n\n# instantiate classifier with default hyperparameters\nsvc=SVC() \n\n\n# fit classifier to training set\nsvc.fit(X_train,y_train)\n\n\n# make predictions on test set\ny_pred=svc.predict(X_test)\n\n\n# compute and print accuracy score\nprint('Model accuracy score with default hyperparameters: {0:0.4f}'. format(accuracy_score(y_test, y_pred)))","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:17:09.551165Z","iopub.execute_input":"2022-05-06T03:17:09.552064Z","iopub.status.idle":"2022-05-06T03:20:06.353742Z","shell.execute_reply.started":"2022-05-06T03:17:09.551999Z","shell.execute_reply":"2022-05-06T03:20:06.352747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data = pd.read_csv(\"../input/digit-recognizer/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:21:52.182508Z","iopub.execute_input":"2022-05-06T03:21:52.183169Z","iopub.status.idle":"2022-05-06T03:21:53.497372Z","shell.execute_reply.started":"2022-05-06T03:21:52.183117Z","shell.execute_reply":"2022-05-06T03:21:53.496487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred = svc.predict(test_data)","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:22:58.998426Z","iopub.execute_input":"2022-05-06T03:22:58.998732Z","iopub.status.idle":"2022-05-06T03:26:36.849414Z","shell.execute_reply.started":"2022-05-06T03:22:58.998697Z","shell.execute_reply":"2022-05-06T03:26:36.848403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:43:03.115898Z","iopub.execute_input":"2022-05-06T03:43:03.116421Z","iopub.status.idle":"2022-05-06T03:43:03.122384Z","shell.execute_reply.started":"2022-05-06T03:43:03.116391Z","shell.execute_reply":"2022-05-06T03:43:03.121567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = pd.read_csv(\"../input/digit-recognizer/sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:48:54.566948Z","iopub.execute_input":"2022-05-06T03:48:54.567624Z","iopub.status.idle":"2022-05-06T03:48:54.589919Z","shell.execute_reply.started":"2022-05-06T03:48:54.567586Z","shell.execute_reply":"2022-05-06T03:48:54.589296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:49:14.627256Z","iopub.execute_input":"2022-05-06T03:49:14.628029Z","iopub.status.idle":"2022-05-06T03:49:14.636539Z","shell.execute_reply.started":"2022-05-06T03:49:14.627977Z","shell.execute_reply":"2022-05-06T03:49:14.635699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub['Label'] = test_pred","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:49:40.440981Z","iopub.execute_input":"2022-05-06T03:49:40.441273Z","iopub.status.idle":"2022-05-06T03:49:40.445523Z","shell.execute_reply.started":"2022-05-06T03:49:40.441245Z","shell.execute_reply":"2022-05-06T03:49:40.444908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.head()","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:50:24.296923Z","iopub.execute_input":"2022-05-06T03:50:24.297320Z","iopub.status.idle":"2022-05-06T03:50:24.304939Z","shell.execute_reply.started":"2022-05-06T03:50:24.297293Z","shell.execute_reply":"2022-05-06T03:50:24.304376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame.to_csv(sub,\"submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-05-06T03:53:49.993484Z","iopub.execute_input":"2022-05-06T03:53:49.993756Z","iopub.status.idle":"2022-05-06T03:53:50.038680Z","shell.execute_reply.started":"2022-05-06T03:53:49.993729Z","shell.execute_reply":"2022-05-06T03:53:50.038074Z"},"trusted":true},"execution_count":null,"outputs":[]}]}