{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":84896,"databundleVersionId":10305135,"sourceType":"competition"}],"dockerImageVersionId":30804,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"id":"038e5cfa-912c-404f-ae48-6d31480aa549","cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn.model_selection import train_test_split","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:06:23.811945Z","iopub.execute_input":"2024-12-03T22:06:23.812642Z","iopub.status.idle":"2024-12-03T22:06:23.819003Z","shell.execute_reply.started":"2024-12-03T22:06:23.812571Z","shell.execute_reply":"2024-12-03T22:06:23.817641Z"}},"outputs":[],"execution_count":null},{"id":"dfce5f0d-aa75-4a01-8a06-1d4688ea69dd","cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/playground-series-s4e12/train.csv')\ntest_df = pd.read_csv('/kaggle/input/playground-series-s4e12/test.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:06:44.482583Z","iopub.execute_input":"2024-12-03T22:06:44.482987Z","iopub.status.idle":"2024-12-03T22:06:55.688296Z","shell.execute_reply.started":"2024-12-03T22:06:44.482956Z","shell.execute_reply":"2024-12-03T22:06:55.686735Z"}},"outputs":[],"execution_count":null},{"id":"0e7f9d94-4cc0-493c-ba05-733ba12aadb2","cell_type":"code","source":"train_df.shape, test_df.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:21.601261Z","iopub.execute_input":"2024-12-03T22:07:21.601685Z","iopub.status.idle":"2024-12-03T22:07:21.60885Z","shell.execute_reply.started":"2024-12-03T22:07:21.601639Z","shell.execute_reply":"2024-12-03T22:07:21.607673Z"}},"outputs":[],"execution_count":null},{"id":"47a9788e-cbe3-4205-96ae-84a2abd09d4b","cell_type":"code","source":"train_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:23.052666Z","iopub.execute_input":"2024-12-03T22:07:23.053073Z","iopub.status.idle":"2024-12-03T22:07:23.784217Z","shell.execute_reply.started":"2024-12-03T22:07:23.053039Z","shell.execute_reply":"2024-12-03T22:07:23.782812Z"}},"outputs":[],"execution_count":null},{"id":"73cf863f-9947-4b5a-b4fa-e7b868a44a59","cell_type":"code","source":"test_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:30.3731Z","iopub.execute_input":"2024-12-03T22:07:30.373461Z","iopub.status.idle":"2024-12-03T22:07:30.808834Z","shell.execute_reply.started":"2024-12-03T22:07:30.373431Z","shell.execute_reply":"2024-12-03T22:07:30.807666Z"}},"outputs":[],"execution_count":null},{"id":"1008c674-4084-46dc-b683-e8c77f6c5925","cell_type":"code","source":"train_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:34.585185Z","iopub.execute_input":"2024-12-03T22:07:34.5857Z","iopub.status.idle":"2024-12-03T22:07:34.620891Z","shell.execute_reply.started":"2024-12-03T22:07:34.585666Z","shell.execute_reply":"2024-12-03T22:07:34.619791Z"}},"outputs":[],"execution_count":null},{"id":"b3c672cc-18bb-4bb8-b7b3-c8d6a916b7d9","cell_type":"code","source":"train_df.columns = train_df.columns.str.lower().str.replace(\" \", \"_\")\ntest_df.columns = test_df.columns.str.lower().str.replace(\" \", \"_\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:37.03449Z","iopub.execute_input":"2024-12-03T22:07:37.03536Z","iopub.status.idle":"2024-12-03T22:07:37.041748Z","shell.execute_reply.started":"2024-12-03T22:07:37.035309Z","shell.execute_reply":"2024-12-03T22:07:37.040474Z"}},"outputs":[],"execution_count":null},{"id":"e9a1839e-438c-438c-bf03-e893348dce8d","cell_type":"code","source":"train_df = train_df.drop(\"id\", axis=1)\n\n# y = train_df[\"premium_amount\"]\n# X = train_df.drop(\"premium_amount\", axis=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:38.840128Z","iopub.execute_input":"2024-12-03T22:07:38.840486Z","iopub.status.idle":"2024-12-03T22:07:39.006002Z","shell.execute_reply.started":"2024-12-03T22:07:38.840456Z","shell.execute_reply":"2024-12-03T22:07:39.004949Z"}},"outputs":[],"execution_count":null},{"id":"072e0e44-43e1-4b1a-8801-57d8f4bbecd3","cell_type":"code","source":"X_train, X_test = train_test_split(train_df, test_size=0.2, random_state=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:39.239915Z","iopub.execute_input":"2024-12-03T22:07:39.240324Z","iopub.status.idle":"2024-12-03T22:07:40.385542Z","shell.execute_reply.started":"2024-12-03T22:07:39.240284Z","shell.execute_reply":"2024-12-03T22:07:40.384441Z"}},"outputs":[],"execution_count":null},{"id":"dbc67fe7-64e8-440f-bc08-84e0e8f6da4c","cell_type":"code","source":"X_train","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:40.387216Z","iopub.execute_input":"2024-12-03T22:07:40.38756Z","iopub.status.idle":"2024-12-03T22:07:40.415018Z","shell.execute_reply.started":"2024-12-03T22:07:40.387528Z","shell.execute_reply":"2024-12-03T22:07:40.41375Z"}},"outputs":[],"execution_count":null},{"id":"93f5d2e8-3571-4dac-8ebf-7d891e7fd41a","cell_type":"code","source":"X_train.corr(numeric_only=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:41.177334Z","iopub.execute_input":"2024-12-03T22:07:41.177745Z","iopub.status.idle":"2024-12-03T22:07:41.444559Z","shell.execute_reply.started":"2024-12-03T22:07:41.177709Z","shell.execute_reply":"2024-12-03T22:07:41.443386Z"}},"outputs":[],"execution_count":null},{"id":"8de622f0-3147-4ab0-858e-f62550d60b00","cell_type":"markdown","source":"```\nprevious_claims and credit_score are +vely correlated. \n\nannual_income and credit_score are -vely correlated (stronger). \n```","metadata":{}},{"id":"44518eff-a5fe-4e2b-bd47-196c01cd26c6","cell_type":"code","source":"X_train.hist(bins=50, figsize=(10, 8))\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:42.495142Z","iopub.execute_input":"2024-12-03T22:07:42.496025Z","iopub.status.idle":"2024-12-03T22:07:44.713142Z","shell.execute_reply.started":"2024-12-03T22:07:42.495988Z","shell.execute_reply":"2024-12-03T22:07:44.711866Z"}},"outputs":[],"execution_count":null},{"id":"996b4b3d-2998-4b10-bead-9258ebd45f40","cell_type":"markdown","source":"```\nnumber_of_dependents, previous_claims, vehicle_age, insurance_duration are all categorical, not continuous. \n```","metadata":{}},{"id":"0c64a215-bcca-4058-90f4-123a9f4b618f","cell_type":"code","source":"X_train.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-03T22:07:44.715197Z","iopub.execute_input":"2024-12-03T22:07:44.715743Z","iopub.status.idle":"2024-12-03T22:07:45.277153Z","shell.execute_reply.started":"2024-12-03T22:07:44.715678Z","shell.execute_reply":"2024-12-03T22:07:45.275958Z"}},"outputs":[],"execution_count":null},{"id":"f2d366e0-bca6-4ff2-955f-d2465f3a7247","cell_type":"code","source":"# from sklearn.impute import SimpleImputer\n# from sklearn.preprocessing import StandardScaler\n# from sklearn.preprocessing import OneHotEncoder","metadata":{},"outputs":[],"execution_count":null},{"id":"b92ff5dd-0c62-4099-9596-5a0505ff7a7f","cell_type":"code","source":"","metadata":{},"outputs":[],"execution_count":null}]}