{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","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":30822,"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-20T15:54:52.001027Z","iopub.execute_input":"2024-12-20T15:54:52.001436Z","iopub.status.idle":"2024-12-20T15:54:52.404092Z","shell.execute_reply.started":"2024-12-20T15:54:52.001389Z","shell.execute_reply":"2024-12-20T15:54:52.403136Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport scipy.stats as sts\nfrom scipy.stats import skew\nfrom scipy.stats import kurtosis\nimport statistics\nimport warnings","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:54:52.405224Z","iopub.execute_input":"2024-12-20T15:54:52.405773Z","iopub.status.idle":"2024-12-20T15:54:53.350234Z","shell.execute_reply.started":"2024-12-20T15:54:52.405741Z","shell.execute_reply":"2024-12-20T15:54:53.349162Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/playground-series-s4e12/sample_submission.csv\")\ntrain = pd.read_csv(\"/kaggle/input/playground-series-s4e12/train.csv\")\ntest = pd.read_csv(\"/kaggle/input/playground-series-s4e12/test.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:54:53.351421Z","iopub.execute_input":"2024-12-20T15:54:53.352036Z","iopub.status.idle":"2024-12-20T15:55:05.559112Z","shell.execute_reply.started":"2024-12-20T15:54:53.35199Z","shell.execute_reply":"2024-12-20T15:55:05.558157Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_combined = pd.concat([df.reset_index(drop=True),test.reset_index(drop = True),train.reset_index(drop=True)],axis=1)\ndf_combined = df_combined.loc[:,~df_combined.columns.duplicated()]\ndf_combined.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:05.561306Z","iopub.execute_input":"2024-12-20T15:55:05.561662Z","iopub.status.idle":"2024-12-20T15:55:06.659772Z","shell.execute_reply.started":"2024-12-20T15:55:05.561633Z","shell.execute_reply":"2024-12-20T15:55:06.658872Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_combined","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:06.66122Z","iopub.execute_input":"2024-12-20T15:55:06.661638Z","iopub.status.idle":"2024-12-20T15:55:07.55207Z","shell.execute_reply.started":"2024-12-20T15:55:06.661607Z","shell.execute_reply":"2024-12-20T15:55:07.551127Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_combined.isna().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:07.553179Z","iopub.execute_input":"2024-12-20T15:55:07.553466Z","iopub.status.idle":"2024-12-20T15:55:08.089871Z","shell.execute_reply.started":"2024-12-20T15:55:07.55344Z","shell.execute_reply":"2024-12-20T15:55:08.088795Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_combined.dtypes","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:08.09074Z","iopub.execute_input":"2024-12-20T15:55:08.09103Z","iopub.status.idle":"2024-12-20T15:55:08.098684Z","shell.execute_reply.started":"2024-12-20T15:55:08.091005Z","shell.execute_reply":"2024-12-20T15:55:08.097815Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"numerical_columns = df_combined[['id','Premium Amount','Age','Annual Income','Number of Dependents','Health Score','Previous Claims','Vehicle Age','Credit Score','Insurance Duration']]\ncategorical_columns = df_combined[['Gender','Marital Status','Education Level','Occupation','Location','Policy Type','Customer Feedback','Smoking Status','Exercise Frequency','Property Type','Policy Start Date']]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:08.099743Z","iopub.execute_input":"2024-12-20T15:55:08.100119Z","iopub.status.idle":"2024-12-20T15:55:08.292103Z","shell.execute_reply.started":"2024-12-20T15:55:08.100086Z","shell.execute_reply":"2024-12-20T15:55:08.291208Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"numerical_columns = df_combined[['id','Premium Amount','Age','Annual Income','Number of Dependents','Health Score','Previous Claims','Vehicle Age','Credit Score','Insurance Duration']].median()\ndf_combined = df_combined[['id','Premium Amount','Age','Annual Income','Number of Dependents','Health Score','Previous Claims','Vehicle Age','Credit Score','Insurance Duration']].fillna(numerical_columns)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:08.293015Z","iopub.execute_input":"2024-12-20T15:55:08.293294Z","iopub.status.idle":"2024-12-20T15:55:08.773979Z","shell.execute_reply.started":"2024-12-20T15:55:08.293268Z","shell.execute_reply":"2024-12-20T15:55:08.772776Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Calculate the percentage of each category in each column\nnumeric_columns = numerical_columns.select_dtypes(include =['float64','int64'])\nnumerical_percentages_nu = numerical_columns.apply(lambda col: col.value_counts(normalize=True) * 100).round(2)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:08.775177Z","iopub.execute_input":"2024-12-20T15:55:08.775579Z","iopub.status.idle":"2024-12-20T15:55:08.930215Z","shell.execute_reply.started":"2024-12-20T15:55:08.775539Z","shell.execute_reply":"2024-12-20T15:55:08.928801Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_combined.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-20T15:55:08.930822Z","iopub.status.idle":"2024-12-20T15:55:08.931142Z","shell.execute_reply":"2024-12-20T15:55:08.931018Z"}},"outputs":[],"execution_count":null}]}