{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"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":[{"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","trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:04.174838Z","iopub.execute_input":"2024-12-09T17:33:04.175221Z","iopub.status.idle":"2024-12-09T17:33:04.586808Z","shell.execute_reply.started":"2024-12-09T17:33:04.175185Z","shell.execute_reply":"2024-12-09T17:33:04.585579Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import MinMaxScaler,StandardScaler,LabelEncoder\nfrom sklearn.linear_model import Ridge,RidgeCV,Lasso,LassoCV\nimport statsmodels.formula.api as smf\nimport math","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:04.589122Z","iopub.execute_input":"2024-12-09T17:33:04.58973Z","iopub.status.idle":"2024-12-09T17:33:05.425882Z","shell.execute_reply.started":"2024-12-09T17:33:04.589681Z","shell.execute_reply":"2024-12-09T17:33:05.424715Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train=pd.read_csv('/kaggle/input/playground-series-s4e12/train.csv')\ndata_test=pd.read_csv('/kaggle/input/playground-series-s4e12/test.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:05.427023Z","iopub.execute_input":"2024-12-09T17:33:05.427487Z","iopub.status.idle":"2024-12-09T17:33:13.321657Z","shell.execute_reply.started":"2024-12-09T17:33:05.427454Z","shell.execute_reply":"2024-12-09T17:33:13.320248Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:13.32488Z","iopub.execute_input":"2024-12-09T17:33:13.325417Z","iopub.status.idle":"2024-12-09T17:33:13.357389Z","shell.execute_reply.started":"2024-12-09T17:33:13.325341Z","shell.execute_reply":"2024-12-09T17:33:13.356259Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:13.358986Z","iopub.execute_input":"2024-12-09T17:33:13.359469Z","iopub.status.idle":"2024-12-09T17:33:13.385492Z","shell.execute_reply.started":"2024-12-09T17:33:13.359418Z","shell.execute_reply":"2024-12-09T17:33:13.384228Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:13.3872Z","iopub.execute_input":"2024-12-09T17:33:13.387622Z","iopub.status.idle":"2024-12-09T17:33:13.401833Z","shell.execute_reply.started":"2024-12-09T17:33:13.387586Z","shell.execute_reply":"2024-12-09T17:33:13.400733Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:13.403153Z","iopub.execute_input":"2024-12-09T17:33:13.403517Z","iopub.status.idle":"2024-12-09T17:33:13.422671Z","shell.execute_reply.started":"2024-12-09T17:33:13.403482Z","shell.execute_reply":"2024-12-09T17:33:13.421428Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:13.424042Z","iopub.execute_input":"2024-12-09T17:33:13.424437Z","iopub.status.idle":"2024-12-09T17:33:14.075304Z","shell.execute_reply.started":"2024-12-09T17:33:13.424378Z","shell.execute_reply":"2024-12-09T17:33:14.074026Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:14.077005Z","iopub.execute_input":"2024-12-09T17:33:14.077493Z","iopub.status.idle":"2024-12-09T17:33:14.511521Z","shell.execute_reply.started":"2024-12-09T17:33:14.077443Z","shell.execute_reply":"2024-12-09T17:33:14.510418Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:14.514818Z","iopub.execute_input":"2024-12-09T17:33:14.515181Z","iopub.status.idle":"2024-12-09T17:33:15.153654Z","shell.execute_reply.started":"2024-12-09T17:33:14.515147Z","shell.execute_reply":"2024-12-09T17:33:15.152603Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:15.155087Z","iopub.execute_input":"2024-12-09T17:33:15.15555Z","iopub.status.idle":"2024-12-09T17:33:15.581369Z","shell.execute_reply.started":"2024-12-09T17:33:15.1555Z","shell.execute_reply":"2024-12-09T17:33:15.580259Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.duplicated()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:15.582699Z","iopub.execute_input":"2024-12-09T17:33:15.583007Z","iopub.status.idle":"2024-12-09T17:33:17.303679Z","shell.execute_reply.started":"2024-12-09T17:33:15.582977Z","shell.execute_reply":"2024-12-09T17:33:17.302339Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.duplicated()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:17.305291Z","iopub.execute_input":"2024-12-09T17:33:17.305906Z","iopub.status.idle":"2024-12-09T17:33:18.354282Z","shell.execute_reply.started":"2024-12-09T17:33:17.305841Z","shell.execute_reply":"2024-12-09T17:33:18.353167Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.kdeplot(data=data_train,x='Premium Amount',color='steelblue',fill=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:18.355428Z","iopub.execute_input":"2024-12-09T17:33:18.355724Z","iopub.status.idle":"2024-12-09T17:33:23.432439Z","shell.execute_reply.started":"2024-12-09T17:33:18.355695Z","shell.execute_reply":"2024-12-09T17:33:23.431264Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax=plt.subplots(1, 2,figsize=(15, 7))\n\nplt_1 = sns.scatterplot(data=data_train,x='Age',y='Premium Amount',ax=ax[0])\nplt_2 = sns.boxplot(data=data_train,x='Gender',y='Premium Amount',ax=ax[1]);","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:23.433876Z","iopub.execute_input":"2024-12-09T17:33:23.434215Z","iopub.status.idle":"2024-12-09T17:33:29.112531Z","shell.execute_reply.started":"2024-12-09T17:33:23.434181Z","shell.execute_reply":"2024-12-09T17:33:29.111435Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15, 7))\n\nplt_1 = sns.boxplot(data=data_train, x='Number of Dependents', y='Premium Amount', ax=ax[0])\nplt_2 = sns.boxplot(data=data_train, x='Marital Status', y='Premium Amount', ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:29.113968Z","iopub.execute_input":"2024-12-09T17:33:29.114414Z","iopub.status.idle":"2024-12-09T17:33:30.615699Z","shell.execute_reply.started":"2024-12-09T17:33:29.114341Z","shell.execute_reply":"2024-12-09T17:33:30.614612Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.boxplot(data=data_train,x='Education Level', y='Premium Amount', ax=ax[0])\nplt_2= sns.boxplot(data=data_train, x='Occupation', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:30.617311Z","iopub.execute_input":"2024-12-09T17:33:30.6178Z","iopub.status.idle":"2024-12-09T17:33:32.421382Z","shell.execute_reply.started":"2024-12-09T17:33:30.617753Z","shell.execute_reply":"2024-12-09T17:33:32.420396Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.scatterplot(data=data_train,x='Health Score', y='Premium Amount', ax=ax[0])\nplt_2= sns.boxplot(data=data_train, x='Location', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:32.422806Z","iopub.execute_input":"2024-12-09T17:33:32.423213Z","iopub.status.idle":"2024-12-09T17:33:37.892201Z","shell.execute_reply.started":"2024-12-09T17:33:32.423167Z","shell.execute_reply":"2024-12-09T17:33:37.891125Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.boxplot(data=data_train,x='Previous Claims', y='Premium Amount', ax=ax[0])\nplt_2= sns.boxplot(data=data_train, x='Policy Type', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:37.893667Z","iopub.execute_input":"2024-12-09T17:33:37.894063Z","iopub.status.idle":"2024-12-09T17:33:39.44298Z","shell.execute_reply.started":"2024-12-09T17:33:37.89402Z","shell.execute_reply":"2024-12-09T17:33:39.441805Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.boxplot(data=data_train,x='Vehicle Age', y='Premium Amount', ax=ax[0])\nplt_2= sns.scatterplot(data=data_train, x='Credit Score', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:39.444239Z","iopub.execute_input":"2024-12-09T17:33:39.444553Z","iopub.status.idle":"2024-12-09T17:33:44.748995Z","shell.execute_reply.started":"2024-12-09T17:33:39.444523Z","shell.execute_reply":"2024-12-09T17:33:44.747833Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.boxplot(data=data_train,x='Customer Feedback', y='Premium Amount', ax=ax[0])\nplt_2= sns.boxplot(data=data_train, x='Insurance Duration', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:44.750287Z","iopub.execute_input":"2024-12-09T17:33:44.750634Z","iopub.status.idle":"2024-12-09T17:33:46.321727Z","shell.execute_reply.started":"2024-12-09T17:33:44.750603Z","shell.execute_reply":"2024-12-09T17:33:46.320589Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.boxplot(data=data_train,x='Smoking Status', y='Premium Amount', ax=ax[0])\nplt_2= sns.boxplot(data=data_train, x='Exercise Frequency', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:46.323107Z","iopub.execute_input":"2024-12-09T17:33:46.323472Z","iopub.status.idle":"2024-12-09T17:33:48.13441Z","shell.execute_reply.started":"2024-12-09T17:33:46.323438Z","shell.execute_reply":"2024-12-09T17:33:48.133433Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig, ax = plt.subplots(1, 2, figsize=(15,7))\n\nplt_1=sns.scatterplot(data=data_train,x='Annual Income', y='Premium Amount', ax=ax[0])\nplt_2= sns.boxplot(data=data_train, x='Property Type', y='Premium Amount',ax=ax[1]);\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:48.135967Z","iopub.execute_input":"2024-12-09T17:33:48.136717Z","iopub.status.idle":"2024-12-09T17:33:53.806926Z","shell.execute_reply.started":"2024-12-09T17:33:48.13667Z","shell.execute_reply":"2024-12-09T17:33:53.805766Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def insurance(df):\n    df['Gender']=df['Gender'].map({'Female':0,'Male':1})\n    df['Smoking Status']=df['Smoking Status'].map({'No':0,'Yes':1})\n    df['Previous Claims']=df['Previous Claims'].clip(None,8)\n    return df\n\nx=insurance(data_train)\ny=insurance(data_test)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:53.808724Z","iopub.execute_input":"2024-12-09T17:33:53.809213Z","iopub.status.idle":"2024-12-09T17:33:54.090987Z","shell.execute_reply.started":"2024-12-09T17:33:53.809166Z","shell.execute_reply":"2024-12-09T17:33:54.090152Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:54.092635Z","iopub.execute_input":"2024-12-09T17:33:54.092974Z","iopub.status.idle":"2024-12-09T17:33:54.099685Z","shell.execute_reply.started":"2024-12-09T17:33:54.092942Z","shell.execute_reply":"2024-12-09T17:33:54.098664Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:54.101091Z","iopub.execute_input":"2024-12-09T17:33:54.101501Z","iopub.status.idle":"2024-12-09T17:33:54.114555Z","shell.execute_reply.started":"2024-12-09T17:33:54.101468Z","shell.execute_reply":"2024-12-09T17:33:54.113491Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:54.11598Z","iopub.execute_input":"2024-12-09T17:33:54.116453Z","iopub.status.idle":"2024-12-09T17:33:54.65951Z","shell.execute_reply.started":"2024-12-09T17:33:54.1164Z","shell.execute_reply":"2024-12-09T17:33:54.658446Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:54.666783Z","iopub.execute_input":"2024-12-09T17:33:54.667094Z","iopub.status.idle":"2024-12-09T17:33:55.025473Z","shell.execute_reply.started":"2024-12-09T17:33:54.667065Z","shell.execute_reply":"2024-12-09T17:33:55.024389Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:55.02701Z","iopub.execute_input":"2024-12-09T17:33:55.027465Z","iopub.status.idle":"2024-12-09T17:33:55.93525Z","shell.execute_reply.started":"2024-12-09T17:33:55.027417Z","shell.execute_reply":"2024-12-09T17:33:55.934156Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:55.936436Z","iopub.execute_input":"2024-12-09T17:33:55.936716Z","iopub.status.idle":"2024-12-09T17:33:56.452088Z","shell.execute_reply.started":"2024-12-09T17:33:55.936687Z","shell.execute_reply":"2024-12-09T17:33:56.451165Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"col=['Age','Annual Income','Health Score','Previous Claims','Credit Score']\ndata_train[col]=data_train[col].fillna(data_train[col].mean())\ndata_test[col]=data_test[col].fillna(data_test[col].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:56.453977Z","iopub.execute_input":"2024-12-09T17:33:56.454411Z","iopub.status.idle":"2024-12-09T17:33:56.754925Z","shell.execute_reply.started":"2024-12-09T17:33:56.45434Z","shell.execute_reply":"2024-12-09T17:33:56.75405Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Marital Status'].fillna(value='unknown',inplace=True)\ndata_train.replace({'Marital Status':{'Single':0,'Married':1,'Divorced':2,'unknown':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:56.756133Z","iopub.execute_input":"2024-12-09T17:33:56.756594Z","iopub.status.idle":"2024-12-09T17:33:57.342211Z","shell.execute_reply.started":"2024-12-09T17:33:56.756546Z","shell.execute_reply":"2024-12-09T17:33:57.341095Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Marital Status'].fillna(value='unknown',inplace=True)\ndata_test.replace({'Marital Status':{'Single':0,'Married':1,'Divorced':2,'unknown':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:57.343634Z","iopub.execute_input":"2024-12-09T17:33:57.343965Z","iopub.status.idle":"2024-12-09T17:33:57.722618Z","shell.execute_reply.started":"2024-12-09T17:33:57.343934Z","shell.execute_reply":"2024-12-09T17:33:57.721563Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Number of Dependents'].fillna(value=0,inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:57.723845Z","iopub.execute_input":"2024-12-09T17:33:57.724163Z","iopub.status.idle":"2024-12-09T17:33:57.734627Z","shell.execute_reply.started":"2024-12-09T17:33:57.724133Z","shell.execute_reply":"2024-12-09T17:33:57.733507Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Number of Dependents'].fillna(value=0,inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:57.735932Z","iopub.execute_input":"2024-12-09T17:33:57.736257Z","iopub.status.idle":"2024-12-09T17:33:57.748611Z","shell.execute_reply.started":"2024-12-09T17:33:57.736225Z","shell.execute_reply":"2024-12-09T17:33:57.747578Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Occupation'].fillna(value='unknown',inplace=True)\ndata_train.replace({'Occupation':{'Self-Employed':0,'Unemployed':1,'Employed':2,'unknown':3}},inplace=True)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:57.749886Z","iopub.execute_input":"2024-12-09T17:33:57.750206Z","iopub.status.idle":"2024-12-09T17:33:58.319922Z","shell.execute_reply.started":"2024-12-09T17:33:57.750174Z","shell.execute_reply":"2024-12-09T17:33:58.318873Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Occupation'].fillna(value='unknown',inplace=True)\ndata_test.replace({'Occupation':{'Self-Employed':0,'Unemployed':1,'Employed':2,'unknown':3}},inplace=True)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:58.321165Z","iopub.execute_input":"2024-12-09T17:33:58.321507Z","iopub.status.idle":"2024-12-09T17:33:58.696279Z","shell.execute_reply.started":"2024-12-09T17:33:58.321475Z","shell.execute_reply":"2024-12-09T17:33:58.695183Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Customer Feedback'].fillna(value='unknown',inplace=True)\ndata_train.replace({'Customer Feedback':{'Poor':0,'Good':1,'Average':2,'unknown':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:58.697867Z","iopub.execute_input":"2024-12-09T17:33:58.698321Z","iopub.status.idle":"2024-12-09T17:33:59.29941Z","shell.execute_reply.started":"2024-12-09T17:33:58.69827Z","shell.execute_reply":"2024-12-09T17:33:59.29821Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Customer Feedback'].fillna(value='unknown',inplace=True)\ndata_test.replace({'Customer Feedback':{'Poor':0,'Good':1,'Average':2,'unknown':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:59.300726Z","iopub.execute_input":"2024-12-09T17:33:59.301079Z","iopub.status.idle":"2024-12-09T17:33:59.693044Z","shell.execute_reply.started":"2024-12-09T17:33:59.301047Z","shell.execute_reply":"2024-12-09T17:33:59.691857Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Vehicle Age']=data_test['Vehicle Age'].fillna(data_test['Vehicle Age'].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:59.694331Z","iopub.execute_input":"2024-12-09T17:33:59.694658Z","iopub.status.idle":"2024-12-09T17:33:59.739058Z","shell.execute_reply.started":"2024-12-09T17:33:59.694628Z","shell.execute_reply":"2024-12-09T17:33:59.737937Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Vehicle Age']=data_test['Vehicle Age'].fillna(data_test['Vehicle Age'].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:59.740226Z","iopub.execute_input":"2024-12-09T17:33:59.740583Z","iopub.status.idle":"2024-12-09T17:33:59.755427Z","shell.execute_reply.started":"2024-12-09T17:33:59.740549Z","shell.execute_reply":"2024-12-09T17:33:59.754068Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Insurance Duration']=data_test['Insurance Duration'].fillna(data_test['Insurance Duration'].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:59.756879Z","iopub.execute_input":"2024-12-09T17:33:59.757173Z","iopub.status.idle":"2024-12-09T17:33:59.801023Z","shell.execute_reply.started":"2024-12-09T17:33:59.757144Z","shell.execute_reply":"2024-12-09T17:33:59.799887Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Insurance Duration']=data_test['Insurance Duration'].fillna(data_test['Insurance Duration'].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:59.80218Z","iopub.execute_input":"2024-12-09T17:33:59.802566Z","iopub.status.idle":"2024-12-09T17:33:59.816789Z","shell.execute_reply.started":"2024-12-09T17:33:59.802502Z","shell.execute_reply":"2024-12-09T17:33:59.815563Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Exercise Frequency'].unique()\ndata_train.replace({'Exercise Frequency':{'Weekly':0,'Rarely':1,'Monthly':2,'Daily':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:33:59.81821Z","iopub.execute_input":"2024-12-09T17:33:59.818588Z","iopub.status.idle":"2024-12-09T17:34:00.427635Z","shell.execute_reply.started":"2024-12-09T17:33:59.818546Z","shell.execute_reply":"2024-12-09T17:34:00.426331Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Exercise Frequency'].unique()\ndata_test.replace({'Exercise Frequency':{'Weekly':0,'Rarely':1,'Monthly':2,'Daily':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:00.428943Z","iopub.execute_input":"2024-12-09T17:34:00.429237Z","iopub.status.idle":"2024-12-09T17:34:00.81826Z","shell.execute_reply.started":"2024-12-09T17:34:00.429207Z","shell.execute_reply":"2024-12-09T17:34:00.817032Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Property Type'].unique()\ndata_train.replace({'Property Type':{'House':0,'Apartment':1,'Condo':2}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:00.819469Z","iopub.execute_input":"2024-12-09T17:34:00.819808Z","iopub.status.idle":"2024-12-09T17:34:01.367997Z","shell.execute_reply.started":"2024-12-09T17:34:00.819775Z","shell.execute_reply":"2024-12-09T17:34:01.366902Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Property Type'].unique()\ndata_test.replace({'Property Type':{'House':0,'Apartment':1,'Condo':2}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:01.369256Z","iopub.execute_input":"2024-12-09T17:34:01.369608Z","iopub.status.idle":"2024-12-09T17:34:01.726099Z","shell.execute_reply.started":"2024-12-09T17:34:01.369575Z","shell.execute_reply":"2024-12-09T17:34:01.725031Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Education Level'].unique()\ndata_train.replace({'Education Level':{\"Bachelor's\":0,\"Master's\":1,'PhD':2,'High School':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:01.727322Z","iopub.execute_input":"2024-12-09T17:34:01.72769Z","iopub.status.idle":"2024-12-09T17:34:02.302905Z","shell.execute_reply.started":"2024-12-09T17:34:01.727658Z","shell.execute_reply":"2024-12-09T17:34:02.301551Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Education Level'].unique()\ndata_test.replace({'Education Level':{\"Bachelor's\":0,\"Master's\":1,'PhD':2,'High School':3}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:02.304123Z","iopub.execute_input":"2024-12-09T17:34:02.304455Z","iopub.status.idle":"2024-12-09T17:34:02.699447Z","shell.execute_reply.started":"2024-12-09T17:34:02.304422Z","shell.execute_reply":"2024-12-09T17:34:02.698252Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Location'].unique()\ndata_train.replace({'Location':{'Rural':0,'Suburban':1,'Urban':2}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:02.701099Z","iopub.execute_input":"2024-12-09T17:34:02.701578Z","iopub.status.idle":"2024-12-09T17:34:03.247346Z","shell.execute_reply.started":"2024-12-09T17:34:02.70153Z","shell.execute_reply":"2024-12-09T17:34:03.246136Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Location'].unique()\ndata_test.replace({'Location':{'Rural':0,'Suburban':1,'Urban':2}},inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:03.248978Z","iopub.execute_input":"2024-12-09T17:34:03.249267Z","iopub.status.idle":"2024-12-09T17:34:03.610416Z","shell.execute_reply.started":"2024-12-09T17:34:03.249239Z","shell.execute_reply":"2024-12-09T17:34:03.609327Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train['Policy Type'].unique()\ndata_train.replace({'Policy Type':{'Basic':0,'Premium':1,'Comprehensive':2}},inplace=True)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:03.611612Z","iopub.execute_input":"2024-12-09T17:34:03.61192Z","iopub.status.idle":"2024-12-09T17:34:04.137724Z","shell.execute_reply.started":"2024-12-09T17:34:03.611889Z","shell.execute_reply":"2024-12-09T17:34:04.136632Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test['Policy Type'].unique()\ndata_test.replace({'Policy Type':{'Basic':0,'Premium':1,'Comprehensive':2}},inplace=True)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:04.13931Z","iopub.execute_input":"2024-12-09T17:34:04.13977Z","iopub.status.idle":"2024-12-09T17:34:04.49267Z","shell.execute_reply.started":"2024-12-09T17:34:04.139723Z","shell.execute_reply":"2024-12-09T17:34:04.491477Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train = data_train.drop(columns = ['Policy Start Date'])\ndata_train = data_train.drop(columns = ['Vehicle Age','Insurance Duration'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:04.493916Z","iopub.execute_input":"2024-12-09T17:34:04.49423Z","iopub.status.idle":"2024-12-09T17:34:04.769605Z","shell.execute_reply.started":"2024-12-09T17:34:04.4942Z","shell.execute_reply":"2024-12-09T17:34:04.768616Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test = data_test.drop(columns = ['Policy Start Date'])\ndata_test = data_test.drop(columns = ['Vehicle Age','Insurance Duration'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:04.770966Z","iopub.execute_input":"2024-12-09T17:34:04.771303Z","iopub.status.idle":"2024-12-09T17:34:04.898644Z","shell.execute_reply.started":"2024-12-09T17:34:04.771269Z","shell.execute_reply":"2024-12-09T17:34:04.897628Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:04.899843Z","iopub.execute_input":"2024-12-09T17:34:04.900175Z","iopub.status.idle":"2024-12-09T17:34:04.920219Z","shell.execute_reply.started":"2024-12-09T17:34:04.900143Z","shell.execute_reply":"2024-12-09T17:34:04.918969Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_test.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:04.921861Z","iopub.execute_input":"2024-12-09T17:34:04.922317Z","iopub.status.idle":"2024-12-09T17:34:04.944636Z","shell.execute_reply.started":"2024-12-09T17:34:04.922266Z","shell.execute_reply":"2024-12-09T17:34:04.943442Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train=pd.get_dummies(data_train,drop_first=True)\ndata_test=pd.get_dummies(data_test,drop_first=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:04.946153Z","iopub.execute_input":"2024-12-09T17:34:04.946519Z","iopub.status.idle":"2024-12-09T17:34:05.332443Z","shell.execute_reply.started":"2024-12-09T17:34:04.946485Z","shell.execute_reply":"2024-12-09T17:34:05.33154Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\nmodel=LinearRegression()\nfrom sklearn.ensemble import RandomForestRegressor","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:05.333654Z","iopub.execute_input":"2024-12-09T17:34:05.33399Z","iopub.status.idle":"2024-12-09T17:34:05.377443Z","shell.execute_reply.started":"2024-12-09T17:34:05.333959Z","shell.execute_reply":"2024-12-09T17:34:05.376225Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x_train=data_train.drop(columns='Premium Amount',axis=1)\ny_train=data_train['Premium Amount']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:05.378788Z","iopub.execute_input":"2024-12-09T17:34:05.379134Z","iopub.status.idle":"2024-12-09T17:34:05.433626Z","shell.execute_reply.started":"2024-12-09T17:34:05.3791Z","shell.execute_reply":"2024-12-09T17:34:05.432674Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_train.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:05.435327Z","iopub.execute_input":"2024-12-09T17:34:05.43581Z","iopub.status.idle":"2024-12-09T17:34:05.482539Z","shell.execute_reply.started":"2024-12-09T17:34:05.435763Z","shell.execute_reply":"2024-12-09T17:34:05.481424Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.fit(x_train,y_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:05.484077Z","iopub.execute_input":"2024-12-09T17:34:05.48453Z","iopub.status.idle":"2024-12-09T17:34:06.812714Z","shell.execute_reply.started":"2024-12-09T17:34:05.484483Z","shell.execute_reply":"2024-12-09T17:34:06.809116Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"prd2=model.predict(x_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:06.813981Z","iopub.execute_input":"2024-12-09T17:34:06.817651Z","iopub.status.idle":"2024-12-09T17:34:06.915894Z","shell.execute_reply.started":"2024-12-09T17:34:06.817598Z","shell.execute_reply":"2024-12-09T17:34:06.914261Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"prd=model.predict(data_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:06.917572Z","iopub.execute_input":"2024-12-09T17:34:06.918079Z","iopub.status.idle":"2024-12-09T17:34:07.030034Z","shell.execute_reply.started":"2024-12-09T17:34:06.918027Z","shell.execute_reply":"2024-12-09T17:34:07.028676Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(prd)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:07.032695Z","iopub.execute_input":"2024-12-09T17:34:07.033682Z","iopub.status.idle":"2024-12-09T17:34:07.044826Z","shell.execute_reply.started":"2024-12-09T17:34:07.033608Z","shell.execute_reply":"2024-12-09T17:34:07.043438Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_sample=pd.read_csv('/kaggle/input/playground-series-s4e12/sample_submission.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:07.046321Z","iopub.execute_input":"2024-12-09T17:34:07.049898Z","iopub.status.idle":"2024-12-09T17:34:07.278415Z","shell.execute_reply.started":"2024-12-09T17:34:07.049824Z","shell.execute_reply":"2024-12-09T17:34:07.277265Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_sample['Premium Amount']=prd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:07.279817Z","iopub.execute_input":"2024-12-09T17:34:07.281085Z","iopub.status.idle":"2024-12-09T17:34:07.287121Z","shell.execute_reply.started":"2024-12-09T17:34:07.281046Z","shell.execute_reply":"2024-12-09T17:34:07.285875Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"data_sample.to_csv('final submission.csv',index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:07.288503Z","iopub.execute_input":"2024-12-09T17:34:07.288855Z","iopub.status.idle":"2024-12-09T17:34:08.98291Z","shell.execute_reply.started":"2024-12-09T17:34:07.288822Z","shell.execute_reply":"2024-12-09T17:34:08.981642Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ssu=pd.read_csv('final submission.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:08.984974Z","iopub.execute_input":"2024-12-09T17:34:08.985527Z","iopub.status.idle":"2024-12-09T17:34:09.236532Z","shell.execute_reply.started":"2024-12-09T17:34:08.985466Z","shell.execute_reply":"2024-12-09T17:34:09.235167Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(ssu)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T17:34:09.23808Z","iopub.execute_input":"2024-12-09T17:34:09.238607Z","iopub.status.idle":"2024-12-09T17:34:09.248422Z","shell.execute_reply.started":"2024-12-09T17:34:09.238554Z","shell.execute_reply":"2024-12-09T17:34:09.247086Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}