{"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":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.028576,"end_time":"2023-01-04T16:19:44.024193","exception":false,"start_time":"2023-01-04T16:19:43.995617","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-09T13:43:45.050249Z","iopub.execute_input":"2023-01-09T13:43:45.050801Z","iopub.status.idle":"2023-01-09T13:43:45.062223Z","shell.execute_reply.started":"2023-01-09T13:43:45.050737Z","shell.execute_reply":"2023-01-09T13:43:45.060869Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ntrain_df = pd.read_csv(\"/kaggle/input/emsi-5iir-ds/train.csv\")\ntest_df = pd.read_csv(\"/kaggle/input/emsi-5iir-ds/test.csv\")","metadata":{"papermill":{"duration":17.206131,"end_time":"2023-01-04T16:20:02.569106","exception":false,"start_time":"2023-01-04T16:19:45.362975","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-09T13:43:45.065619Z","iopub.execute_input":"2023-01-09T13:43:45.066239Z","iopub.status.idle":"2023-01-09T13:44:07.772734Z","shell.execute_reply.started":"2023-01-09T13:43:45.066178Z","shell.execute_reply":"2023-01-09T13:44:07.771399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X=train_df.drop([\"id\",\"target\", 'f_27'],axis=1)\ny=train_df[\"target\"]\nX.head()","metadata":{"papermill":{"duration":0.134934,"end_time":"2023-01-04T16:20:03.515886","exception":false,"start_time":"2023-01-04T16:20:03.380952","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-01-09T13:44:07.774463Z","iopub.execute_input":"2023-01-09T13:44:07.775039Z","iopub.status.idle":"2023-01-09T13:44:07.941978Z","shell.execute_reply.started":"2023-01-09T13:44:07.774975Z","shell.execute_reply":"2023-01-09T13:44:07.940618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:44:07.943819Z","iopub.execute_input":"2023-01-09T13:44:07.944396Z","iopub.status.idle":"2023-01-09T13:44:07.954153Z","shell.execute_reply.started":"2023-01-09T13:44:07.944344Z","shell.execute_reply":"2023-01-09T13:44:07.952914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfrom sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.4, test_size=0.1)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:56:32.068189Z","iopub.execute_input":"2023-01-09T13:56:32.068632Z","iopub.status.idle":"2023-01-09T13:56:32.427411Z","shell.execute_reply.started":"2023-01-09T13:56:32.068597Z","shell.execute_reply":"2023-01-09T13:56:32.425777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"train_test_split is a function that splits a dataset into two subsets: a training set and a testing set. The train_test_split function takes a number of inputs,","metadata":{}},{"cell_type":"code","source":"from sklearn import svm\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.linear_model import LogisticRegression\n\n# Create a logistic regression classifier object\nclf = LogisticRegression()\n\n# Train the classifier using the training data\nclf.fit(X_train, y_train)\n\n# Make predictions on the test data\npredictions = clf.predict(X_test)\n\n# Evaluate the performance of the classifier\naccuracy = accuracy_score(y_test, predictions)\nprint(\"Accuracy:\", accuracy)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:56:34.684600Z","iopub.execute_input":"2023-01-09T13:56:34.685117Z","iopub.status.idle":"2023-01-09T13:56:44.076759Z","shell.execute_reply.started":"2023-01-09T13:56:34.685075Z","shell.execute_reply":"2023-01-09T13:56:44.075328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = test_df[['id']]\nx_test = test_df.drop([\"id\",'f_27'],axis=1)\nsubmission['target'] =  clf.predict(x_test);","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:44:17.500250Z","iopub.execute_input":"2023-01-09T13:44:17.501361Z","iopub.status.idle":"2023-01-09T13:44:17.766390Z","shell.execute_reply.started":"2023-01-09T13:44:17.501302Z","shell.execute_reply":"2023-01-09T13:44:17.764903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['target']","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:44:17.768601Z","iopub.execute_input":"2023-01-09T13:44:17.769667Z","iopub.status.idle":"2023-01-09T13:44:17.784929Z","shell.execute_reply.started":"2023-01-09T13:44:17.769602Z","shell.execute_reply":"2023-01-09T13:44:17.783471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)\nsubmission","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:44:17.787262Z","iopub.execute_input":"2023-01-09T13:44:17.789330Z","iopub.status.idle":"2023-01-09T13:44:18.602670Z","shell.execute_reply.started":"2023-01-09T13:44:17.789251Z","shell.execute_reply":"2023-01-09T13:44:18.601202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from IPython.display import HTML\nimport pandas as pd\nimport numpy as np\n\ndef create_download_link(title = \"Download CSV file\", filename = \"data.csv\"):  \n    html = '<a href={filename}>{title}</a>'\n    html = html.format(title=title,filename=filename)\n    return HTML(html)\ncreate_download_link(filename='submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T13:44:18.604720Z","iopub.execute_input":"2023-01-09T13:44:18.605244Z","iopub.status.idle":"2023-01-09T13:44:18.615508Z","shell.execute_reply.started":"2023-01-09T13:44:18.605199Z","shell.execute_reply":"2023-01-09T13:44:18.613939Z"},"trusted":true},"execution_count":null,"outputs":[]}]}