{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":104803,"databundleVersionId":12615271,"sourceType":"competition"}],"dockerImageVersionId":31040,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# Standard library imports\nimport os\nimport time\n\n# Third-party imports\nimport joblib\nimport matplotlib.pylab as plt\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\n\n# Configure plotting style\nplt.style.use('ggplot')\n\n# Set pandas display option\npd.set_option('display.max_columns', 35)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:49.641394Z","iopub.execute_input":"2025-06-10T10:00:49.641721Z","iopub.status.idle":"2025-06-10T10:00:49.647532Z","shell.execute_reply.started":"2025-06-10T10:00:49.641697Z","shell.execute_reply":"2025-06-10T10:00:49.646358Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/data-science-5-sbu/train.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:49.649048Z","iopub.execute_input":"2025-06-10T10:00:49.649328Z","iopub.status.idle":"2025-06-10T10:00:54.455481Z","shell.execute_reply.started":"2025-06-10T10:00:49.649299Z","shell.execute_reply":"2025-06-10T10:00:54.454614Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:54.456298Z","iopub.execute_input":"2025-06-10T10:00:54.456572Z","iopub.status.idle":"2025-06-10T10:00:54.462326Z","shell.execute_reply.started":"2025-06-10T10:00:54.456536Z","shell.execute_reply":"2025-06-10T10:00:54.461381Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:54.463254Z","iopub.execute_input":"2025-06-10T10:00:54.463507Z","iopub.status.idle":"2025-06-10T10:00:55.061967Z","shell.execute_reply.started":"2025-06-10T10:00:54.463486Z","shell.execute_reply":"2025-06-10T10:00:55.061121Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# df['Years Lived'] = df['Years Lived'].astype(int)\n# df['Dependent Count'] = df['Dependent Count'].astype(int)\n# df['Prior Claims'] = df['Prior Claims'].astype(int)\n# df['Automobile Age'] = df['Automobile Age'].astype(int)\n# df['Coverage Period'] = df['Coverage Period'].astype(int)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:55.063916Z","iopub.execute_input":"2025-06-10T10:00:55.064177Z","iopub.status.idle":"2025-06-10T10:00:55.068064Z","shell.execute_reply.started":"2025-06-10T10:00:55.064156Z","shell.execute_reply":"2025-06-10T10:00:55.067218Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:55.068870Z","iopub.execute_input":"2025-06-10T10:00:55.069087Z","iopub.status.idle":"2025-06-10T10:00:55.102179Z","shell.execute_reply.started":"2025-06-10T10:00:55.069070Z","shell.execute_reply":"2025-06-10T10:00:55.101330Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:55.103072Z","iopub.execute_input":"2025-06-10T10:00:55.103340Z","iopub.status.idle":"2025-06-10T10:00:55.771726Z","shell.execute_reply.started":"2025-06-10T10:00:55.103319Z","shell.execute_reply":"2025-06-10T10:00:55.770941Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"cat_features = df.select_dtypes(include=['object'])\n\nfor cat in cat_features:\n    print('------------------------')\n    print(f'Unique Values for {cat}:')\n    print(df[cat].value_counts())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:55.772769Z","iopub.execute_input":"2025-06-10T10:00:55.773098Z","iopub.status.idle":"2025-06-10T10:00:57.158273Z","shell.execute_reply.started":"2025-06-10T10:00:55.773071Z","shell.execute_reply":"2025-06-10T10:00:57.157229Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.isna().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:57.159115Z","iopub.execute_input":"2025-06-10T10:00:57.159343Z","iopub.status.idle":"2025-06-10T10:00:57.798135Z","shell.execute_reply.started":"2025-06-10T10:00:57.159326Z","shell.execute_reply":"2025-06-10T10:00:57.797374Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def plot_numerical_distributions(data):\n    \"\"\"\n    Plot distributions of all numerical columns in a dataset using subplots.\n    \n    Parameters:\n    data (pd.DataFrame): Input dataframe containing the data\n    \"\"\"\n    # Select only numerical columns\n    numerical_cols = data.select_dtypes(include=[np.number]).columns\n    \n    # Calculate number of rows needed (3 columns per row)\n    n_cols = 3\n    n_rows = (len(numerical_cols) + n_cols - 1) // n_cols\n    \n    # Create figure and axes\n    fig, axes = plt.subplots(n_rows, n_cols, figsize=(15, 5*n_rows))\n    axes = axes.flatten()  # Flatten in case of 2D array of axes\n    \n    # Plot each numerical column\n    for i, col in enumerate(numerical_cols):\n        if i < len(axes):  # Ensure we don't exceed the number of axes\n            sns.histplot(data=data, x=col, kde=True, ax=axes[i])\n            axes[i].set_title(f'Distribution of {col}')\n            axes[i].set_xlabel('')\n    \n    # Hide any unused axes\n    for j in range(i+1, len(axes)):\n        axes[j].set_visible(False)\n    \n    plt.tight_layout()\n    plt.show()\n\nplot_numerical_distributions(df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:00:57.799061Z","iopub.execute_input":"2025-06-10T10:00:57.799364Z","iopub.status.idle":"2025-06-10T10:01:44.204498Z","shell.execute_reply.started":"2025-06-10T10:00:57.799338Z","shell.execute_reply":"2025-06-10T10:01:44.203637Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df['Automobile Age'].value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-10T10:01:44.205747Z","iopub.execute_input":"2025-06-10T10:01:44.206052Z","iopub.status.idle":"2025-06-10T10:01:44.229046Z","shell.execute_reply.started":"2025-06-10T10:01:44.206029Z","shell.execute_reply":"2025-06-10T10:01:44.228146Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}