{"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-04-06T20:14:35.042512Z","iopub.execute_input":"2022-04-06T20:14:35.043019Z","iopub.status.idle":"2022-04-06T20:14:35.054909Z","shell.execute_reply.started":"2022-04-06T20:14:35.042975Z","shell.execute_reply":"2022-04-06T20:14:35.053923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=pd.read_csv('../input/Kannada-MNIST/train.csv')\ntest=pd.read_csv('../input/Kannada-MNIST/test.csv')\nsubmission = pd.read_csv('../input/Kannada-MNIST/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:14:35.056097Z","iopub.execute_input":"2022-04-06T20:14:35.056712Z","iopub.status.idle":"2022-04-06T20:14:39.092813Z","shell.execute_reply.started":"2022-04-06T20:14:35.056663Z","shell.execute_reply":"2022-04-06T20:14:39.091938Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X, y = (train.drop(['label'], axis=1), train.label)","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:14:39.094650Z","iopub.execute_input":"2022-04-06T20:14:39.094955Z","iopub.status.idle":"2022-04-06T20:14:39.245245Z","shell.execute_reply.started":"2022-04-06T20:14:39.094916Z","shell.execute_reply":"2022-04-06T20:14:39.244501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = X / 255\nX.max().max()","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:14:39.246713Z","iopub.execute_input":"2022-04-06T20:14:39.247371Z","iopub.status.idle":"2022-04-06T20:14:39.422394Z","shell.execute_reply.started":"2022-04-06T20:14:39.247327Z","shell.execute_reply":"2022-04-06T20:14:39.421580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test = test / 255","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:14:39.424765Z","iopub.execute_input":"2022-04-06T20:14:39.425077Z","iopub.status.idle":"2022-04-06T20:14:39.435084Z","shell.execute_reply.started":"2022-04-06T20:14:39.425038Z","shell.execute_reply":"2022-04-06T20:14:39.434334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn import svm\nfrom sklearn.metrics import accuracy_score","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:14:39.436334Z","iopub.execute_input":"2022-04-06T20:14:39.436636Z","iopub.status.idle":"2022-04-06T20:14:39.441183Z","shell.execute_reply.started":"2022-04-06T20:14:39.436604Z","shell.execute_reply":"2022-04-06T20:14:39.440581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"svc = svm.SVC(kernel = \"rbf\", C=4, cache_size=1000)\nfitted = svc.fit(X, y)","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:15:19.012069Z","iopub.execute_input":"2022-04-06T20:15:19.012453Z","iopub.status.idle":"2022-04-06T20:19:13.783626Z","shell.execute_reply.started":"2022-04-06T20:15:19.012420Z","shell.execute_reply":"2022-04-06T20:19:13.782803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainPred = fitted.predict(X)\n\nprint(\"Final training score for XGB: \", accuracy_score(y, trainPred))\n\ntest_x = test.values[:,1:]\nxgbTestPred = fitted.predict(test_x)","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:19:36.774997Z","iopub.execute_input":"2022-04-06T20:19:36.775481Z","iopub.status.idle":"2022-04-06T20:30:15.916687Z","shell.execute_reply.started":"2022-04-06T20:19:36.775433Z","shell.execute_reply":"2022-04-06T20:30:15.915174Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['label'] = xgbTestPred\nsubmission.to_csv('submission.csv', index=False)\nsubmission.head()","metadata":{"execution":{"iopub.status.busy":"2022-04-06T20:30:20.811457Z","iopub.execute_input":"2022-04-06T20:30:20.811797Z","iopub.status.idle":"2022-04-06T20:30:20.843959Z","shell.execute_reply.started":"2022-04-06T20:30:20.811754Z","shell.execute_reply":"2022-04-06T20:30:20.843118Z"},"trusted":true},"execution_count":null,"outputs":[]}]}