{"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-14T11:44:56.11714Z","iopub.execute_input":"2024-12-14T11:44:56.11756Z","iopub.status.idle":"2024-12-14T11:44:56.124364Z","shell.execute_reply.started":"2024-12-14T11:44:56.117531Z","shell.execute_reply":"2024-12-14T11:44:56.123574Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Predict Insurance premium","metadata":{}},{"cell_type":"markdown","source":"**Import Libraries** ","metadata":{}},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nimport matplotlib_inline\n\nsns.set()\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:44:56.12571Z","iopub.execute_input":"2024-12-14T11:44:56.125976Z","iopub.status.idle":"2024-12-14T11:44:56.146967Z","shell.execute_reply.started":"2024-12-14T11:44:56.12595Z","shell.execute_reply":"2024-12-14T11:44:56.145563Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Load DataSet**","metadata":{}},{"cell_type":"code","source":"train_data = pd.read_csv(\"/kaggle/input/playground-series-s4e12/train.csv\")\ntest_data = pd.read_csv(\"/kaggle/input/playground-series-s4e12/test.csv\") ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:44:56.148182Z","iopub.execute_input":"2024-12-14T11:44:56.148494Z","iopub.status.idle":"2024-12-14T11:45:00.767095Z","shell.execute_reply.started":"2024-12-14T11:44:56.148469Z","shell.execute_reply":"2024-12-14T11:45:00.766201Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# from ydata_profiling import ProfileReport","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:00.768876Z","iopub.execute_input":"2024-12-14T11:45:00.769126Z","iopub.status.idle":"2024-12-14T11:45:00.774818Z","shell.execute_reply.started":"2024-12-14T11:45:00.769103Z","shell.execute_reply":"2024-12-14T11:45:00.773564Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Show Top 5 rows**","metadata":{}},{"cell_type":"code","source":"train_data.head(5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:00.775782Z","iopub.execute_input":"2024-12-14T11:45:00.776033Z","iopub.status.idle":"2024-12-14T11:45:00.807539Z","shell.execute_reply.started":"2024-12-14T11:45:00.776008Z","shell.execute_reply":"2024-12-14T11:45:00.806252Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Test Data Top 5 Rows**","metadata":{}},{"cell_type":"code","source":"test_data.head(5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:00.80906Z","iopub.execute_input":"2024-12-14T11:45:00.809497Z","iopub.status.idle":"2024-12-14T11:45:00.838904Z","shell.execute_reply.started":"2024-12-14T11:45:00.809467Z","shell.execute_reply":"2024-12-14T11:45:00.837623Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Drop Id Column**","metadata":{}},{"cell_type":"code","source":"train_data.drop(\"id\",axis=1,inplace=True)\ntest_data.drop(\"id\",axis=1,inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:00.840313Z","iopub.execute_input":"2024-12-14T11:45:00.840734Z","iopub.status.idle":"2024-12-14T11:45:01.037701Z","shell.execute_reply.started":"2024-12-14T11:45:00.840701Z","shell.execute_reply":"2024-12-14T11:45:01.036703Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Size of dataset**","metadata":{}},{"cell_type":"code","source":"print(f\"Size of Train Data Set -->> {train_data.shape}\")\nprint(f\"Size of Test Data Set -->> {test_data.shape}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:01.038878Z","iopub.execute_input":"2024-12-14T11:45:01.039094Z","iopub.status.idle":"2024-12-14T11:45:01.044878Z","shell.execute_reply.started":"2024-12-14T11:45:01.039073Z","shell.execute_reply":"2024-12-14T11:45:01.043825Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":" train_data.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:01.048596Z","iopub.execute_input":"2024-12-14T11:45:01.049306Z","iopub.status.idle":"2024-12-14T11:45:01.06649Z","shell.execute_reply.started":"2024-12-14T11:45:01.049265Z","shell.execute_reply":"2024-12-14T11:45:01.065383Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# **About DataSet**","metadata":{}},{"cell_type":"markdown","source":"**Goal:**\nThe objectives of this challenge is to predict insurance premiums based on various factors.\n\n**Evaluation**:\r\nSubmissions are evaluated using the Root Mean Squared Logarithmic Error (RMSLE)\n\n**Age:** The age of the customer.\n\n**Gender:** The gender of the customer (e.g., male, female).\n\n**Annual Income:** The yearly income of the customer.\n\n**Marital Status:** The marital status of the customer (e.g., single, married).\n\n**Number of Dependents:** The number of dependents the customer has.\n\n**Education Level:** The highest level of education attained by the customer (e.g., high school, bachelor's, master's).\n\n**Occupation:** The job or profession of the customer.\n\n**Health Score:** A rating that represents the customer's overall health.\n\n**Location:** The geographical area where the customer resides.\n\n**Policy Type:** The type of insurance policy the customer holds (e.g., health, auto, life).\n\n**Previous Claims:** The number of insurance claims the customer has made in the past.\n\n**Vehicle Age:** The age of the vehicle (if the policy is related to auto insurance).\n\n**Credit Score:** A numerical value representing the customer's creditworthiness.\n\n**Insurance Duration:** The length of time the customer has held the insurance policy.\n\n**Policy Start Date:** The date when the insurance policy was initiated.\n\n**Customer Feedback:** Customer's feedback or satisfaction rating for the insurance service.\n\n**Smoking Status:** Whether the customer smokes (e.g., smoker, non-smoker).\n\n**Exercise Frequency:** How often the customer exercises (e.g., daily, weekly, rarely).\n\n**Property Type:** The type of property the customer owns or is insured for (e.g., house, apartment).\n\n**Premium Amount:** The amount paid by the customer for the insurance policy..","metadata":{}},{"cell_type":"code","source":"train_data.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:01.067761Z","iopub.execute_input":"2024-12-14T11:45:01.068094Z","iopub.status.idle":"2024-12-14T11:45:01.540492Z","shell.execute_reply.started":"2024-12-14T11:45:01.068062Z","shell.execute_reply":"2024-12-14T11:45:01.538943Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Statistical Analysis**","metadata":{}},{"cell_type":"code","source":"train_data.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:01.541863Z","iopub.execute_input":"2024-12-14T11:45:01.542242Z","iopub.status.idle":"2024-12-14T11:45:02.040086Z","shell.execute_reply.started":"2024-12-14T11:45:01.542207Z","shell.execute_reply":"2024-12-14T11:45:02.039018Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Check Missing Values**","metadata":{}},{"cell_type":"code","source":"train_data.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:02.041386Z","iopub.execute_input":"2024-12-14T11:45:02.041781Z","iopub.status.idle":"2024-12-14T11:45:02.486677Z","shell.execute_reply.started":"2024-12-14T11:45:02.041739Z","shell.execute_reply":"2024-12-14T11:45:02.485297Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data.isnull().sum().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:02.488328Z","iopub.execute_input":"2024-12-14T11:45:02.488679Z","iopub.status.idle":"2024-12-14T11:45:02.937735Z","shell.execute_reply.started":"2024-12-14T11:45:02.488652Z","shell.execute_reply":"2024-12-14T11:45:02.936557Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Larrge Amount of Missing Values available","metadata":{}},{"cell_type":"markdown","source":"**Check Duplicate Values**","metadata":{}},{"cell_type":"code","source":"train_data.duplicated().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:02.939015Z","iopub.execute_input":"2024-12-14T11:45:02.939287Z","iopub.status.idle":"2024-12-14T11:45:04.376629Z","shell.execute_reply.started":"2024-12-14T11:45:02.939262Z","shell.execute_reply":"2024-12-14T11:45:04.375436Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"No Dupliacated Values","metadata":{}},{"cell_type":"markdown","source":"# Data Analysis and Visualization","metadata":{}},{"cell_type":"code","source":"colors = ['#A3D2A3','#E6B3B3','#C7E1A6','#B3E0E0','#A0D7D7','#C2C7E1','#D9E1C3' ,\"#24C06A\" ,'#B3E5BB',\n          '#A2D6A6','#A3C1AD','#ff9999','#66b3ff','#99ff99','#ffcc99']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:04.378131Z","iopub.execute_input":"2024-12-14T11:45:04.378504Z","iopub.status.idle":"2024-12-14T11:45:04.384006Z","shell.execute_reply.started":"2024-12-14T11:45:04.378463Z","shell.execute_reply":"2024-12-14T11:45:04.382908Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"num_features=train_data.select_dtypes(include='number')\nobj_features=train_data.select_dtypes(exclude='number')\n\nprint(f\"Total Feature is -->> {len(train_data.columns)}\")\nprint(f\"Numerical Feature is -->> {len(num_features.columns)}\")\nprint(f\"Object Feature is -->> {len(obj_features.columns)}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:04.385002Z","iopub.execute_input":"2024-12-14T11:45:04.385261Z","iopub.status.idle":"2024-12-14T11:45:04.74166Z","shell.execute_reply.started":"2024-12-14T11:45:04.385229Z","shell.execute_reply":"2024-12-14T11:45:04.740445Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"**Premium Amount**\t","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(9,6))\nsns.histplot(train_data[\"Premium Amount\"] ,color='red' ,kde=True,shrink=1)\nplt.title(\"Premium Amount Distribution using histplot\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:04.743479Z","iopub.execute_input":"2024-12-14T11:45:04.743946Z","iopub.status.idle":"2024-12-14T11:45:09.53671Z","shell.execute_reply.started":"2024-12-14T11:45:04.743898Z","shell.execute_reply":"2024-12-14T11:45:09.535115Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**gender**","metadata":{}},{"cell_type":"code","source":"train_data[\"Gender\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:09.538464Z","iopub.execute_input":"2024-12-14T11:45:09.538818Z","iopub.status.idle":"2024-12-14T11:45:09.610922Z","shell.execute_reply.started":"2024-12-14T11:45:09.538789Z","shell.execute_reply":"2024-12-14T11:45:09.609297Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Gender\" , ax=ax[0],color=colors[0], saturation=0.75)\nax[0].set_title(\"Gender Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Gender\"].value_counts() , labels=train_data[\"Gender\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07],\n          colors=colors\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:09.612007Z","iopub.execute_input":"2024-12-14T11:45:09.612263Z","iopub.status.idle":"2024-12-14T11:45:10.447162Z","shell.execute_reply.started":"2024-12-14T11:45:09.612238Z","shell.execute_reply":"2024-12-14T11:45:10.446134Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Premium_Amount vs Gender**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Gender\")\nplt.title(\"Premium Amount hue with Gender\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:10.448992Z","iopub.execute_input":"2024-12-14T11:45:10.44943Z","iopub.status.idle":"2024-12-14T11:45:16.700537Z","shell.execute_reply.started":"2024-12-14T11:45:10.449386Z","shell.execute_reply":"2024-12-14T11:45:16.699195Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Insight**\n\n1. **No Gender Discrimination in Premium Calculation**\n\n2.  **Equality in Treatment:**\n\n    *  This could indicate that the policy or system is gender-neutral,treating both male and female customers equally in terms of premium determination.","metadata":{}},{"cell_type":"markdown","source":"**Marital Status**\t","metadata":{}},{"cell_type":"code","source":"train_data[\"Marital Status\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:16.701841Z","iopub.execute_input":"2024-12-14T11:45:16.702134Z","iopub.status.idle":"2024-12-14T11:45:16.77827Z","shell.execute_reply.started":"2024-12-14T11:45:16.702099Z","shell.execute_reply":"2024-12-14T11:45:16.776717Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Marital Status\" , ax=ax[0],color=colors[1])\nax[0].set_title(\"Marital Status Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Marital Status\"].value_counts() , labels=train_data[\"Marital Status\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07 ,0.07],\n          colors=colors[1:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:16.779964Z","iopub.execute_input":"2024-12-14T11:45:16.780737Z","iopub.status.idle":"2024-12-14T11:45:17.649916Z","shell.execute_reply.started":"2024-12-14T11:45:16.780654Z","shell.execute_reply":"2024-12-14T11:45:17.648746Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Marital_Status vs Gender**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(8,5))\nsns.countplot(data=train_data , x=\"Marital Status\" , hue=\"Gender\" , color='r',palette='Blues_d')\nplt.title(\"Marital Status Count hue with Gender\",fontweight='bold')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:17.651368Z","iopub.execute_input":"2024-12-14T11:45:17.651688Z","iopub.status.idle":"2024-12-14T11:45:18.738278Z","shell.execute_reply.started":"2024-12-14T11:45:17.651661Z","shell.execute_reply":"2024-12-14T11:45:18.737195Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Marital Status\")\nplt.title(\"Premium Amount hue with Marital Status\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:18.742712Z","iopub.execute_input":"2024-12-14T11:45:18.743008Z","iopub.status.idle":"2024-12-14T11:45:25.30857Z","shell.execute_reply.started":"2024-12-14T11:45:18.742985Z","shell.execute_reply":"2024-12-14T11:45:25.307698Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Insights:**\n1.  Marital Status Independence:\n\n    *  The result implies that the Premium_Amount is not affected by whether a person is married or not","metadata":{}},{"cell_type":"markdown","source":"**Education_Level**","metadata":{}},{"cell_type":"code","source":"train_data[\"Education Level\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:25.309551Z","iopub.execute_input":"2024-12-14T11:45:25.30978Z","iopub.status.idle":"2024-12-14T11:45:25.378647Z","shell.execute_reply.started":"2024-12-14T11:45:25.309756Z","shell.execute_reply":"2024-12-14T11:45:25.377795Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Education Level\" , ax=ax[0],color=colors[2])\nax[0].set_title(\"Education Level Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Education Level\"].value_counts() , labels=train_data[\"Education Level\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07 ,0.07,0.07],\n          colors=colors[2:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:25.379679Z","iopub.execute_input":"2024-12-14T11:45:25.37994Z","iopub.status.idle":"2024-12-14T11:45:26.230043Z","shell.execute_reply.started":"2024-12-14T11:45:25.379911Z","shell.execute_reply":"2024-12-14T11:45:26.228822Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,6))\nsns.countplot(data=train_data , x=\"Education Level\" , hue=\"Gender\",palette='Greens_d')\nplt.title(\"Education Level Count hue with Gender\",fontweight='bold')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:26.231157Z","iopub.execute_input":"2024-12-14T11:45:26.231461Z","iopub.status.idle":"2024-12-14T11:45:27.301174Z","shell.execute_reply.started":"2024-12-14T11:45:26.231435Z","shell.execute_reply":"2024-12-14T11:45:27.299873Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Education Level\")\nplt.title(\"Premium Amount hue with Education_Level\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:27.302465Z","iopub.execute_input":"2024-12-14T11:45:27.302808Z","iopub.status.idle":"2024-12-14T11:45:34.167457Z","shell.execute_reply.started":"2024-12-14T11:45:27.302775Z","shell.execute_reply":"2024-12-14T11:45:34.165986Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Insight**\n\n**No Impact of Education Level:**\n\n*  This indicates that Education_Level does not significantly influence Premium_Amount.","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.boxplot(data=train_data, x=\"Education Level\", y=\"Premium Amount\")\nplt.title(\"Premium Amount Distribution by Education Level\", fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:34.169075Z","iopub.execute_input":"2024-12-14T11:45:34.169474Z","iopub.status.idle":"2024-12-14T11:45:34.835704Z","shell.execute_reply.started":"2024-12-14T11:45:34.169444Z","shell.execute_reply":"2024-12-14T11:45:34.834309Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Occupation**","metadata":{}},{"cell_type":"code","source":"train_data[\"Occupation\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:34.837154Z","iopub.execute_input":"2024-12-14T11:45:34.837533Z","iopub.status.idle":"2024-12-14T11:45:34.902186Z","shell.execute_reply.started":"2024-12-14T11:45:34.837495Z","shell.execute_reply":"2024-12-14T11:45:34.901006Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Occupation\" , ax=ax[0],color=colors[2])\nax[0].set_title(\"Occupation Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Occupation\"].value_counts() , labels=train_data[\"Occupation\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07 ,0.07],\n          colors=colors[2:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:34.904769Z","iopub.execute_input":"2024-12-14T11:45:34.905276Z","iopub.status.idle":"2024-12-14T11:45:35.751629Z","shell.execute_reply.started":"2024-12-14T11:45:34.905217Z","shell.execute_reply":"2024-12-14T11:45:35.750492Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Occupation vs Gender**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(8,5))\nsns.countplot(data=train_data , x=\"Occupation\" , hue=\"Gender\",palette='viridis')\nplt.title(\"Occupation Count hue with Gender\",fontweight='bold')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:35.752949Z","iopub.execute_input":"2024-12-14T11:45:35.75326Z","iopub.status.idle":"2024-12-14T11:45:36.771456Z","shell.execute_reply.started":"2024-12-14T11:45:35.753229Z","shell.execute_reply":"2024-12-14T11:45:36.76975Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Occupation\")\nplt.title(\"Premium Amount hue with Occupation\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:36.772587Z","iopub.execute_input":"2024-12-14T11:45:36.772926Z","iopub.status.idle":"2024-12-14T11:45:41.72351Z","shell.execute_reply.started":"2024-12-14T11:45:36.77289Z","shell.execute_reply":"2024-12-14T11:45:41.72222Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**No Clear Variation by Occupation:**\n\n*  Premium_Amount may not vary significantly across different occupations.","metadata":{}},{"cell_type":"markdown","source":"**Location**","metadata":{}},{"cell_type":"code","source":"train_data[\"Location\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:41.725001Z","iopub.execute_input":"2024-12-14T11:45:41.725408Z","iopub.status.idle":"2024-12-14T11:45:41.79904Z","shell.execute_reply.started":"2024-12-14T11:45:41.725368Z","shell.execute_reply":"2024-12-14T11:45:41.797023Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Location\" , ax=ax[0],color=colors[7],saturation=0.5)\nax[0].set_title(\"Location Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Location\"].value_counts() , labels=train_data[\"Location\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07 ,0.07],\n          colors=colors[7:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:41.800552Z","iopub.execute_input":"2024-12-14T11:45:41.800911Z","iopub.status.idle":"2024-12-14T11:45:42.655324Z","shell.execute_reply.started":"2024-12-14T11:45:41.800876Z","shell.execute_reply":"2024-12-14T11:45:42.654152Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Location\")\nplt.title(\"Premium Amount hue with Location\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:42.656896Z","iopub.execute_input":"2024-12-14T11:45:42.657279Z","iopub.status.idle":"2024-12-14T11:45:49.245049Z","shell.execute_reply.started":"2024-12-14T11:45:42.657241Z","shell.execute_reply":"2024-12-14T11:45:49.243883Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**No Variation by Location:**\n\n*  Premium_Amount does not seem to vary by location,","metadata":{}},{"cell_type":"markdown","source":"**Policy_Type**","metadata":{}},{"cell_type":"code","source":"train_data[\"Policy Type\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:49.246974Z","iopub.execute_input":"2024-12-14T11:45:49.247508Z","iopub.status.idle":"2024-12-14T11:45:49.321525Z","shell.execute_reply.started":"2024-12-14T11:45:49.247464Z","shell.execute_reply":"2024-12-14T11:45:49.320462Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Policy Type\" , ax=ax[0],color=colors[7],saturation=0.5)\nax[0].set_title(\"Policy Type Count\",fontweight='bold')\nax[0].set_xticklabels(ax[0].get_xticklabels(), rotation=45, ha='right')\n\nax[1].pie(train_data[\"Policy Type\"].value_counts() , labels=train_data[\"Policy Type\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07 ,0.07],\n          colors=colors[7:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:49.322582Z","iopub.execute_input":"2024-12-14T11:45:49.322843Z","iopub.status.idle":"2024-12-14T11:45:50.21063Z","shell.execute_reply.started":"2024-12-14T11:45:49.322811Z","shell.execute_reply":"2024-12-14T11:45:50.209406Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Policy Type\")\nplt.title(\"Premium Amount hue with Policy Type\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:50.211601Z","iopub.execute_input":"2024-12-14T11:45:50.211854Z","iopub.status.idle":"2024-12-14T11:45:56.92076Z","shell.execute_reply.started":"2024-12-14T11:45:50.21181Z","shell.execute_reply":"2024-12-14T11:45:56.919515Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Customer_Feedback**","metadata":{}},{"cell_type":"code","source":"train_data[\"Customer Feedback\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:56.922175Z","iopub.execute_input":"2024-12-14T11:45:56.922508Z","iopub.status.idle":"2024-12-14T11:45:56.993473Z","shell.execute_reply.started":"2024-12-14T11:45:56.922481Z","shell.execute_reply":"2024-12-14T11:45:56.991178Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Customer Feedback\" , ax=ax[0],color=colors[7],saturation=0.5)\nax[0].set_title(\"Customer Feedback Count\",fontweight='bold')\nax[0].set_xticklabels(ax[0].get_xticklabels(), rotation=45, ha='right')\n\nax[1].pie(train_data[\"Customer Feedback\"].value_counts() , labels=train_data[\"Customer Feedback\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07 ,0.07],\n          colors=colors[7:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:56.995147Z","iopub.execute_input":"2024-12-14T11:45:56.995566Z","iopub.status.idle":"2024-12-14T11:45:57.85388Z","shell.execute_reply.started":"2024-12-14T11:45:56.995529Z","shell.execute_reply":"2024-12-14T11:45:57.85294Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,5))\nsns.countplot(data=train_data , x=\"Customer Feedback\" , hue=\"Gender\",palette='viridis')\nplt.title(\"Customer Feedback Count hue with Gender\",fontweight='bold')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:57.855081Z","iopub.execute_input":"2024-12-14T11:45:57.855439Z","iopub.status.idle":"2024-12-14T11:45:58.920868Z","shell.execute_reply.started":"2024-12-14T11:45:57.855404Z","shell.execute_reply":"2024-12-14T11:45:58.919715Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Customer Feedback\")\nplt.title(\"Premium Amount hue with Customer Feedback\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:45:58.922242Z","iopub.execute_input":"2024-12-14T11:45:58.922622Z","iopub.status.idle":"2024-12-14T11:46:04.912883Z","shell.execute_reply.started":"2024-12-14T11:45:58.922583Z","shell.execute_reply":"2024-12-14T11:46:04.911606Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Smoking_Status**","metadata":{}},{"cell_type":"code","source":"train_data[\"Smoking Status\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:04.914369Z","iopub.execute_input":"2024-12-14T11:46:04.914673Z","iopub.status.idle":"2024-12-14T11:46:04.987574Z","shell.execute_reply.started":"2024-12-14T11:46:04.914647Z","shell.execute_reply":"2024-12-14T11:46:04.985826Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Smoking Status\" ,hue=\"Gender\", ax=ax[0],color=colors[7],saturation=0.5)\nax[0].set_title(\"Smoking_Status Count\",fontweight='bold')\nax[0].set_xticklabels(ax[0].get_xticklabels(), rotation=45, ha='right')\n\nax[1].pie(train_data[\"Smoking Status\"].value_counts() , labels=train_data[\"Smoking Status\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07],\n          colors=colors[7:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:04.98902Z","iopub.execute_input":"2024-12-14T11:46:04.989363Z","iopub.status.idle":"2024-12-14T11:46:06.486946Z","shell.execute_reply.started":"2024-12-14T11:46:04.989315Z","shell.execute_reply":"2024-12-14T11:46:06.485945Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Smoking Status\")\nplt.title(\"Premium Amount hue with Smoking Status\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:06.488008Z","iopub.execute_input":"2024-12-14T11:46:06.488288Z","iopub.status.idle":"2024-12-14T11:46:12.470398Z","shell.execute_reply.started":"2024-12-14T11:46:06.488258Z","shell.execute_reply":"2024-12-14T11:46:12.469224Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Exercise_Frequency**","metadata":{}},{"cell_type":"code","source":"train_data[\"Exercise Frequency\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:12.471623Z","iopub.execute_input":"2024-12-14T11:46:12.471907Z","iopub.status.idle":"2024-12-14T11:46:12.54249Z","shell.execute_reply.started":"2024-12-14T11:46:12.471882Z","shell.execute_reply":"2024-12-14T11:46:12.541329Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,5))\nsns.countplot(data=train_data , x=\"Exercise Frequency\" ,hue=\"Gender\", ax=ax[0],color=colors[7],saturation=0.5)\nax[0].set_title(\"Exercise_Frequency Count\",fontweight='bold')\nax[0].set_xticklabels(ax[0].get_xticklabels(), rotation=45, ha='right')\n\nax[1].pie(train_data[\"Exercise Frequency\"].value_counts() , labels=train_data[\"Exercise Frequency\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07,0.07 , 0.07],\n          colors=colors[7:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:12.543797Z","iopub.execute_input":"2024-12-14T11:46:12.544192Z","iopub.status.idle":"2024-12-14T11:46:13.843098Z","shell.execute_reply.started":"2024-12-14T11:46:12.544161Z","shell.execute_reply":"2024-12-14T11:46:13.842021Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Property_Type**","metadata":{}},{"cell_type":"code","source":"train_data[\"Property Type\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:13.84512Z","iopub.execute_input":"2024-12-14T11:46:13.845517Z","iopub.status.idle":"2024-12-14T11:46:13.919527Z","shell.execute_reply.started":"2024-12-14T11:46:13.84548Z","shell.execute_reply":"2024-12-14T11:46:13.917771Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,5))\nsns.countplot(data=train_data , x=\"Property Type\", ax=ax[0],color=colors[7],saturation=0.5)\nax[0].set_title(\"Property Type Count\",fontweight='bold')\nax[0].set_xticklabels(ax[0].get_xticklabels(), rotation=45, ha='right')\n\nax[1].pie(train_data[\"Property Type\"].value_counts() , labels=train_data[\"Property Type\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07,0.07],\n          colors=colors[7:]\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:13.921054Z","iopub.execute_input":"2024-12-14T11:46:13.921468Z","iopub.status.idle":"2024-12-14T11:46:14.770053Z","shell.execute_reply.started":"2024-12-14T11:46:13.921433Z","shell.execute_reply":"2024-12-14T11:46:14.768722Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,5))\nsns.histplot(data=train_data , x=\"Premium Amount\",kde=True ,hue=\"Property Type\")\nplt.title(\"Premium Amount hue with Property Type\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:14.771575Z","iopub.execute_input":"2024-12-14T11:46:14.771891Z","iopub.status.idle":"2024-12-14T11:46:21.371779Z","shell.execute_reply.started":"2024-12-14T11:46:14.771863Z","shell.execute_reply":"2024-12-14T11:46:21.370614Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Numerical Feature Distribution**","metadata":{}},{"cell_type":"markdown","source":"**Number of Dependents**","metadata":{}},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , x=\"Number of Dependents\" , ax=ax[0],color=colors[0])\nax[0].set_title(\"Number of Dependents Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Number of Dependents\"].value_counts() , labels=train_data[\"Number of Dependents\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07,0.07 , 0.07,0.07],\n          colors=colors\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:21.373154Z","iopub.execute_input":"2024-12-14T11:46:21.374387Z","iopub.status.idle":"2024-12-14T11:46:21.749704Z","shell.execute_reply.started":"2024-12-14T11:46:21.374299Z","shell.execute_reply":"2024-12-14T11:46:21.748699Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Previous_Claims**","metadata":{}},{"cell_type":"code","source":"train_data[\"Previous Claims\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:21.750987Z","iopub.execute_input":"2024-12-14T11:46:21.751333Z","iopub.status.idle":"2024-12-14T11:46:21.774332Z","shell.execute_reply.started":"2024-12-14T11:46:21.751295Z","shell.execute_reply":"2024-12-14T11:46:21.773116Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,4))\nsns.countplot(data=train_data , x=\"Previous Claims\")\nplt.title(\"Previous Claims Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:21.775959Z","iopub.execute_input":"2024-12-14T11:46:21.776281Z","iopub.status.idle":"2024-12-14T11:46:22.085211Z","shell.execute_reply.started":"2024-12-14T11:46:21.776253Z","shell.execute_reply":"2024-12-14T11:46:22.083789Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Age**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10,6))\nsns.countplot(data=train_data , x=\"Age\")\nplt.title(\"Age Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:22.086765Z","iopub.execute_input":"2024-12-14T11:46:22.087134Z","iopub.status.idle":"2024-12-14T11:46:22.68443Z","shell.execute_reply.started":"2024-12-14T11:46:22.087105Z","shell.execute_reply":"2024-12-14T11:46:22.682911Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,6))\nsns.countplot(data=train_data , x=\"Age\",hue=\"Marital Status\")\nplt.title(\"Age Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:22.686943Z","iopub.execute_input":"2024-12-14T11:46:22.687335Z","iopub.status.idle":"2024-12-14T11:46:23.970877Z","shell.execute_reply.started":"2024-12-14T11:46:22.687297Z","shell.execute_reply":"2024-12-14T11:46:23.969408Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,4))\nsns.boxplot(x=train_data[\"Age\"] , color='r')\nplt.title(\"Check Outliers in Age using BoxPlot\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:23.972549Z","iopub.execute_input":"2024-12-14T11:46:23.97294Z","iopub.status.idle":"2024-12-14T11:46:24.155268Z","shell.execute_reply.started":"2024-12-14T11:46:23.972902Z","shell.execute_reply":"2024-12-14T11:46:24.154415Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Annual_Income**","metadata":{}},{"cell_type":"code","source":"fig,ax = plt.subplots(1,2,figsize=(16,6))\n\nsns.histplot(data=train_data , x=\"Annual Income\",ax=ax[0])\nax[0].set_title(\"Annual Income Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\n\n\nsns.histplot(data=train_data , x=\"Annual Income\",kde=True,ax=ax[1] ,hue=\"Gender\")\nax[0].set_title(\"Annual Income hue with Gender\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:24.15626Z","iopub.execute_input":"2024-12-14T11:46:24.156585Z","iopub.status.idle":"2024-12-14T11:46:30.744097Z","shell.execute_reply.started":"2024-12-14T11:46:24.15655Z","shell.execute_reply":"2024-12-14T11:46:30.742667Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Insight:**\n*  Both Male and Female have same anual income","metadata":{}},{"cell_type":"markdown","source":"**Health_Score**","metadata":{}},{"cell_type":"code","source":"train_data[\"Health Score\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:30.745623Z","iopub.execute_input":"2024-12-14T11:46:30.746007Z","iopub.status.idle":"2024-12-14T11:46:30.813972Z","shell.execute_reply.started":"2024-12-14T11:46:30.745969Z","shell.execute_reply":"2024-12-14T11:46:30.812156Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,4))\nsns.histplot(data=train_data , x=\"Health Score\")\nplt.title(\"Health Score Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:30.817702Z","iopub.execute_input":"2024-12-14T11:46:30.818169Z","iopub.status.idle":"2024-12-14T11:46:31.482946Z","shell.execute_reply.started":"2024-12-14T11:46:30.818109Z","shell.execute_reply":"2024-12-14T11:46:31.481642Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,4))\nsns.histplot(data=train_data , x=\"Health Score\",hue=\"Gender\")\nplt.title(\"Health Score Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:31.484187Z","iopub.execute_input":"2024-12-14T11:46:31.484461Z","iopub.status.idle":"2024-12-14T11:46:33.267645Z","shell.execute_reply.started":"2024-12-14T11:46:31.484435Z","shell.execute_reply":"2024-12-14T11:46:33.266271Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Vehicle_Age**","metadata":{}},{"cell_type":"code","source":"train_data[\"Vehicle Age\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:33.268829Z","iopub.execute_input":"2024-12-14T11:46:33.26916Z","iopub.status.idle":"2024-12-14T11:46:33.292714Z","shell.execute_reply.started":"2024-12-14T11:46:33.269118Z","shell.execute_reply":"2024-12-14T11:46:33.291209Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,4))\nsns.countplot(data=train_data , x=\"Vehicle Age\" ,palette='Purples_d')\nplt.title(\"Vehicle_Age Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:33.294147Z","iopub.execute_input":"2024-12-14T11:46:33.294527Z","iopub.status.idle":"2024-12-14T11:46:33.688009Z","shell.execute_reply.started":"2024-12-14T11:46:33.294488Z","shell.execute_reply":"2024-12-14T11:46:33.686632Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Credit_Score**","metadata":{}},{"cell_type":"code","source":"train_data[\"Credit Score\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:33.689699Z","iopub.execute_input":"2024-12-14T11:46:33.690148Z","iopub.status.idle":"2024-12-14T11:46:33.710805Z","shell.execute_reply.started":"2024-12-14T11:46:33.690094Z","shell.execute_reply":"2024-12-14T11:46:33.709399Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,4))\nsns.histplot(data=train_data , x=\"Credit Score\", palette='coolwarm')\nplt.title(\"Credit Score Distribution\" , fontweight=\"bold\")\nplt.xticks(rotation=45)\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:33.712079Z","iopub.execute_input":"2024-12-14T11:46:33.712415Z","iopub.status.idle":"2024-12-14T11:46:34.327254Z","shell.execute_reply.started":"2024-12-14T11:46:33.712379Z","shell.execute_reply":"2024-12-14T11:46:34.325744Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Insurance_Duration(year)**","metadata":{}},{"cell_type":"code","source":"fig , ax = plt.subplots(1,2,figsize=(14,6))\nsns.countplot(data=train_data , y=\"Insurance Duration\" , ax=ax[0],color=colors[0])\nax[0].set_title(\"Insurance Duration Count\",fontweight='bold',\n               )\n\nax[1].pie(train_data[\"Insurance Duration\"].value_counts() , labels=train_data[\"Insurance Duration\"].value_counts().index,\n          autopct=\"%0.2f%%\",\n          shadow=True,\n          explode=[0.07 , 0.07,0.07 , 0.07,0.07,0.07, 0.07,0.07,0.07],\n          colors=colors\n         )\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:34.328524Z","iopub.execute_input":"2024-12-14T11:46:34.328837Z","iopub.status.idle":"2024-12-14T11:46:34.795514Z","shell.execute_reply.started":"2024-12-14T11:46:34.328806Z","shell.execute_reply":"2024-12-14T11:46:34.794161Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data.head(1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:34.797256Z","iopub.execute_input":"2024-12-14T11:46:34.797643Z","iopub.status.idle":"2024-12-14T11:46:34.816223Z","shell.execute_reply.started":"2024-12-14T11:46:34.797606Z","shell.execute_reply":"2024-12-14T11:46:34.815228Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Policy_Start_Year**\n*  Convert \"Policy Start Date\" into datatime","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Ensure datetime conversion\ntrain_data[\"Policy Start Date\"] = pd.to_datetime(train_data[\"Policy Start Date\"], errors=\"coerce\")\n\nfig, ax = plt.subplots(1, 2, figsize=(14, 6))\n\n# Countplot\nsns.countplot(\n    y=train_data[\"Policy Start Date\"].dt.year, \n    ax=ax[0], \n    color=colors[0]\n)\nax[0].set_title(\"Policy Start Year Count\", fontweight='bold')\nax[0].set_xlabel(\"Count\")\nax[0].set_ylabel(\"Policy Start Year\")\n\n# Pie Chart\nyear_counts = train_data[\"Policy Start Date\"].dt.year.value_counts()\nexplode = [0.07] * len(year_counts)\n\nax[1].pie(\n    year_counts, \n    labels=year_counts.index, \n    autopct=\"%0.2f%%\", \n    shadow=True, \n    explode=explode, \n    colors=colors[:len(year_counts)]  # Ensure colors match the number of labels\n)\nax[1].set_title(\"Policy Start Year Distribution\")\n\n# Show\nplt.tight_layout()\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:34.818109Z","iopub.execute_input":"2024-12-14T11:46:34.818502Z","iopub.status.idle":"2024-12-14T11:46:35.612661Z","shell.execute_reply.started":"2024-12-14T11:46:34.818474Z","shell.execute_reply":"2024-12-14T11:46:35.611479Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"# Ensure datetime conversion\ntrain_data[\"Policy Start Date\"] = pd.to_datetime(train_data[\"Policy Start Date\"], errors=\"coerce\")\n\nfig, ax = plt.subplots(1, 2, figsize=(14, 6))\n\n# Countplot\nsns.countplot(\n    y=train_data[\"Policy Start Date\"].dt.month, \n    ax=ax[0], \n    color=colors[0]\n)\nax[0].set_title(\"Policy Start Month Count\", fontweight='bold')\nax[0].set_xlabel(\"Count\")\nax[0].set_ylabel(\"Policy Start Month\")\n\n# Pie Chart\nmonth_count = train_data[\"Policy Start Date\"].dt.month.value_counts()\nexplode = [0.07] * len(month_count)\n\nax[1].pie(\n    month_count, \n    labels=month_count.index, \n    autopct=\"%0.2f%%\", \n    shadow=True, \n    explode=explode, \n    colors=colors[:len(month_count)]  # Ensure colors match the number of labels\n)\nax[1].set_title(\"Policy Start Month Distribution\")\n\n# Show\nplt.tight_layout()\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:35.622446Z","iopub.execute_input":"2024-12-14T11:46:35.622806Z","iopub.status.idle":"2024-12-14T11:46:36.559639Z","shell.execute_reply.started":"2024-12-14T11:46:35.622779Z","shell.execute_reply":"2024-12-14T11:46:36.558286Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.barplot(\n    x=train_data[\"Policy Start Date\"].dt.year, \n    y=train_data[\"Premium Amount\"], \n    estimator=np.mean,  # Use a callable function like np.mean for aggregation\n    \n)\nplt.title(\"Average Premium Amount by Policy Start Year\", fontweight='bold')\nplt.xlabel(\"Policy Start Year\")\nplt.ylabel(\"Average Premium Amount\")\nplt.xticks(rotation=45)  # Rotate x-axis labels if they overlap\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:36.560821Z","iopub.execute_input":"2024-12-14T11:46:36.561203Z","iopub.status.idle":"2024-12-14T11:46:42.473104Z","shell.execute_reply.started":"2024-12-14T11:46:36.561163Z","shell.execute_reply":"2024-12-14T11:46:42.471629Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Insight**\n*  2019 and 2024  have more average Permium Amount and also have less ammount of data","metadata":{}},{"cell_type":"code","source":"# Group data by 'Policy Start Year' and calculate the total premium amount\npremium_by_year = train_data.groupby(train_data[\"Policy Start Date\"].dt.year)[\"Premium Amount\"].sum().reset_index()\npremium_by_year.columns = [\"Policy Start Year\", \"Total Premium Amount\"]\n\n# Lineplot\nsns.lineplot(data=premium_by_year, x=\"Policy Start Year\", y=\"Total Premium Amount\", marker=\"o\", color=\"blue\")\nplt.title(\"Total Premium Amount by Policy Start Year\", fontweight='bold')\nplt.xlabel(\"Policy Start Year\")\nplt.ylabel(\"Total Premium Amount\")\nplt.grid(True, linestyle=\"--\", alpha=0.7)\nplt.xticks(rotation=45)\nplt.tight_layout()\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.474618Z","iopub.execute_input":"2024-12-14T11:46:42.474988Z","iopub.status.idle":"2024-12-14T11:46:42.846999Z","shell.execute_reply.started":"2024-12-14T11:46:42.474952Z","shell.execute_reply":"2024-12-14T11:46:42.845553Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# sns.pairplot(train_data,kind='scatter')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.848675Z","iopub.execute_input":"2024-12-14T11:46:42.849067Z","iopub.status.idle":"2024-12-14T11:46:42.854262Z","shell.execute_reply.started":"2024-12-14T11:46:42.84903Z","shell.execute_reply":"2024-12-14T11:46:42.853003Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# sns.pairplot(train_data)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.855872Z","iopub.execute_input":"2024-12-14T11:46:42.856286Z","iopub.status.idle":"2024-12-14T11:46:42.870854Z","shell.execute_reply.started":"2024-12-14T11:46:42.856243Z","shell.execute_reply":"2024-12-14T11:46:42.869827Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# num_features=train_data.select_dtypes(include='int').columns\n# num_corr = train_data[num_features].corr()\n# num_corr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.872565Z","iopub.execute_input":"2024-12-14T11:46:42.872884Z","iopub.status.idle":"2024-12-14T11:46:42.891777Z","shell.execute_reply.started":"2024-12-14T11:46:42.872858Z","shell.execute_reply":"2024-12-14T11:46:42.890092Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# plt.figure(figsize=(12,8))\n# sns.heatmap(\n#         num_corr ,annot=True, center=True, cmap='Blues',\n#         square=True,linecolor='white',\n#         linewidths=0.01,annot_kws={\"size\":8},cbar=True\n#            )\n# plt.title(\"Check Corr between Features\")\n# plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.893225Z","iopub.execute_input":"2024-12-14T11:46:42.893587Z","iopub.status.idle":"2024-12-14T11:46:42.917476Z","shell.execute_reply.started":"2024-12-14T11:46:42.89356Z","shell.execute_reply":"2024-12-14T11:46:42.91619Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# num_features=train_data.select_dtypes(include='int').columns\n# num_corr = train_data[num_features].corr()\n# premium_corr = num_corr['Premium Amount'].sort_values(ascending=False)\n# premium_corr","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.919046Z","iopub.execute_input":"2024-12-14T11:46:42.919484Z","iopub.status.idle":"2024-12-14T11:46:42.93191Z","shell.execute_reply.started":"2024-12-14T11:46:42.919457Z","shell.execute_reply":"2024-12-14T11:46:42.930747Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.933052Z","iopub.execute_input":"2024-12-14T11:46:42.933335Z","iopub.status.idle":"2024-12-14T11:46:42.95348Z","shell.execute_reply.started":"2024-12-14T11:46:42.93331Z","shell.execute_reply":"2024-12-14T11:46:42.95139Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:42.955191Z","iopub.execute_input":"2024-12-14T11:46:42.955641Z","iopub.status.idle":"2024-12-14T11:46:43.37973Z","shell.execute_reply.started":"2024-12-14T11:46:42.955595Z","shell.execute_reply":"2024-12-14T11:46:43.378924Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Feature Engeneering","metadata":{}},{"cell_type":"markdown","source":"**Age**","metadata":{}},{"cell_type":"code","source":"train_data[\"Age\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:43.380699Z","iopub.execute_input":"2024-12-14T11:46:43.380953Z","iopub.status.idle":"2024-12-14T11:46:43.398319Z","shell.execute_reply.started":"2024-12-14T11:46:43.380929Z","shell.execute_reply":"2024-12-14T11:46:43.396846Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Age\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:43.40006Z","iopub.execute_input":"2024-12-14T11:46:43.400501Z","iopub.status.idle":"2024-12-14T11:46:43.41694Z","shell.execute_reply.started":"2024-12-14T11:46:43.40046Z","shell.execute_reply":"2024-12-14T11:46:43.415642Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Distribution Age Using Boxplot**","metadata":{}},{"cell_type":"markdown","source":"**Outliers**:","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"\n*  No Outliers In Age Column","metadata":{}},{"cell_type":"markdown","source":"**Fill Age Missing Values with Mean And Convert it dtype into int**","metadata":{}},{"cell_type":"code","source":"print(f\"Mean Of Age is -->> {train_data['Age'].mean()}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:43.418181Z","iopub.execute_input":"2024-12-14T11:46:43.41851Z","iopub.status.idle":"2024-12-14T11:46:43.436479Z","shell.execute_reply.started":"2024-12-14T11:46:43.418484Z","shell.execute_reply":"2024-12-14T11:46:43.435069Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data['Age'] = train_data['Age'].fillna(train_data[\"Age\"].mean()).astype('int')\n\ntrain_data['Age'].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:43.438322Z","iopub.execute_input":"2024-12-14T11:46:43.438752Z","iopub.status.idle":"2024-12-14T11:46:43.466566Z","shell.execute_reply.started":"2024-12-14T11:46:43.438717Z","shell.execute_reply":"2024-12-14T11:46:43.465332Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Age Have No Issue after Preorocessing**","metadata":{}},{"cell_type":"markdown","source":"# Annual Income","metadata":{}},{"cell_type":"code","source":"train_data[\"Annual Income\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:43.467742Z","iopub.execute_input":"2024-12-14T11:46:43.468272Z","iopub.status.idle":"2024-12-14T11:46:43.504196Z","shell.execute_reply.started":"2024-12-14T11:46:43.468203Z","shell.execute_reply":"2024-12-14T11:46:43.50269Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.histplot(train_data[\"Annual Income\"])\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:43.506033Z","iopub.execute_input":"2024-12-14T11:46:43.506581Z","iopub.status.idle":"2024-12-14T11:46:44.492322Z","shell.execute_reply.started":"2024-12-14T11:46:43.506526Z","shell.execute_reply":"2024-12-14T11:46:44.491204Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,4))\nsns.boxplot(x=train_data[\"Annual Income\"] , color='#24C06A')\nplt.title(\"Check Outliers in Annual Income using BoxPlot\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:44.493442Z","iopub.execute_input":"2024-12-14T11:46:44.493726Z","iopub.status.idle":"2024-12-14T11:46:44.833007Z","shell.execute_reply.started":"2024-12-14T11:46:44.493698Z","shell.execute_reply":"2024-12-14T11:46:44.831665Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Fill Missing Values\n\n**Annual Income feature have Outliers So We fill this missing Values with medean and Convert dtype into int...**","metadata":{}},{"cell_type":"code","source":"print(f\"Mean Value Of Annual Income is -->> {train_data['Annual Income'].mean()}\")\nprint(f\"Median Value Of Annual Income is -->> {train_data['Annual Income'].median()}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:44.834164Z","iopub.execute_input":"2024-12-14T11:46:44.834446Z","iopub.status.idle":"2024-12-14T11:46:44.867888Z","shell.execute_reply.started":"2024-12-14T11:46:44.834421Z","shell.execute_reply":"2024-12-14T11:46:44.866214Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Annual Income\"] = train_data[\"Annual Income\"].fillna(train_data[\"Annual Income\"].median()).astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:44.869538Z","iopub.execute_input":"2024-12-14T11:46:44.869913Z","iopub.status.idle":"2024-12-14T11:46:44.903266Z","shell.execute_reply.started":"2024-12-14T11:46:44.869873Z","shell.execute_reply":"2024-12-14T11:46:44.902421Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Annual Income\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:44.904401Z","iopub.execute_input":"2024-12-14T11:46:44.90471Z","iopub.status.idle":"2024-12-14T11:46:44.925467Z","shell.execute_reply.started":"2024-12-14T11:46:44.904677Z","shell.execute_reply":"2024-12-14T11:46:44.924427Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"\n**Annual Income column have no more issue only outliers available if we need then remove these**","metadata":{}},{"cell_type":"markdown","source":"# Marital Status","metadata":{}},{"cell_type":"code","source":"train_data[\"Marital Status\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:44.92656Z","iopub.execute_input":"2024-12-14T11:46:44.926785Z","iopub.status.idle":"2024-12-14T11:46:44.970912Z","shell.execute_reply.started":"2024-12-14T11:46:44.926762Z","shell.execute_reply":"2024-12-14T11:46:44.969474Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Marital Status\"].value_counts()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:44.972142Z","iopub.execute_input":"2024-12-14T11:46:44.972539Z","iopub.status.idle":"2024-12-14T11:46:45.055246Z","shell.execute_reply.started":"2024-12-14T11:46:44.972503Z","shell.execute_reply":"2024-12-14T11:46:45.053588Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Marital Status\"].fillna(train_data[\"Marital Status\"].mode()[0] , inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.056858Z","iopub.execute_input":"2024-12-14T11:46:45.057203Z","iopub.status.idle":"2024-12-14T11:46:45.180811Z","shell.execute_reply.started":"2024-12-14T11:46:45.057171Z","shell.execute_reply":"2024-12-14T11:46:45.179084Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Number of Dependents","metadata":{}},{"cell_type":"code","source":"train_data[\"Number of Dependents\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.182381Z","iopub.execute_input":"2024-12-14T11:46:45.182793Z","iopub.status.idle":"2024-12-14T11:46:45.202582Z","shell.execute_reply.started":"2024-12-14T11:46:45.18275Z","shell.execute_reply":"2024-12-14T11:46:45.201452Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Number of Dependents\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.203712Z","iopub.execute_input":"2024-12-14T11:46:45.203999Z","iopub.status.idle":"2024-12-14T11:46:45.222115Z","shell.execute_reply.started":"2024-12-14T11:46:45.203972Z","shell.execute_reply":"2024-12-14T11:46:45.220761Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Number of Dependents\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.224338Z","iopub.execute_input":"2024-12-14T11:46:45.224789Z","iopub.status.idle":"2024-12-14T11:46:45.244411Z","shell.execute_reply.started":"2024-12-14T11:46:45.22476Z","shell.execute_reply":"2024-12-14T11:46:45.242819Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Fill Missing Values with mode and Convert it into int**","metadata":{}},{"cell_type":"code","source":"# Fill missing values\ntrain_data[\"Number of Dependents\"]=train_data[\"Number of Dependents\"].fillna(train_data[\"Number of Dependents\"].mode()[0]).astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.245628Z","iopub.execute_input":"2024-12-14T11:46:45.245981Z","iopub.status.idle":"2024-12-14T11:46:45.276893Z","shell.execute_reply.started":"2024-12-14T11:46:45.245942Z","shell.execute_reply":"2024-12-14T11:46:45.275521Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Number of Dependents\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.278008Z","iopub.execute_input":"2024-12-14T11:46:45.278309Z","iopub.status.idle":"2024-12-14T11:46:45.293716Z","shell.execute_reply.started":"2024-12-14T11:46:45.278271Z","shell.execute_reply":"2024-12-14T11:46:45.292625Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Occupation**","metadata":{}},{"cell_type":"code","source":"train_data[\"Occupation\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.295258Z","iopub.execute_input":"2024-12-14T11:46:45.295709Z","iopub.status.idle":"2024-12-14T11:46:45.350932Z","shell.execute_reply.started":"2024-12-14T11:46:45.295669Z","shell.execute_reply":"2024-12-14T11:46:45.350008Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Fill Missing Values in Occupation  with Unknown**","metadata":{}},{"cell_type":"code","source":"train_data[\"Occupation\"].fillna(\"Unknown\" , inplace=True)\n\ntrain_data[\"Occupation\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.352308Z","iopub.execute_input":"2024-12-14T11:46:45.352596Z","iopub.status.idle":"2024-12-14T11:46:45.466644Z","shell.execute_reply.started":"2024-12-14T11:46:45.35257Z","shell.execute_reply":"2024-12-14T11:46:45.46504Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Health Score","metadata":{}},{"cell_type":"code","source":"train_data[\"Health Score\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.468056Z","iopub.execute_input":"2024-12-14T11:46:45.468445Z","iopub.status.idle":"2024-12-14T11:46:45.538178Z","shell.execute_reply.started":"2024-12-14T11:46:45.468414Z","shell.execute_reply":"2024-12-14T11:46:45.536911Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Health Score\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.539239Z","iopub.execute_input":"2024-12-14T11:46:45.5395Z","iopub.status.idle":"2024-12-14T11:46:45.609824Z","shell.execute_reply.started":"2024-12-14T11:46:45.539475Z","shell.execute_reply":"2024-12-14T11:46:45.608894Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,4))\nsns.boxplot(x=train_data[\"Health Score\"] , color='r')\nplt.title(\"Check Outliers in Health Score using BoxPlot\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.610923Z","iopub.execute_input":"2024-12-14T11:46:45.611205Z","iopub.status.idle":"2024-12-14T11:46:45.836597Z","shell.execute_reply.started":"2024-12-14T11:46:45.611176Z","shell.execute_reply":"2024-12-14T11:46:45.835245Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(f\"Mean of Health Score is -->> {train_data['Health Score'].mean()}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.837928Z","iopub.execute_input":"2024-12-14T11:46:45.838263Z","iopub.status.idle":"2024-12-14T11:46:45.847968Z","shell.execute_reply.started":"2024-12-14T11:46:45.838226Z","shell.execute_reply":"2024-12-14T11:46:45.847024Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Fill Missing Values of Health Score with mean of Health Score**","metadata":{}},{"cell_type":"code","source":"train_data[\"Health Score\"].fillna(train_data[\"Health Score\"].mean() , inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.849151Z","iopub.execute_input":"2024-12-14T11:46:45.849458Z","iopub.status.idle":"2024-12-14T11:46:45.86961Z","shell.execute_reply.started":"2024-12-14T11:46:45.849429Z","shell.execute_reply":"2024-12-14T11:46:45.867902Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Previous Claims","metadata":{}},{"cell_type":"code","source":"train_data[\"Previous Claims\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.871283Z","iopub.execute_input":"2024-12-14T11:46:45.871701Z","iopub.status.idle":"2024-12-14T11:46:45.898096Z","shell.execute_reply.started":"2024-12-14T11:46:45.871666Z","shell.execute_reply":"2024-12-14T11:46:45.89605Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Previous Claims\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.899797Z","iopub.execute_input":"2024-12-14T11:46:45.900212Z","iopub.status.idle":"2024-12-14T11:46:45.919632Z","shell.execute_reply.started":"2024-12-14T11:46:45.900175Z","shell.execute_reply":"2024-12-14T11:46:45.918812Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Previous Claims\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.92072Z","iopub.execute_input":"2024-12-14T11:46:45.921032Z","iopub.status.idle":"2024-12-14T11:46:45.943606Z","shell.execute_reply.started":"2024-12-14T11:46:45.921002Z","shell.execute_reply":"2024-12-14T11:46:45.942527Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Fill Missing Values with mode and rename the name of columns and convert dtype into int**","metadata":{}},{"cell_type":"code","source":"train_data[\"Previous Claims\"].fillna(train_data[\"Previous Claims\"].mode()[0] , inplace=True)\n# Convert into int\ntrain_data[\"Previous Claims\"] = train_data[\"Previous Claims\"].astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.944814Z","iopub.execute_input":"2024-12-14T11:46:45.945128Z","iopub.status.idle":"2024-12-14T11:46:45.98217Z","shell.execute_reply.started":"2024-12-14T11:46:45.945098Z","shell.execute_reply":"2024-12-14T11:46:45.981282Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Vehicle Age","metadata":{}},{"cell_type":"code","source":"train_data[\"Vehicle Age\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:45.983236Z","iopub.execute_input":"2024-12-14T11:46:45.983512Z","iopub.status.idle":"2024-12-14T11:46:46.007528Z","shell.execute_reply.started":"2024-12-14T11:46:45.983487Z","shell.execute_reply":"2024-12-14T11:46:46.006439Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Vehicle Age\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.00869Z","iopub.execute_input":"2024-12-14T11:46:46.009016Z","iopub.status.idle":"2024-12-14T11:46:46.026612Z","shell.execute_reply.started":"2024-12-14T11:46:46.008985Z","shell.execute_reply":"2024-12-14T11:46:46.025259Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**This Feature have only 6 missing values and fill with mode**","metadata":{}},{"cell_type":"code","source":"# Fill missing values\ntrain_data[\"Vehicle Age\"].fillna(train_data[\"Vehicle Age\"].mode()[0],inplace=True)\n# convert float to int\ntrain_data[\"Vehicle Age\"] =train_data[\"Vehicle Age\"].astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.027913Z","iopub.execute_input":"2024-12-14T11:46:46.028246Z","iopub.status.idle":"2024-12-14T11:46:46.051544Z","shell.execute_reply.started":"2024-12-14T11:46:46.02822Z","shell.execute_reply":"2024-12-14T11:46:46.050444Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Credit Score","metadata":{}},{"cell_type":"code","source":"train_data[\"Credit Score\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.052804Z","iopub.execute_input":"2024-12-14T11:46:46.053189Z","iopub.status.idle":"2024-12-14T11:46:46.076201Z","shell.execute_reply.started":"2024-12-14T11:46:46.053149Z","shell.execute_reply":"2024-12-14T11:46:46.07428Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Credit Score\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.077491Z","iopub.execute_input":"2024-12-14T11:46:46.077868Z","iopub.status.idle":"2024-12-14T11:46:46.099317Z","shell.execute_reply.started":"2024-12-14T11:46:46.077825Z","shell.execute_reply":"2024-12-14T11:46:46.097605Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10,4))\nsns.boxplot(x=train_data[\"Credit Score\"] , color='r')\nplt.title(\"Check Outliers in Credit Score using BoxPlot\")\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.101461Z","iopub.execute_input":"2024-12-14T11:46:46.101894Z","iopub.status.idle":"2024-12-14T11:46:46.324504Z","shell.execute_reply.started":"2024-12-14T11:46:46.101842Z","shell.execute_reply":"2024-12-14T11:46:46.323417Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Fill Missing Values of Credit Score with mean**","metadata":{}},{"cell_type":"code","source":"print(f\" Mean of Credit Score is--->>> {train_data['Credit Score'].mean()}\")\n# Fill Missing Values\ntrain_data[\"Credit Score\"].fillna(train_data[\"Credit Score\"].mean(),inplace=True)\n\n# Convert Dtypes Into int\ntrain_data[\"Credit Score\"] = train_data[\"Credit Score\"].astype(\"int\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.32614Z","iopub.execute_input":"2024-12-14T11:46:46.32652Z","iopub.status.idle":"2024-12-14T11:46:46.348593Z","shell.execute_reply.started":"2024-12-14T11:46:46.326484Z","shell.execute_reply":"2024-12-14T11:46:46.347303Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Insurance Duration","metadata":{}},{"cell_type":"code","source":"train_data[\"Insurance Duration\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.349865Z","iopub.execute_input":"2024-12-14T11:46:46.350226Z","iopub.status.idle":"2024-12-14T11:46:46.366405Z","shell.execute_reply.started":"2024-12-14T11:46:46.350196Z","shell.execute_reply":"2024-12-14T11:46:46.365189Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Insurance Duration\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.368046Z","iopub.execute_input":"2024-12-14T11:46:46.368415Z","iopub.status.idle":"2024-12-14T11:46:46.388031Z","shell.execute_reply.started":"2024-12-14T11:46:46.368373Z","shell.execute_reply":"2024-12-14T11:46:46.386426Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Insurance Duration\"].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.389622Z","iopub.execute_input":"2024-12-14T11:46:46.389996Z","iopub.status.idle":"2024-12-14T11:46:46.413246Z","shell.execute_reply.started":"2024-12-14T11:46:46.389956Z","shell.execute_reply":"2024-12-14T11:46:46.4118Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Drop missing value only one missing value is occure**","metadata":{}},{"cell_type":"code","source":"train_data.dropna(subset=[\"Insurance Duration\"], axis=0 , inplace=True)\n\n# rename columns name\ntrain_data.rename(columns={\"Insurance Duration\":\"Insurance_Duration(year)\"},inplace=True)\n# convert float to int\ntrain_data[\"Insurance_Duration(year)\"] = train_data[\"Insurance_Duration(year)\"].astype('int')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.414545Z","iopub.execute_input":"2024-12-14T11:46:46.414834Z","iopub.status.idle":"2024-12-14T11:46:46.56807Z","shell.execute_reply.started":"2024-12-14T11:46:46.414797Z","shell.execute_reply":"2024-12-14T11:46:46.566424Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Policy Start Date","metadata":{}},{"cell_type":"code","source":"train_data[\"Policy Start Date\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.569273Z","iopub.execute_input":"2024-12-14T11:46:46.56961Z","iopub.status.idle":"2024-12-14T11:46:46.62705Z","shell.execute_reply.started":"2024-12-14T11:46:46.569581Z","shell.execute_reply":"2024-12-14T11:46:46.625078Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Policy Start Date","metadata":{}},{"cell_type":"code","source":"train_data[\"Policy Start Date\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.628591Z","iopub.execute_input":"2024-12-14T11:46:46.629099Z","iopub.status.idle":"2024-12-14T11:46:46.676728Z","shell.execute_reply.started":"2024-12-14T11:46:46.629053Z","shell.execute_reply":"2024-12-14T11:46:46.675833Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# creat three columns more and drop \"Policy Start Date\"\ntrain_data[\"Policy Start Date\"] = pd.to_datetime(train_data[\"Policy Start Date\"])\ntrain_data[\"Policy_Start_Date\"] = train_data[\"Policy Start Date\"].dt.day\ntrain_data[\"Policy_Start_Month\"] = train_data[\"Policy Start Date\"].dt.month\ntrain_data[\"Policy_Start_Year\"] = train_data[\"Policy Start Date\"].dt.year\n# Drop Policy Start Date\ntrain_data.drop(\"Policy Start Date\" , axis=1 ,inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.677871Z","iopub.execute_input":"2024-12-14T11:46:46.678213Z","iopub.status.idle":"2024-12-14T11:46:46.973699Z","shell.execute_reply.started":"2024-12-14T11:46:46.67818Z","shell.execute_reply":"2024-12-14T11:46:46.971809Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Customer Feedback","metadata":{}},{"cell_type":"code","source":"train_data[\"Customer Feedback\"].nunique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:46.97542Z","iopub.execute_input":"2024-12-14T11:46:46.975908Z","iopub.status.idle":"2024-12-14T11:46:47.018189Z","shell.execute_reply.started":"2024-12-14T11:46:46.975861Z","shell.execute_reply":"2024-12-14T11:46:47.016284Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data[\"Customer Feedback\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:47.019931Z","iopub.execute_input":"2024-12-14T11:46:47.020466Z","iopub.status.idle":"2024-12-14T11:46:47.070253Z","shell.execute_reply.started":"2024-12-14T11:46:47.020427Z","shell.execute_reply":"2024-12-14T11:46:47.06894Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Fill missing values with \"No Feedback\"**","metadata":{}},{"cell_type":"code","source":"train_data[\"Customer Feedback\"].fillna(\"No Feedback\" ,inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:47.071657Z","iopub.execute_input":"2024-12-14T11:46:47.071932Z","iopub.status.idle":"2024-12-14T11:46:47.126467Z","shell.execute_reply.started":"2024-12-14T11:46:47.071907Z","shell.execute_reply":"2024-12-14T11:46:47.125542Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Premium Amount","metadata":{}},{"cell_type":"code","source":"train_data[\"Premium Amount\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:47.128526Z","iopub.execute_input":"2024-12-14T11:46:47.128941Z","iopub.status.idle":"2024-12-14T11:46:47.155206Z","shell.execute_reply.started":"2024-12-14T11:46:47.128907Z","shell.execute_reply":"2024-12-14T11:46:47.154409Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Comvet into int\ntrain_data[\"Premium Amount\"] = train_data[\"Premium Amount\"].astype('int')\n\ntrain_data[\"Premium Amount\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:47.156321Z","iopub.execute_input":"2024-12-14T11:46:47.15658Z","iopub.status.idle":"2024-12-14T11:46:47.177797Z","shell.execute_reply.started":"2024-12-14T11:46:47.156556Z","shell.execute_reply":"2024-12-14T11:46:47.176638Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_data.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:47.17887Z","iopub.execute_input":"2024-12-14T11:46:47.179188Z","iopub.status.idle":"2024-12-14T11:46:47.604915Z","shell.execute_reply.started":"2024-12-14T11:46:47.179154Z","shell.execute_reply":"2024-12-14T11:46:47.603565Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# Test Data","metadata":{}},{"cell_type":"code","source":"print(f\"Size of Test data {test_data.shape}\")\nprint(\"--\"*20)\n\nprint('Missing Values : ')\nprint(test_data.isnull().sum())\nprint(\"--\"*20)\n\n\nprint(\"Infoamtion AboutData :\")\nprint(test_data.info())\nprint(\"--\"*20)\n\n\n\n# Age\ntest_data['Age'] = test_data['Age'].fillna(test_data[\"Age\"].mean()).astype('int')\n\n# ------------------------------------------------------------------------\n\n# Annual Income\ntest_data[\"Annual Income\"] = test_data[\"Annual Income\"].fillna(test_data[\"Annual Income\"].median()).astype('int')\n\n\n# ---------------------------------------------------------------------------\n\n\n# Marital Status\n\ntest_data[\"Marital Status\"].fillna(test_data[\"Marital Status\"].mode()[0] , inplace=True)\n\n\n# ---------------------------------------------------------------------------\n\n# Number of Dependents\n# Fill missing values and covert it into int\ntest_data[\"Number of Dependents\"]=test_data[\"Number of Dependents\"].fillna(test_data[\"Number of Dependents\"].mode()[0]).astype('int')\n\n\n# ----------------------------------------------------------------------------\n\n\n# ----------------------------------------------------------------------\n\n# Occupation\ntest_data[\"Occupation\"].fillna(\"Unknown\" , inplace=True)\n\n# ------------------------------------------------------------------------\n\n# Health Score\ntest_data[\"Health Score\"].fillna(test_data[\"Health Score\"].mean() , inplace=True)\n\n# ---------------------------------------------------------------------\n\n\n# --------------------------------------------------------------------------\n\n# Previous Claims\ntest_data[\"Previous Claims\"].fillna(test_data[\"Previous Claims\"].mode()[0] , inplace=True)\n\n# Convert into int\ntest_data[\"Previous Claims\"] = test_data[\"Previous Claims\"].astype('int')\n\n\n# --------------------------------------------------------------------------\n# Vehicle Age\n\n# Fill missing values\ntest_data[\"Vehicle Age\"].fillna(test_data[\"Vehicle Age\"].mode()[0],inplace=True)\n\n# convert float to int\ntest_data[\"Vehicle Age\"] =test_data[\"Vehicle Age\"].astype('int')\n\n\n# ----------------------------------------------------------------------------\n\n# Credit Score\n# Fill Missing Values\ntest_data[\"Credit Score\"].fillna(test_data[\"Credit Score\"].mean(),inplace=True)\n\n# Convert Dtypes Into int\ntest_data[\"Credit Score\"] = test_data[\"Credit Score\"].astype(\"int\")\n\n# ______________________________________________________________________________\n\n\n# Insurance Duration\n # drop Missing values\ntest_data.dropna(subset=[\"Insurance Duration\"], axis=0 , inplace=True)\n# rename columns name\ntest_data.rename(columns={\"Insurance Duration\":\"Insurance_Duration(year)\"},inplace=True)\n# convert float to int\ntest_data[\"Insurance_Duration(year)\"] = test_data[\"Insurance_Duration(year)\"].astype('int')\n\n# ------------------------------------------------------------------------------------\n\n# Policy Start Date\ntest_data[\"Policy Start Date\"] = pd.to_datetime(test_data[\"Policy Start Date\"])\ntest_data[\"Policy_Start_Date\"] = test_data[\"Policy Start Date\"].dt.day\ntest_data[\"Policy_Start_Month\"] = test_data[\"Policy Start Date\"].dt.month\ntest_data[\"Policy_Start_Year\"] = test_data[\"Policy Start Date\"].dt.year\n# Drop Policy Start Date\ntest_data.drop(\"Policy Start Date\" , axis=1 ,inplace=True)\n\n# ------------------------------------------------------------------------------------\n\n# Customer Feedback\ntest_data[\"Customer Feedback\"].fillna(\"No Feedback\" ,inplace=True)\n\n\n# ------------------------------------------------------------------------------------\n\n\n# Smoking Status\n\n\n# ------------------------------------------------------------------------------------\n\n\n# Exercise Frequency\n\n\n# ------------------------------------------------------------------------------------\n\n# Property Type\n\n\n# ------------------------------------------------------------------------------------\n\n\n\n# ------------------------------------------------------------------------------------\nprint(\"==\"*20)\ntest_data.isnull().sum()\n\nprint(\"==\"*20)\nprint(test_data.info())\n\n\n# ------------------------------------------------------------------------------------\n\n\n\n\n# ------------------------------------------------------------------------------------","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:47.606254Z","iopub.execute_input":"2024-12-14T11:46:47.606552Z","iopub.status.idle":"2024-12-14T11:46:49.431613Z","shell.execute_reply.started":"2024-12-14T11:46:47.606525Z","shell.execute_reply":"2024-12-14T11:46:49.430471Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(test_data.info(),\"_________________\",train_data.info())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:49.43257Z","iopub.execute_input":"2024-12-14T11:46:49.432795Z","iopub.status.idle":"2024-12-14T11:46:50.116854Z","shell.execute_reply.started":"2024-12-14T11:46:49.43277Z","shell.execute_reply":"2024-12-14T11:46:50.115286Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import OneHotEncoder , LabelEncoder , OrdinalEncoder ,StandardScaler\nfrom sklearn.model_selection import train_test_split","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:50.118033Z","iopub.execute_input":"2024-12-14T11:46:50.118284Z","iopub.status.idle":"2024-12-14T11:46:50.125067Z","shell.execute_reply.started":"2024-12-14T11:46:50.118258Z","shell.execute_reply":"2024-12-14T11:46:50.12317Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X = train_data.drop(\"Premium Amount\",axis=1)\nY = train_data[\"Premium Amount\"]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:50.126442Z","iopub.execute_input":"2024-12-14T11:46:50.126759Z","iopub.status.idle":"2024-12-14T11:46:50.265413Z","shell.execute_reply.started":"2024-12-14T11:46:50.126733Z","shell.execute_reply":"2024-12-14T11:46:50.263853Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x_train,x_test,y_train,y_test=train_test_split(X,Y ,test_size=0.2 , random_state=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:50.26634Z","iopub.execute_input":"2024-12-14T11:46:50.266643Z","iopub.status.idle":"2024-12-14T11:46:51.162017Z","shell.execute_reply.started":"2024-12-14T11:46:50.266616Z","shell.execute_reply":"2024-12-14T11:46:51.160665Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(\"x_train Size --->> \" ,x_train.shape)\nprint(\"x_test Size --->> \" ,x_test.shape)\nprint(\"y_train Size --->> \" ,y_train.shape)\nprint(\"y_test Size --->> \" ,y_test.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:51.163405Z","iopub.execute_input":"2024-12-14T11:46:51.163705Z","iopub.status.idle":"2024-12-14T11:46:51.169891Z","shell.execute_reply.started":"2024-12-14T11:46:51.16368Z","shell.execute_reply":"2024-12-14T11:46:51.168666Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**apply OneHotEncoder**","metadata":{}},{"cell_type":"code","source":"ohe = OneHotEncoder(drop='first',sparse_output=False ,dtype=np.int32)\n\nx_train_ohe = ohe.fit_transform(x_train[[\"Gender\",\"Marital Status\",\"Occupation\",\"Location\",\"Smoking Status\",\"Property Type\"]])\nx_test_ohe = ohe.transform(x_test[[\"Gender\",\"Marital Status\",\"Occupation\",\"Location\",\"Smoking Status\",\"Property Type\"]])\ntest_data_ohe = ohe.transform(test_data[[\"Gender\",\"Marital Status\",\"Occupation\",\"Location\",\"Smoking Status\",\"Property Type\"]])\n\n\nohe_column_name = ohe.get_feature_names_out([\"Gender\",\"Marital Status\",\"Occupation\",\"Location\",\"Smoking Status\",\"Property Type\"])\n\nx_train_1 = pd.DataFrame(x_train_ohe,columns=ohe_column_name.tolist(), index=x_train.index)\nx_test_1 = pd.DataFrame(x_test_ohe,columns=ohe_column_name.tolist(), index=x_test.index)\ntest_data_ohe = pd.DataFrame(test_data_ohe,columns=ohe_column_name.tolist(), index=test_data.index)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:51.170976Z","iopub.execute_input":"2024-12-14T11:46:51.171256Z","iopub.status.idle":"2024-12-14T11:46:53.785876Z","shell.execute_reply.started":"2024-12-14T11:46:51.171231Z","shell.execute_reply":"2024-12-14T11:46:53.784558Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"\n**apply OrdinalEncoder**","metadata":{}},{"cell_type":"code","source":"oe = OrdinalEncoder(categories=[['PhD', \"Master's\", \"Bachelor's\", 'High School'],\n                                ['Premium', 'Comprehensive', 'Basic'],\n                                ['Good', \"Average\", \"Poor\", \"No Feedback\"],\n                                [\"Rarely\", \"Monthly\", \"Weekly\", \"Daily\"]] , dtype=int)\n\n\nx_train_oe = oe.fit_transform(x_train[[\"Education Level\", \"Policy Type\", \"Customer Feedback\", \"Exercise Frequency\"]])\nx_test_oe = oe.transform(x_test[[\"Education Level\", \"Policy Type\", \"Customer Feedback\", \"Exercise Frequency\"]])\ntest_data_oe = oe.transform(test_data[[\"Education Level\", \"Policy Type\", \"Customer Feedback\", \"Exercise Frequency\"]])\n\nx_train_2 = pd.DataFrame(x_train_oe,columns=[\"Education Level\", \"Policy Type\", \"Customer Feedback\", \"Exercise Frequency\"] ,index=x_train.index)\nx_test_2 = pd.DataFrame(x_test_oe,columns=[\"Education Level\", \"Policy Type\", \"Customer Feedback\", \"Exercise Frequency\"], index=x_test.index)\ntest_data_oe = pd.DataFrame(test_data_oe,columns=[\"Education Level\", \"Policy Type\", \"Customer Feedback\", \"Exercise Frequency\"], index=test_data.index)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:53.787322Z","iopub.execute_input":"2024-12-14T11:46:53.787753Z","iopub.status.idle":"2024-12-14T11:46:54.909528Z","shell.execute_reply.started":"2024-12-14T11:46:53.787722Z","shell.execute_reply":"2024-12-14T11:46:54.90834Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"\n**Standard Scaler**","metadata":{}},{"cell_type":"code","source":"scaler = StandardScaler()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:54.910748Z","iopub.execute_input":"2024-12-14T11:46:54.91108Z","iopub.status.idle":"2024-12-14T11:46:54.915892Z","shell.execute_reply.started":"2024-12-14T11:46:54.911048Z","shell.execute_reply":"2024-12-14T11:46:54.914524Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x_train_num_feature = x_train.select_dtypes(\"number\").copy()\nx_test_num_feature = x_test.select_dtypes(\"number\").copy()\ntest_data_num_feature = test_data.select_dtypes(\"number\").copy()\n\nx_train_num_feature[[\"Age\",\"Annual Income\",\"Health Score\",\"Vehicle Age\",\"Credit Score\"]] = scaler.fit_transform(x_train_num_feature[[\"Age\",\"Annual Income\",\"Health Score\",\"Vehicle Age\",\"Credit Score\"]])\nx_test_num_feature[[\"Age\",\"Annual Income\",\"Health Score\",\"Vehicle Age\",\"Credit Score\"]] = scaler.fit_transform(x_test_num_feature[[\"Age\",\"Annual Income\",\"Health Score\",\"Vehicle Age\",\"Credit Score\"]])\ntest_data_num_feature[[\"Age\",\"Annual Income\",\"Health Score\",\"Vehicle Age\",\"Credit Score\"]] = scaler.fit_transform(test_data_num_feature[[\"Age\",\"Annual Income\",\"Health Score\",\"Vehicle Age\",\"Credit Score\"]])\n\ntest_data_num_feature.head(1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:54.917299Z","iopub.execute_input":"2024-12-14T11:46:54.917673Z","iopub.status.idle":"2024-12-14T11:46:55.199075Z","shell.execute_reply.started":"2024-12-14T11:46:54.917633Z","shell.execute_reply":"2024-12-14T11:46:55.19787Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x_train_new = pd.concat([x_train_1 ,x_train_2 ,x_train_num_feature],axis=1)\nx_test_new = pd.concat([x_test_1 ,x_test_2 ,x_test_num_feature],axis=1)\ntest_data_new = pd.concat([test_data_ohe ,test_data_oe ,test_data_num_feature],axis=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:55.200763Z","iopub.execute_input":"2024-12-14T11:46:55.201199Z","iopub.status.idle":"2024-12-14T11:46:55.370895Z","shell.execute_reply.started":"2024-12-14T11:46:55.201157Z","shell.execute_reply":"2024-12-14T11:46:55.369558Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_data_new.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:55.372994Z","iopub.execute_input":"2024-12-14T11:46:55.373451Z","iopub.status.idle":"2024-12-14T11:46:55.39685Z","shell.execute_reply.started":"2024-12-14T11:46:55.373413Z","shell.execute_reply":"2024-12-14T11:46:55.39565Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Feature Importance**","metadata":{"execution":{"iopub.status.busy":"2024-12-14T10:09:53.41652Z","iopub.status.idle":"2024-12-14T10:09:53.416863Z","shell.execute_reply.started":"2024-12-14T10:09:53.416729Z","shell.execute_reply":"2024-12-14T10:09:53.416745Z"}}},{"cell_type":"code","source":"dddd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:46:55.398645Z","iopub.execute_input":"2024-12-14T11:46:55.398975Z","iopub.status.idle":"2024-12-14T11:46:55.434522Z","shell.execute_reply.started":"2024-12-14T11:46:55.398948Z","shell.execute_reply":"2024-12-14T11:46:55.432891Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.ensemble import ExtraTreesRegressor","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:47:36.72234Z","iopub.execute_input":"2024-12-14T11:47:36.722783Z","iopub.status.idle":"2024-12-14T11:47:36.727958Z","shell.execute_reply.started":"2024-12-14T11:47:36.722755Z","shell.execute_reply":"2024-12-14T11:47:36.726803Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"selection = ExtraTreesRegressor()\nselection.fit(x_train_new,y_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T11:47:36.729531Z","iopub.execute_input":"2024-12-14T11:47:36.729902Z","iopub.status.idle":"2024-12-14T12:03:44.514525Z","shell.execute_reply.started":"2024-12-14T11:47:36.729873Z","shell.execute_reply":"2024-12-14T12:03:44.512071Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"selection.feature_importances_","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:44.517124Z","iopub.execute_input":"2024-12-14T12:03:44.517511Z","iopub.status.idle":"2024-12-14T12:03:45.987658Z","shell.execute_reply.started":"2024-12-14T12:03:44.517483Z","shell.execute_reply":"2024-12-14T12:03:45.986407Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,6))\nfeature_importance = pd.Series(selection.feature_importances_ ,index=x_train_new.columns)\nfeature_importance.nlargest(20).plot(kind='barh')\n\nplt.title(\"Feature Selection\",fontweight=\"bold\")\nplt.xlabel(\"Importance\")\nplt.ylabel(\"Features\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:45.991422Z","iopub.execute_input":"2024-12-14T12:03:45.99192Z","iopub.status.idle":"2024-12-14T12:03:47.749913Z","shell.execute_reply.started":"2024-12-14T12:03:45.991851Z","shell.execute_reply":"2024-12-14T12:03:47.749018Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**Model Training**","metadata":{}},{"cell_type":"markdown","source":"**Linear Regressor**","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\nfrom sklearn.metrics import r2_score , mean_squared_log_error","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:47.750965Z","iopub.execute_input":"2024-12-14T12:03:47.751222Z","iopub.status.idle":"2024-12-14T12:03:47.75503Z","shell.execute_reply.started":"2024-12-14T12:03:47.751198Z","shell.execute_reply":"2024-12-14T12:03:47.754256Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_LR = LinearRegression()\nmodel_LR.fit(x_train_new,y_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:47.756078Z","iopub.execute_input":"2024-12-14T12:03:47.756364Z","iopub.status.idle":"2024-12-14T12:03:48.792582Z","shell.execute_reply.started":"2024-12-14T12:03:47.756318Z","shell.execute_reply":"2024-12-14T12:03:48.791799Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_LR = model_LR.predict(x_test_new)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:48.793523Z","iopub.execute_input":"2024-12-14T12:03:48.793843Z","iopub.status.idle":"2024-12-14T12:03:48.832919Z","shell.execute_reply.started":"2024-12-14T12:03:48.793804Z","shell.execute_reply":"2024-12-14T12:03:48.832122Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"r2_score(pred_LR,y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:48.834531Z","iopub.execute_input":"2024-12-14T12:03:48.834827Z","iopub.status.idle":"2024-12-14T12:03:48.84456Z","shell.execute_reply.started":"2024-12-14T12:03:48.834797Z","shell.execute_reply":"2024-12-14T12:03:48.843364Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_LR,y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:48.84663Z","iopub.execute_input":"2024-12-14T12:03:48.846945Z","iopub.status.idle":"2024-12-14T12:03:48.877254Z","shell.execute_reply.started":"2024-12-14T12:03:48.846916Z","shell.execute_reply":"2024-12-14T12:03:48.875048Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**DecissionTree**","metadata":{}},{"cell_type":"code","source":"from sklearn.tree import DecisionTreeRegressor","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:48.883561Z","iopub.execute_input":"2024-12-14T12:03:48.883925Z","iopub.status.idle":"2024-12-14T12:03:48.892315Z","shell.execute_reply.started":"2024-12-14T12:03:48.883895Z","shell.execute_reply":"2024-12-14T12:03:48.891033Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_DT = DecisionTreeRegressor()\nmodel_DT.fit(x_train_new , y_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:03:48.896396Z","iopub.execute_input":"2024-12-14T12:03:48.896906Z","iopub.status.idle":"2024-12-14T12:04:11.34538Z","shell.execute_reply.started":"2024-12-14T12:03:48.896863Z","shell.execute_reply":"2024-12-14T12:04:11.344197Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_DT = model_DT.predict(x_test_new)\nr2_score(pred_DT,y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:04:11.346731Z","iopub.execute_input":"2024-12-14T12:04:11.347011Z","iopub.status.idle":"2024-12-14T12:04:11.627146Z","shell.execute_reply.started":"2024-12-14T12:04:11.346986Z","shell.execute_reply":"2024-12-14T12:04:11.625874Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_DT,y_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:04:11.62894Z","iopub.execute_input":"2024-12-14T12:04:11.629287Z","iopub.status.idle":"2024-12-14T12:04:11.647792Z","shell.execute_reply.started":"2024-12-14T12:04:11.62925Z","shell.execute_reply":"2024-12-14T12:04:11.646534Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**RandomForest**","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestRegressor","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:04:11.648905Z","iopub.execute_input":"2024-12-14T12:04:11.649143Z","iopub.status.idle":"2024-12-14T12:04:11.654615Z","shell.execute_reply.started":"2024-12-14T12:04:11.649119Z","shell.execute_reply":"2024-12-14T12:04:11.653211Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_RF = RandomForestRegressor()\nmodel_RF.fit(x_train_new , y_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T12:04:11.656247Z","iopub.execute_input":"2024-12-14T12:04:11.656692Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_RF = model_RF.predict(x_test_new)\nr2_score(pred_RF,y_test","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_RF,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**SVR**","metadata":{}},{"cell_type":"code","source":"from sklearn.svm import SVR","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_svm = SVR()\nmodel_svm.fit(x_train_new , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_svm = model_svm.predict(x_test_new)\nr2_score(pred_svm,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_svm,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**AdaBoosting**","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import AdaBoostRegressor","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_ada = AdaBoostRegressor()\nmodel_ada.fit(x_train_new , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_ada = model_ada.predict(x_test_new)\nr2_score(pred_ada,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_ada,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Gradient Boosting","metadata":{}},{"cell_type":"code","source":"from sklearn.ensemble import GradientBoostingRegressor","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_gradient = GradientBoostingRegressor()\nmodel_gradient.fit(x_train_new , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_gradient = model_gradient.predict(x_test_new)\nr2_score(pred_gradient,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_gradient,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**CatBoostRegressor**","metadata":{}},{"cell_type":"code","source":"from catboost import CatBoostRegressor","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_DT = CatBoostRegressor()\nmodel_DT.fit(x_train , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_DT = model_DT.predict(x_test)\nr2_score(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_DT = DecisionTreeRegressor()\nmodel_DT.fit(x_train_new , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_DT = model_DT.predict(x_test_new)\nr2_score(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_DT = DecisionTreeRegressor()\nmodel_DT.fit(x_train_new , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_DT = model_DT.predict(x_test_new)\nr2_score(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_DT = DecisionTreeRegressor()\nmodel_DT.fit(x_train_new , y_train)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred_DT = model_DT.predict(x_test_new)\nr2_score(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mean_squared_log_error(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestRegressor\nmodel_DT = DecisionTreeRegressor()\nmodel_DT.fit(x_train_new , y_train)\n\npred_DT = model_DT.predict(x_test_new)\nr2_score(pred_DT,y_test)\n\nmean_squared_log_error(pred_DT,y_test)","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"models={\n    \"LineaRegression\":LinearRegression(),\n    \"Ridge\":Ridge(),\n    \"Lasso\":Lasso(),\n    \"DecisionTree\":DecisionTreeRegressor(),\n    \"RandomForest\":RandomForestRegressor(),\n    \"SVM\":SVR(),\n    \"AdaBoost\":AdaBoostRegressor(),\n    \"GradientBoosting\":GradientBoostingRegressor(),\n    'CatBoost':CatBoostRegressor\n}","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def evaluation_metrics(true,y_test):\n    msle = mean_squared_log_error(true,y_test)\n    score=r2_score(true,y_test)\n\n    rerturn mse , score","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"R2_score=[]\nmodel_list = []\nmean_sq_log_error = []\n\nfor name , model in models:\n    ","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}