{"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":"markdown","source":"### Simple Baseline Deep Learning Approach with Pytorch\n\n- Basic Preprossessing\n- baseline DL Model\n- submission","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.metrics import accuracy_score, mean_squared_error\nimport warnings\n\nwarnings.filterwarnings('ignore')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:21:50.908421Z","iopub.execute_input":"2024-12-09T16:21:50.909072Z","iopub.status.idle":"2024-12-09T16:21:53.865423Z","shell.execute_reply.started":"2024-12-09T16:21:50.908964Z","shell.execute_reply":"2024-12-09T16:21:53.864097Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/playground-series-s4e12/train.csv', index_col='id', engine='pyarrow')\ntest_df = pd.read_csv('/kaggle/input/playground-series-s4e12/test.csv', index_col='id', engine='pyarrow')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:22:00.391663Z","iopub.execute_input":"2024-12-09T16:22:00.392066Z","iopub.status.idle":"2024-12-09T16:22:04.167408Z","shell.execute_reply.started":"2024-12-09T16:22:00.392012Z","shell.execute_reply":"2024-12-09T16:22:04.166133Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:22:06.262176Z","iopub.execute_input":"2024-12-09T16:22:06.262564Z","iopub.status.idle":"2024-12-09T16:22:06.298298Z","shell.execute_reply.started":"2024-12-09T16:22:06.262523Z","shell.execute_reply":"2024-12-09T16:22:06.296997Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:22:08.620293Z","iopub.execute_input":"2024-12-09T16:22:08.620702Z","iopub.status.idle":"2024-12-09T16:22:08.645316Z","shell.execute_reply.started":"2024-12-09T16:22:08.620667Z","shell.execute_reply":"2024-12-09T16:22:08.643993Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def date_separator(x):\n    return pd.Series([x.day, x.month, x.year])\n\ntrain_df[['day', 'month', 'year']] = train_df['Policy Start Date'].apply(date_separator)\ntest_df[['day', 'month', 'year']] = test_df['Policy Start Date'].apply(date_separator)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:22:10.831107Z","iopub.execute_input":"2024-12-09T16:22:10.83149Z","iopub.status.idle":"2024-12-09T16:25:46.082779Z","shell.execute_reply.started":"2024-12-09T16:22:10.831454Z","shell.execute_reply":"2024-12-09T16:25:46.08156Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:16.878528Z","iopub.execute_input":"2024-12-09T16:27:16.878958Z","iopub.status.idle":"2024-12-09T16:27:17.474894Z","shell.execute_reply.started":"2024-12-09T16:27:16.878921Z","shell.execute_reply":"2024-12-09T16:27:17.473766Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.isna().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:20.166421Z","iopub.execute_input":"2024-12-09T16:27:20.166827Z","iopub.status.idle":"2024-12-09T16:27:20.750842Z","shell.execute_reply.started":"2024-12-09T16:27:20.166788Z","shell.execute_reply":"2024-12-09T16:27:20.749636Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"target = 'Premium Amount'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:23.259641Z","iopub.execute_input":"2024-12-09T16:27:23.260071Z","iopub.status.idle":"2024-12-09T16:27:23.265269Z","shell.execute_reply.started":"2024-12-09T16:27:23.26Z","shell.execute_reply":"2024-12-09T16:27:23.264004Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"numerical_features = train_df.drop(target, axis=1).select_dtypes(include=np.number).columns.values\nnumerical_features","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:24.912894Z","iopub.execute_input":"2024-12-09T16:27:24.913302Z","iopub.status.idle":"2024-12-09T16:27:25.164385Z","shell.execute_reply.started":"2024-12-09T16:27:24.913263Z","shell.execute_reply":"2024-12-09T16:27:25.163343Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"categorical_features = train_df.drop(target, axis=1).select_dtypes(include='object').columns.values\ncategorical_features","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:27.036234Z","iopub.execute_input":"2024-12-09T16:27:27.036639Z","iopub.status.idle":"2024-12-09T16:27:27.673932Z","shell.execute_reply.started":"2024-12-09T16:27:27.036603Z","shell.execute_reply":"2024-12-09T16:27:27.672613Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.duplicated().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:29.419411Z","iopub.execute_input":"2024-12-09T16:27:29.419795Z","iopub.status.idle":"2024-12-09T16:27:30.806601Z","shell.execute_reply.started":"2024-12-09T16:27:29.41976Z","shell.execute_reply":"2024-12-09T16:27:30.805525Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df[numerical_features].astype(np.float_).describe().T","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:32.102633Z","iopub.execute_input":"2024-12-09T16:27:32.103004Z","iopub.status.idle":"2024-12-09T16:27:33.009385Z","shell.execute_reply.started":"2024-12-09T16:27:32.102971Z","shell.execute_reply":"2024-12-09T16:27:33.008118Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.describe(include='O').T","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:35.322549Z","iopub.execute_input":"2024-12-09T16:27:35.322954Z","iopub.status.idle":"2024-12-09T16:27:36.949476Z","shell.execute_reply.started":"2024-12-09T16:27:35.322914Z","shell.execute_reply":"2024-12-09T16:27:36.948362Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler, FunctionTransformer, LabelEncoder, OneHotEncoder\nfrom sklearn.pipeline import make_pipeline, Pipeline\nfrom sklearn.compose import ColumnTransformer, make_column_selector, make_column_transformer\nfrom sklearn.experimental import enable_iterative_imputer\nfrom sklearn.impute import SimpleImputer, IterativeImputer\nimport category_encoders as ce\n\npreprocessing = ColumnTransformer([\n    ('num', make_pipeline(SimpleImputer(strategy='mean'), FunctionTransformer(), StandardScaler()), numerical_features),\n    ('cat', make_pipeline(SimpleImputer(strategy='most_frequent'), ce.cat_boost.CatBoostEncoder()), categorical_features)\n], remainder='drop')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:39.146731Z","iopub.execute_input":"2024-12-09T16:27:39.14717Z","iopub.status.idle":"2024-12-09T16:27:39.722428Z","shell.execute_reply.started":"2024-12-09T16:27:39.147131Z","shell.execute_reply":"2024-12-09T16:27:39.721379Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X = train_df.copy()\ny = X.pop(target)\ny = np.log1p(y)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:42.906099Z","iopub.execute_input":"2024-12-09T16:27:42.907086Z","iopub.status.idle":"2024-12-09T16:27:43.469252Z","shell.execute_reply.started":"2024-12-09T16:27:42.907009Z","shell.execute_reply":"2024-12-09T16:27:43.468115Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X = preprocessing.fit_transform(X, y)\ntestProcessed = preprocessing.transform(test_df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:27:45.611505Z","iopub.execute_input":"2024-12-09T16:27:45.61197Z","iopub.status.idle":"2024-12-09T16:27:56.851942Z","shell.execute_reply.started":"2024-12-09T16:27:45.611931Z","shell.execute_reply":"2024-12-09T16:27:56.85088Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from lightgbm import LGBMRegressor","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:00.183918Z","iopub.execute_input":"2024-12-09T16:28:00.184314Z","iopub.status.idle":"2024-12-09T16:28:01.254875Z","shell.execute_reply.started":"2024-12-09T16:28:00.184278Z","shell.execute_reply":"2024-12-09T16:28:01.253762Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:01.902879Z","iopub.execute_input":"2024-12-09T16:28:01.90345Z","iopub.status.idle":"2024-12-09T16:28:01.912045Z","shell.execute_reply.started":"2024-12-09T16:28:01.903414Z","shell.execute_reply":"2024-12-09T16:28:01.910455Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"y.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:03.843093Z","iopub.execute_input":"2024-12-09T16:28:03.843479Z","iopub.status.idle":"2024-12-09T16:28:03.851079Z","shell.execute_reply.started":"2024-12-09T16:28:03.843446Z","shell.execute_reply":"2024-12-09T16:28:03.849838Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"testProcessed.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:05.872355Z","iopub.execute_input":"2024-12-09T16:28:05.872733Z","iopub.status.idle":"2024-12-09T16:28:05.880317Z","shell.execute_reply.started":"2024-12-09T16:28:05.872699Z","shell.execute_reply":"2024-12-09T16:28:05.878883Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import DataLoader, TensorDataset\nimport numpy as np\n\n# Set random seed for reproducibility\ntorch.manual_seed(42)\nnp.random.seed(42)\n\n# Custom RMSLE Loss Function\nclass RMSLELoss(nn.Module):\n    def __init__(self):\n        super(RMSLELoss, self).__init__()\n    \n    def forward(self, pred, target):\n        # Ensure predictions and targets are non-negative\n        pred = torch.clamp(pred, min=0)\n        target = torch.clamp(target, min=0)\n        \n        # Apply log(1+x) transformation\n        log_pred = torch.log1p(pred)\n        log_target = torch.log1p(target)\n        \n        # Calculate mean squared error of log-transformed values\n        loss = torch.sqrt(torch.mean(torch.pow(log_pred - log_target, 2)))\n        return loss","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:11.175612Z","iopub.execute_input":"2024-12-09T16:28:11.176106Z","iopub.status.idle":"2024-12-09T16:28:12.750881Z","shell.execute_reply.started":"2024-12-09T16:28:11.17601Z","shell.execute_reply":"2024-12-09T16:28:12.749582Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\n\n# Assuming X, y, and testProcessed are numpy arrays\n# Convert to PyTorch tensors\nX_tensor = torch.FloatTensor(X)\ny_tensor = torch.FloatTensor(y)\ntest_tensor = torch.FloatTensor(testProcessed)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:15.327381Z","iopub.execute_input":"2024-12-09T16:28:15.327965Z","iopub.status.idle":"2024-12-09T16:28:15.668732Z","shell.execute_reply.started":"2024-12-09T16:28:15.327928Z","shell.execute_reply":"2024-12-09T16:28:15.667814Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\n\n# Normalize the input features\ndef normalize_data(data):\n    mean = torch.mean(data, dim=0)\n    std = torch.std(data, dim=0)\n    return (data - mean) / (std + 1e-7)  # Adding small epsilon to avoid division by zero\n\nX_normalized = normalize_data(X_tensor)\ntest_normalized = normalize_data(test_tensor)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:18.775333Z","iopub.execute_input":"2024-12-09T16:28:18.775721Z","iopub.status.idle":"2024-12-09T16:28:19.184622Z","shell.execute_reply.started":"2024-12-09T16:28:18.775688Z","shell.execute_reply":"2024-12-09T16:28:19.18312Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\n\n# Create DataLoader\ntrain_dataset = TensorDataset(X_normalized, y_tensor)\ntrain_loader = DataLoader(train_dataset, batch_size=1024, shuffle=True)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:21.65757Z","iopub.execute_input":"2024-12-09T16:28:21.658032Z","iopub.status.idle":"2024-12-09T16:28:21.665342Z","shell.execute_reply.started":"2024-12-09T16:28:21.657979Z","shell.execute_reply":"2024-12-09T16:28:21.663793Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Define the Neural Network Model\nclass PremiumPredictor(nn.Module):\n    def __init__(self, input_dim):\n        super(PremiumPredictor, self).__init__()\n        self.network = nn.Sequential(\n            nn.Linear(input_dim, 256),\n            nn.ReLU(),\n            nn.BatchNorm1d(256),\n            nn.Dropout(0.3),\n            nn.Linear(256, 128),\n            nn.ReLU(),\n            nn.BatchNorm1d(128),\n            nn.Dropout(0.3),\n            nn.Linear(128, 64),\n            nn.ReLU(),\n            nn.BatchNorm1d(64),\n            nn.Dropout(0.2),\n            nn.Linear(64, 1),\n            nn.ReLU()  # Ensure non-negative predictions\n        )\n    \n    def forward(self, x):\n        return self.network(x)\n\n\n\n# Instantiate the model\ninput_dim = X_tensor.shape[1]\nmodel = PremiumPredictor(input_dim)\n\n# Loss and Optimizer\ncriterion = RMSLELoss()\noptimizer = optim.Adam(model.parameters(), lr=0.001)\n\n# Learning Rate Scheduler\nscheduler = optim.lr_scheduler.ReduceLROnPlateau(optimizer, mode='min', factor=0.5, patience=5, verbose=True)\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:27.508742Z","iopub.execute_input":"2024-12-09T16:28:27.509194Z","iopub.status.idle":"2024-12-09T16:28:28.484094Z","shell.execute_reply.started":"2024-12-09T16:28:27.509152Z","shell.execute_reply":"2024-12-09T16:28:28.482893Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Training Loop\ndef train_model(model, train_loader, criterion, optimizer, scheduler, epochs=50):\n    model.train()\n    best_loss = float('inf')\n    \n    for epoch in range(epochs):\n        total_loss = 0\n        for batch_x, batch_y in train_loader:\n            # Forward pass\n            outputs = model(batch_x)\n            loss = criterion(outputs.squeeze(), batch_y)\n            \n            # Backward pass and optimize\n            optimizer.zero_grad()\n            loss.backward()\n            optimizer.step()\n            \n            total_loss += loss.item()\n        \n        # Average loss for the epoch\n        avg_loss = total_loss / len(train_loader)\n        \n        # Learning rate scheduling\n        scheduler.step(avg_loss)\n        \n        # Print progress and save best model\n        if (epoch + 1) % 5 == 0:\n            print(f'Epoch [{epoch+1}/{epochs}], Loss: {avg_loss:.4f}')\n        \n        # Save the best model\n        if avg_loss < best_loss:\n            best_loss = avg_loss\n            torch.save(model.state_dict(), 'best_insurance_premium_predictor.pth')\n\n# Train the model\ntrain_model(model, train_loader, criterion, optimizer, scheduler)\n\n\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:28:33.982077Z","iopub.execute_input":"2024-12-09T16:28:33.983222Z","iopub.status.idle":"2024-12-09T16:47:22.064673Z","shell.execute_reply.started":"2024-12-09T16:28:33.983175Z","shell.execute_reply":"2024-12-09T16:47:22.0634Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prediction\ndef predict_premiums(model, test_data):\n    model.eval()\n    with torch.no_grad():\n        predictions = model(test_data).numpy()\n    return np.maximum(predictions, 0)  # Ensure non-negative predictions\n\n# Make predictions on the test set\ntest_predictions = predict_premiums(model, test_normalized)\n\n# Optional: Save the final model\ntorch.save(model.state_dict(), 'final_insurance_premium_predictor.pth')\n\n# Print some basic statistics about predictions\nprint(\"\\nPrediction Statistics:\")\nprint(\"Mean Predicted Premium:\", np.mean(test_predictions))\nprint(\"Median Predicted Premium:\", np.median(test_predictions))\nprint(\"Standard Deviation of Predictions:\", np.std(test_predictions))\n\n# Save predictions\nnp.savetxt('test_premium_predictions.csv', test_predictions, delimiter=',')\n\nprint(\"\\nModel training completed. Predictions saved.\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:49:40.632524Z","iopub.execute_input":"2024-12-09T16:49:40.632949Z","iopub.status.idle":"2024-12-09T16:49:46.099835Z","shell.execute_reply.started":"2024-12-09T16:49:40.632915Z","shell.execute_reply":"2024-12-09T16:49:46.098434Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Calculation of RMSLE (for verification)\ndef calculate_rmsle(y_true, y_pred):\n    y_true = np.maximum(y_true, 0)\n    y_pred = np.maximum(y_pred, 0)\n    log_true = np.log1p(y_true)\n    log_pred = np.log1p(y_pred)\n    squared_log_errors = np.power(log_pred - log_true, 2)\n    return np.sqrt(np.mean(squared_log_errors))\n\n# Uncomment and modify if you have true test labels\n# rmsle = calculate_rmsle(y_test, test_predictions)\n# print(f\"Root Mean Squared Logarithmic Error: {rmsle}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:49:53.976757Z","iopub.execute_input":"2024-12-09T16:49:53.977218Z","iopub.status.idle":"2024-12-09T16:49:53.983925Z","shell.execute_reply.started":"2024-12-09T16:49:53.977177Z","shell.execute_reply":"2024-12-09T16:49:53.982647Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_predictions.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:51:39.360929Z","iopub.execute_input":"2024-12-09T16:51:39.362085Z","iopub.status.idle":"2024-12-09T16:51:39.602715Z","shell.execute_reply.started":"2024-12-09T16:51:39.362009Z","shell.execute_reply":"2024-12-09T16:51:39.601223Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:50.136248Z","iopub.execute_input":"2024-12-08T08:27:50.136961Z","iopub.status.idle":"2024-12-08T08:27:50.142547Z","shell.execute_reply.started":"2024-12-08T08:27:50.136908Z","shell.execute_reply":"2024-12-08T08:27:50.141119Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:50.144639Z","iopub.execute_input":"2024-12-08T08:27:50.145127Z","iopub.status.idle":"2024-12-08T08:27:50.338391Z","shell.execute_reply.started":"2024-12-08T08:27:50.145072Z","shell.execute_reply":"2024-12-08T08:27:50.337281Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:50.34017Z","iopub.execute_input":"2024-12-08T08:27:50.340587Z","iopub.status.idle":"2024-12-08T08:27:50.345853Z","shell.execute_reply.started":"2024-12-08T08:27:50.340541Z","shell.execute_reply":"2024-12-08T08:27:50.344756Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:50.447135Z","iopub.execute_input":"2024-12-08T08:27:50.447555Z","iopub.status.idle":"2024-12-08T08:27:50.459665Z","shell.execute_reply.started":"2024-12-08T08:27:50.447509Z","shell.execute_reply":"2024-12-08T08:27:50.458556Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:55.743904Z","iopub.execute_input":"2024-12-08T08:27:55.745482Z","iopub.status.idle":"2024-12-08T08:27:55.75112Z","shell.execute_reply.started":"2024-12-08T08:27:55.74543Z","shell.execute_reply":"2024-12-08T08:27:55.749587Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:50.347187Z","iopub.execute_input":"2024-12-08T08:27:50.347556Z","iopub.status.idle":"2024-12-08T08:27:50.4454Z","shell.execute_reply.started":"2024-12-08T08:27:50.347524Z","shell.execute_reply":"2024-12-08T08:27:50.444344Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-08T08:27:58.472184Z","iopub.execute_input":"2024-12-08T08:27:58.472643Z","iopub.status.idle":"2024-12-08T08:27:58.478672Z","shell.execute_reply.started":"2024-12-08T08:27:58.4726Z","shell.execute_reply":"2024-12-08T08:27:58.477257Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sub = pd.read_csv(\"/kaggle/input/playground-series-s4e12/sample_submission.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:50:15.017601Z","iopub.execute_input":"2024-12-09T16:50:15.018506Z","iopub.status.idle":"2024-12-09T16:50:15.314175Z","shell.execute_reply.started":"2024-12-09T16:50:15.018466Z","shell.execute_reply":"2024-12-09T16:50:15.312981Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sub[target] = np.expm1(test_predictions)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:53:22.763764Z","iopub.execute_input":"2024-12-09T16:53:22.764267Z","iopub.status.idle":"2024-12-09T16:53:22.787394Z","shell.execute_reply.started":"2024-12-09T16:53:22.764226Z","shell.execute_reply":"2024-12-09T16:53:22.786403Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sub.to_csv(\"submission_for_insurance.csv\", index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-09T16:53:45.269458Z","iopub.execute_input":"2024-12-09T16:53:45.269821Z","iopub.status.idle":"2024-12-09T16:53:46.460232Z","shell.execute_reply.started":"2024-12-09T16:53:45.269784Z","shell.execute_reply":"2024-12-09T16:53:46.459104Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}