{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":84896,"databundleVersionId":10305135,"sourceType":"competition"}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"id":"80caa206-5f74-425d-9637-1924ec874a67","cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:20:54.508344Z","iopub.execute_input":"2024-12-14T16:20:54.509564Z","iopub.status.idle":"2024-12-14T16:20:54.517324Z","shell.execute_reply.started":"2024-12-14T16:20:54.50952Z","shell.execute_reply":"2024-12-14T16:20:54.516149Z"}},"outputs":[],"execution_count":null},{"id":"fae4a90b","cell_type":"code","source":"# Data Manipulation and Visualization\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# Machine Learning\nfrom sklearn.model_selection import train_test_split, GridSearchCV\nfrom sklearn.preprocessing import StandardScaler, LabelEncoder\nfrom sklearn.ensemble import RandomForestRegressor\n\n# Model Evaluation\nfrom sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:20:54.519251Z","iopub.execute_input":"2024-12-14T16:20:54.519718Z","iopub.status.idle":"2024-12-14T16:20:56.342395Z","shell.execute_reply.started":"2024-12-14T16:20:54.519671Z","shell.execute_reply":"2024-12-14T16:20:56.34123Z"}},"outputs":[],"execution_count":null},{"id":"f5b34d5c","cell_type":"code","source":"train = pd.read_csv('/kaggle/input/playground-series-s4e12/train.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:20:56.34447Z","iopub.execute_input":"2024-12-14T16:20:56.345161Z","iopub.status.idle":"2024-12-14T16:21:03.782677Z","shell.execute_reply.started":"2024-12-14T16:20:56.345075Z","shell.execute_reply":"2024-12-14T16:21:03.781541Z"}},"outputs":[],"execution_count":null},{"id":"d4a21444","cell_type":"code","source":"train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:03.784175Z","iopub.execute_input":"2024-12-14T16:21:03.784656Z","iopub.status.idle":"2024-12-14T16:21:03.829164Z","shell.execute_reply.started":"2024-12-14T16:21:03.784597Z","shell.execute_reply":"2024-12-14T16:21:03.828021Z"}},"outputs":[],"execution_count":null},{"id":"300e52ee","cell_type":"code","source":"train.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:03.832157Z","iopub.execute_input":"2024-12-14T16:21:03.832616Z","iopub.status.idle":"2024-12-14T16:21:04.517753Z","shell.execute_reply.started":"2024-12-14T16:21:03.832568Z","shell.execute_reply":"2024-12-14T16:21:04.516575Z"}},"outputs":[],"execution_count":null},{"id":"d4d7297b","cell_type":"code","source":"train.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:04.519489Z","iopub.execute_input":"2024-12-14T16:21:04.519946Z","iopub.status.idle":"2024-12-14T16:21:05.252351Z","shell.execute_reply.started":"2024-12-14T16:21:04.519899Z","shell.execute_reply":"2024-12-14T16:21:05.250965Z"}},"outputs":[],"execution_count":null},{"id":"cc3dac28","cell_type":"code","source":"train.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:05.25386Z","iopub.execute_input":"2024-12-14T16:21:05.254287Z","iopub.status.idle":"2024-12-14T16:21:05.903406Z","shell.execute_reply.started":"2024-12-14T16:21:05.254251Z","shell.execute_reply":"2024-12-14T16:21:05.902314Z"}},"outputs":[],"execution_count":null},{"id":"c7716ce0","cell_type":"code","source":"test = pd.read_csv('/kaggle/input/playground-series-s4e12/test.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:05.904838Z","iopub.execute_input":"2024-12-14T16:21:05.905298Z","iopub.status.idle":"2024-12-14T16:21:10.341Z","shell.execute_reply.started":"2024-12-14T16:21:05.905252Z","shell.execute_reply":"2024-12-14T16:21:10.339246Z"}},"outputs":[],"execution_count":null},{"id":"e920d4bf","cell_type":"code","source":"test.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:10.342757Z","iopub.execute_input":"2024-12-14T16:21:10.34328Z","iopub.status.idle":"2024-12-14T16:21:10.369864Z","shell.execute_reply.started":"2024-12-14T16:21:10.343226Z","shell.execute_reply":"2024-12-14T16:21:10.368456Z"}},"outputs":[],"execution_count":null},{"id":"32fa290b","cell_type":"code","source":"test.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:10.371482Z","iopub.execute_input":"2024-12-14T16:21:10.371858Z","iopub.status.idle":"2024-12-14T16:21:10.818455Z","shell.execute_reply.started":"2024-12-14T16:21:10.371823Z","shell.execute_reply":"2024-12-14T16:21:10.81716Z"}},"outputs":[],"execution_count":null},{"id":"6219db4a","cell_type":"code","source":"test.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:10.821835Z","iopub.execute_input":"2024-12-14T16:21:10.822249Z","iopub.status.idle":"2024-12-14T16:21:11.254351Z","shell.execute_reply.started":"2024-12-14T16:21:10.822211Z","shell.execute_reply":"2024-12-14T16:21:11.253231Z"}},"outputs":[],"execution_count":null},{"id":"d37901ce","cell_type":"code","source":"test.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:11.255714Z","iopub.execute_input":"2024-12-14T16:21:11.256042Z","iopub.status.idle":"2024-12-14T16:21:11.684291Z","shell.execute_reply.started":"2024-12-14T16:21:11.25601Z","shell.execute_reply":"2024-12-14T16:21:11.683197Z"}},"outputs":[],"execution_count":null},{"id":"2eead622","cell_type":"code","source":"train['Gender']=train['Gender'].replace({'Female':0,'Male':1})\ntest['Gender']=test['Gender'].replace({'Female':0,'Male':1})","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:11.685635Z","iopub.execute_input":"2024-12-14T16:21:11.685957Z","iopub.status.idle":"2024-12-14T16:21:12.40295Z","shell.execute_reply.started":"2024-12-14T16:21:11.685926Z","shell.execute_reply":"2024-12-14T16:21:12.401737Z"}},"outputs":[],"execution_count":null},{"id":"2f9256d8","cell_type":"code","source":"print(\"Categorical columns in training data\")\ncategorical=train.select_dtypes(include=['object']).columns\ncategorical\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:12.404471Z","iopub.execute_input":"2024-12-14T16:21:12.404825Z","iopub.status.idle":"2024-12-14T16:21:12.564769Z","shell.execute_reply.started":"2024-12-14T16:21:12.404791Z","shell.execute_reply":"2024-12-14T16:21:12.563682Z"}},"outputs":[],"execution_count":null},{"id":"ed8940d0","cell_type":"code","source":"print(train[categorical].nunique())\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:12.566174Z","iopub.execute_input":"2024-12-14T16:21:12.566637Z","iopub.status.idle":"2024-12-14T16:21:13.64038Z","shell.execute_reply.started":"2024-12-14T16:21:12.566569Z","shell.execute_reply":"2024-12-14T16:21:13.639042Z"}},"outputs":[],"execution_count":null},{"id":"71584a06","cell_type":"code","source":"print(\"Numerical  columns in training data\")\nnumerical=train.select_dtypes(include=['float']).columns\nnumerical\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:13.641637Z","iopub.execute_input":"2024-12-14T16:21:13.642059Z","iopub.status.idle":"2024-12-14T16:21:13.68504Z","shell.execute_reply.started":"2024-12-14T16:21:13.642015Z","shell.execute_reply":"2024-12-14T16:21:13.683951Z"}},"outputs":[],"execution_count":null},{"id":"68746989","cell_type":"code","source":"print(train[numerical].nunique())\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:13.686273Z","iopub.execute_input":"2024-12-14T16:21:13.686577Z","iopub.status.idle":"2024-12-14T16:21:13.928584Z","shell.execute_reply.started":"2024-12-14T16:21:13.686548Z","shell.execute_reply":"2024-12-14T16:21:13.926574Z"}},"outputs":[],"execution_count":null},{"id":"b1e8a098","cell_type":"code","source":"train[numerical].isnull().sum()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:13.930464Z","iopub.execute_input":"2024-12-14T16:21:13.930908Z","iopub.status.idle":"2024-12-14T16:21:13.989428Z","shell.execute_reply.started":"2024-12-14T16:21:13.930862Z","shell.execute_reply":"2024-12-14T16:21:13.988356Z"}},"outputs":[],"execution_count":null},{"id":"00497809","cell_type":"code","source":"print(\"Numerical  columns in testing data\")\nnumericalt=test.select_dtypes(include=['float']).columns\nnumericalt\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:13.990802Z","iopub.execute_input":"2024-12-14T16:21:13.991248Z","iopub.status.idle":"2024-12-14T16:21:14.019718Z","shell.execute_reply.started":"2024-12-14T16:21:13.991154Z","shell.execute_reply":"2024-12-14T16:21:14.018573Z"}},"outputs":[],"execution_count":null},{"id":"c25c48a4","cell_type":"code","source":"print(test[numericalt].nunique())\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:14.020941Z","iopub.execute_input":"2024-12-14T16:21:14.021273Z","iopub.status.idle":"2024-12-14T16:21:14.170791Z","shell.execute_reply.started":"2024-12-14T16:21:14.021242Z","shell.execute_reply":"2024-12-14T16:21:14.169651Z"}},"outputs":[],"execution_count":null},{"id":"30ae8f77","cell_type":"code","source":"test[numericalt].isnull().sum()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:14.172467Z","iopub.execute_input":"2024-12-14T16:21:14.172811Z","iopub.status.idle":"2024-12-14T16:21:14.209919Z","shell.execute_reply.started":"2024-12-14T16:21:14.172778Z","shell.execute_reply":"2024-12-14T16:21:14.208503Z"}},"outputs":[],"execution_count":null},{"id":"16c87fdb","cell_type":"code","source":"print(\"Categorical columns in testing data\")\ncategoricalt=test.select_dtypes(include=['object']).columns\ncategoricalt\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:14.211416Z","iopub.execute_input":"2024-12-14T16:21:14.211907Z","iopub.status.idle":"2024-12-14T16:21:14.324015Z","shell.execute_reply.started":"2024-12-14T16:21:14.211853Z","shell.execute_reply":"2024-12-14T16:21:14.322804Z"}},"outputs":[],"execution_count":null},{"id":"fc5ebbcf","cell_type":"code","source":"print(test[categoricalt].nunique())\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:14.325848Z","iopub.execute_input":"2024-12-14T16:21:14.326263Z","iopub.status.idle":"2024-12-14T16:21:15.028698Z","shell.execute_reply.started":"2024-12-14T16:21:14.326227Z","shell.execute_reply":"2024-12-14T16:21:15.02747Z"}},"outputs":[],"execution_count":null},{"id":"5a536eb6","cell_type":"code","source":"train[numerical]=train[numerical].fillna(train[numerical].mean())\ntest[numericalt]=test[numericalt].fillna(test[numericalt].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:15.029852Z","iopub.execute_input":"2024-12-14T16:21:15.030183Z","iopub.status.idle":"2024-12-14T16:21:15.504888Z","shell.execute_reply.started":"2024-12-14T16:21:15.030145Z","shell.execute_reply":"2024-12-14T16:21:15.503835Z"}},"outputs":[],"execution_count":null},{"id":"5aab5142","cell_type":"code","source":"train[numericalt].isnull().sum()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:15.506274Z","iopub.execute_input":"2024-12-14T16:21:15.506629Z","iopub.status.idle":"2024-12-14T16:21:15.573498Z","shell.execute_reply.started":"2024-12-14T16:21:15.506589Z","shell.execute_reply":"2024-12-14T16:21:15.572213Z"}},"outputs":[],"execution_count":null},{"id":"4a0435b6","cell_type":"code","source":"test[numericalt].isnull().sum()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:15.575045Z","iopub.execute_input":"2024-12-14T16:21:15.575536Z","iopub.status.idle":"2024-12-14T16:21:15.617709Z","shell.execute_reply.started":"2024-12-14T16:21:15.575488Z","shell.execute_reply":"2024-12-14T16:21:15.616594Z"}},"outputs":[],"execution_count":null},{"id":"bfac841e","cell_type":"code","source":"train= train.drop(['Marital Status','Policy Start Date','Customer Feedback','Education Level'], axis=1)\ntest= test.drop(['Marital Status','Policy Start Date','Customer Feedback','Education Level'], axis=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:15.618801Z","iopub.execute_input":"2024-12-14T16:21:15.61911Z","iopub.status.idle":"2024-12-14T16:21:15.811372Z","shell.execute_reply.started":"2024-12-14T16:21:15.61908Z","shell.execute_reply":"2024-12-14T16:21:15.810296Z"}},"outputs":[],"execution_count":null},{"id":"6787bd04","cell_type":"code","source":"train = pd.get_dummies(train,drop_first=True)\ntest= pd.get_dummies(test,drop_first=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:15.812733Z","iopub.execute_input":"2024-12-14T16:21:15.813184Z","iopub.status.idle":"2024-12-14T16:21:17.100201Z","shell.execute_reply.started":"2024-12-14T16:21:15.813113Z","shell.execute_reply":"2024-12-14T16:21:17.099204Z"}},"outputs":[],"execution_count":null},{"id":"f8689938","cell_type":"code","source":"train.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:17.105226Z","iopub.execute_input":"2024-12-14T16:21:17.105552Z","iopub.status.idle":"2024-12-14T16:21:17.151081Z","shell.execute_reply.started":"2024-12-14T16:21:17.105523Z","shell.execute_reply":"2024-12-14T16:21:17.149966Z"}},"outputs":[],"execution_count":null},{"id":"d4e6dfa1","cell_type":"code","source":"test.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:17.152745Z","iopub.execute_input":"2024-12-14T16:21:17.153221Z","iopub.status.idle":"2024-12-14T16:21:17.187723Z","shell.execute_reply.started":"2024-12-14T16:21:17.153171Z","shell.execute_reply":"2024-12-14T16:21:17.186522Z"}},"outputs":[],"execution_count":null},{"id":"bf284bdd","cell_type":"code","source":"train.isnull().sum()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:17.188959Z","iopub.execute_input":"2024-12-14T16:21:17.189312Z","iopub.status.idle":"2024-12-14T16:21:17.228439Z","shell.execute_reply.started":"2024-12-14T16:21:17.189278Z","shell.execute_reply":"2024-12-14T16:21:17.227312Z"}},"outputs":[],"execution_count":null},{"id":"a3a857b0","cell_type":"code","source":"test.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:17.229876Z","iopub.execute_input":"2024-12-14T16:21:17.231603Z","iopub.status.idle":"2024-12-14T16:21:17.259587Z","shell.execute_reply.started":"2024-12-14T16:21:17.231545Z","shell.execute_reply":"2024-12-14T16:21:17.258401Z"}},"outputs":[],"execution_count":null},{"id":"46441f6c","cell_type":"code","source":"# Separate features (X) and target (y)\nX = train.drop(columns=['Premium Amount'])  # Drop the target\ny = train['Premium Amount']  # Target variable","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:17.260911Z","iopub.execute_input":"2024-12-14T16:21:17.261291Z","iopub.status.idle":"2024-12-14T16:21:17.300265Z","shell.execute_reply.started":"2024-12-14T16:21:17.261256Z","shell.execute_reply":"2024-12-14T16:21:17.299187Z"}},"outputs":[],"execution_count":null},{"id":"68985956","cell_type":"code","source":"plt.figure(figsize=(12, 8))\nsns.heatmap(train.corr(), annot=True, cmap='coolwarm')\nplt.title('Feature Correlation with Premium')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:17.301669Z","iopub.execute_input":"2024-12-14T16:21:17.302008Z","iopub.status.idle":"2024-12-14T16:21:20.932797Z","shell.execute_reply.started":"2024-12-14T16:21:17.301975Z","shell.execute_reply":"2024-12-14T16:21:20.931674Z"}},"outputs":[],"execution_count":null},{"id":"fb638d39","cell_type":"code","source":"import seaborn as sns\n# Distribution of target variable\nsns.histplot(y, kde=True)\nplt.title('Distribution of Insurance Premiums')\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:20.934302Z","iopub.execute_input":"2024-12-14T16:21:20.934871Z","iopub.status.idle":"2024-12-14T16:21:27.001377Z","shell.execute_reply.started":"2024-12-14T16:21:20.934808Z","shell.execute_reply":"2024-12-14T16:21:27.00022Z"}},"outputs":[],"execution_count":null},{"id":"3ca48758","cell_type":"code","source":"# Train-test split (80% train, 20% test)\nX_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:27.003015Z","iopub.execute_input":"2024-12-14T16:21:27.003504Z","iopub.status.idle":"2024-12-14T16:21:27.291403Z","shell.execute_reply.started":"2024-12-14T16:21:27.003451Z","shell.execute_reply":"2024-12-14T16:21:27.2901Z"}},"outputs":[],"execution_count":null},{"id":"f1e81c39","cell_type":"code","source":"# Scale numerical features (standardize features)\nscaler = StandardScaler()\nX_train = scaler.fit_transform(X_train)\nX_val = scaler.transform(X_val)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:27.292928Z","iopub.execute_input":"2024-12-14T16:21:27.293325Z","iopub.status.idle":"2024-12-14T16:21:28.937008Z","shell.execute_reply.started":"2024-12-14T16:21:27.293287Z","shell.execute_reply":"2024-12-14T16:21:28.935828Z"}},"outputs":[],"execution_count":null},{"id":"afead7e3","cell_type":"code","source":"from sklearn.linear_model import LinearRegression\n\n# Initialize model\nlr_model = LinearRegression()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:28.938356Z","iopub.execute_input":"2024-12-14T16:21:28.938698Z","iopub.status.idle":"2024-12-14T16:21:28.944357Z","shell.execute_reply.started":"2024-12-14T16:21:28.938665Z","shell.execute_reply":"2024-12-14T16:21:28.942999Z"}},"outputs":[],"execution_count":null},{"id":"31fa3dec","cell_type":"code","source":"# Train model\nlr_model.fit(X_train, y_train)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:28.945786Z","iopub.execute_input":"2024-12-14T16:21:28.946299Z","iopub.status.idle":"2024-12-14T16:21:30.361204Z","shell.execute_reply.started":"2024-12-14T16:21:28.946245Z","shell.execute_reply":"2024-12-14T16:21:30.359885Z"}},"outputs":[],"execution_count":null},{"id":"dc9d002b","cell_type":"code","source":"# Make predictions\ny_pred = lr_model.predict(X_val)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:30.362696Z","iopub.execute_input":"2024-12-14T16:21:30.364265Z","iopub.status.idle":"2024-12-14T16:21:30.380566Z","shell.execute_reply.started":"2024-12-14T16:21:30.364222Z","shell.execute_reply":"2024-12-14T16:21:30.377829Z"}},"outputs":[],"execution_count":null},{"id":"3d65eb17","cell_type":"code","source":"mse = mean_squared_error(y_val, y_pred)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:30.38284Z","iopub.execute_input":"2024-12-14T16:21:30.383508Z","iopub.status.idle":"2024-12-14T16:21:30.393886Z","shell.execute_reply.started":"2024-12-14T16:21:30.383434Z","shell.execute_reply":"2024-12-14T16:21:30.391871Z"}},"outputs":[],"execution_count":null},{"id":"b511133c","cell_type":"code","source":"mae = mean_absolute_error(y_val, y_pred)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:30.395882Z","iopub.execute_input":"2024-12-14T16:21:30.397918Z","iopub.status.idle":"2024-12-14T16:21:30.410789Z","shell.execute_reply.started":"2024-12-14T16:21:30.39783Z","shell.execute_reply":"2024-12-14T16:21:30.407888Z"}},"outputs":[],"execution_count":null},{"id":"836eb6a1","cell_type":"code","source":"r2 = r2_score(y_val, y_pred)\nprint(f'MSE: {mse}, MAE: {mae}, R2: {r2}')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:30.41485Z","iopub.execute_input":"2024-12-14T16:21:30.416885Z","iopub.status.idle":"2024-12-14T16:21:30.439844Z","shell.execute_reply.started":"2024-12-14T16:21:30.416804Z","shell.execute_reply":"2024-12-14T16:21:30.436293Z"}},"outputs":[],"execution_count":null},{"id":"b53d90af","cell_type":"code","source":"# Step 12: Predict on Test Set\ntest_scaled = scaler.transform(test)\ntest_predictions = lr_model.predict(test_scaled)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:30.445397Z","iopub.execute_input":"2024-12-14T16:21:30.447569Z","iopub.status.idle":"2024-12-14T16:21:31.366632Z","shell.execute_reply.started":"2024-12-14T16:21:30.447491Z","shell.execute_reply":"2024-12-14T16:21:31.364491Z"}},"outputs":[],"execution_count":null},{"id":"e0712191","cell_type":"code","source":"test_predictions","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:31.371625Z","iopub.execute_input":"2024-12-14T16:21:31.372317Z","iopub.status.idle":"2024-12-14T16:21:31.392211Z","shell.execute_reply.started":"2024-12-14T16:21:31.372249Z","shell.execute_reply":"2024-12-14T16:21:31.387292Z"}},"outputs":[],"execution_count":null},{"id":"eddf035e-bbd0-46aa-9f74-1624972ae014","cell_type":"code","source":"test_ids = test['id']  # Save the original ID column\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:31.394226Z","iopub.execute_input":"2024-12-14T16:21:31.399612Z","iopub.status.idle":"2024-12-14T16:21:31.411333Z","shell.execute_reply.started":"2024-12-14T16:21:31.399522Z","shell.execute_reply":"2024-12-14T16:21:31.408653Z"}},"outputs":[],"execution_count":null},{"id":"dce7c1e6-c0a6-4f8f-be2b-c5b1ea2be421","cell_type":"code","source":"test_ids.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:21:31.413181Z","iopub.execute_input":"2024-12-14T16:21:31.413795Z","iopub.status.idle":"2024-12-14T16:21:31.432702Z","shell.execute_reply.started":"2024-12-14T16:21:31.413719Z","shell.execute_reply":"2024-12-14T16:21:31.431241Z"}},"outputs":[],"execution_count":null},{"id":"eb6526aa-3f19-4c8d-8af1-31f5d6ffc1aa","cell_type":"code","source":"df = pd.DataFrame({'id': test_ids, 'Premium Amount': test_predictions})\ndf.to_csv('submission.csv', index=False)\n\nprint(\"\\nPredictions saved to 'submission.csv'\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:27:51.904339Z","iopub.execute_input":"2024-12-14T16:27:51.90487Z","iopub.status.idle":"2024-12-14T16:27:53.670056Z","shell.execute_reply.started":"2024-12-14T16:27:51.904824Z","shell.execute_reply":"2024-12-14T16:27:53.668765Z"}},"outputs":[],"execution_count":null},{"id":"73450e0b","cell_type":"code","source":"df =pd.read_csv('submission.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:27:55.749497Z","iopub.execute_input":"2024-12-14T16:27:55.750002Z","iopub.status.idle":"2024-12-14T16:27:56.011797Z","shell.execute_reply.started":"2024-12-14T16:27:55.749957Z","shell.execute_reply":"2024-12-14T16:27:56.010444Z"}},"outputs":[],"execution_count":null},{"id":"c0a8eb8c","cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-14T16:27:57.693306Z","iopub.execute_input":"2024-12-14T16:27:57.693778Z","iopub.status.idle":"2024-12-14T16:27:57.706748Z","shell.execute_reply.started":"2024-12-14T16:27:57.693741Z","shell.execute_reply":"2024-12-14T16:27:57.705323Z"}},"outputs":[],"execution_count":null},{"id":"b6caba87-bf7a-4a32-853b-c962150d1984","cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}