{"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":30786,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport plotly.graph_objs as go\nimport plotly.offline as py\nimport plotly.express as px\n\nimport warnings\nwarnings.filterwarnings('ignore')\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:25:17.58282Z","iopub.execute_input":"2024-12-01T09:25:17.58343Z","iopub.status.idle":"2024-12-01T09:25:17.589383Z","shell.execute_reply.started":"2024-12-01T09:25:17.583389Z","shell.execute_reply":"2024-12-01T09:25:17.588167Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/playground-series-s4e12/train.csv')\ndf.sample(10)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:27:41.37701Z","iopub.execute_input":"2024-12-01T09:27:41.377404Z","iopub.status.idle":"2024-12-01T09:27:46.365368Z","shell.execute_reply.started":"2024-12-01T09:27:41.377367Z","shell.execute_reply":"2024-12-01T09:27:46.364055Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(df.shape)\n    \nprint(df.dtypes)\n    \nprint(df.isnull().sum())\n    \nprint(df.describe())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:28:50.874371Z","iopub.execute_input":"2024-12-01T09:28:50.874757Z","iopub.status.idle":"2024-12-01T09:28:52.207156Z","shell.execute_reply.started":"2024-12-01T09:28:50.874725Z","shell.execute_reply":"2024-12-01T09:28:52.206001Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"code","source":"X = [\"Age\", \"Gender\", \"Annual Income\",\"Education Level\",\"Occupation\",\"Health Score\",\"Premium Amount\"]\n\ndata = df[X]\ny = df[\"Premium Amount\"]\ndata.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:31:59.795673Z","iopub.execute_input":"2024-12-01T09:31:59.796038Z","iopub.status.idle":"2024-12-01T09:31:59.84945Z","shell.execute_reply.started":"2024-12-01T09:31:59.796006Z","shell.execute_reply":"2024-12-01T09:31:59.848329Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:39:44.382344Z","iopub.execute_input":"2024-12-01T09:39:44.382859Z","iopub.status.idle":"2024-12-01T09:39:45.03921Z","shell.execute_reply.started":"2024-12-01T09:39:44.382792Z","shell.execute_reply":"2024-12-01T09:39:45.038042Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"obj = df.select_dtypes(\"object\")\n\nfor column in obj:\n    df[column].fillna(df[column].mode()[0], inplace=True)\n\nflo = df.select_dtypes([\"float64\",\"int64\"]).drop(\"Premium Amount\",axis=1)\n\nfor column in flo:\n    df[column].fillna(df[column].median(), inplace=True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:43:38.88551Z","iopub.execute_input":"2024-12-01T09:43:38.885864Z","iopub.status.idle":"2024-12-01T09:43:41.420785Z","shell.execute_reply.started":"2024-12-01T09:43:38.885835Z","shell.execute_reply":"2024-12-01T09:43:41.419748Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# df.isnull().sum()\n\n# Yup was just making sure this was doing something ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:44:30.947031Z","iopub.execute_input":"2024-12-01T09:44:30.947455Z","iopub.status.idle":"2024-12-01T09:44:30.952323Z","shell.execute_reply.started":"2024-12-01T09:44:30.947407Z","shell.execute_reply":"2024-12-01T09:44:30.951012Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LinearRegression","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:44:42.375659Z","iopub.execute_input":"2024-12-01T09:44:42.376073Z","iopub.status.idle":"2024-12-01T09:44:42.677158Z","shell.execute_reply.started":"2024-12-01T09:44:42.376035Z","shell.execute_reply":"2024-12-01T09:44:42.675835Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\n\n# Label Encoding\nfor column in df.columns:\n    if df[column].dtype=='object': \n        le = LabelEncoder()\n        le.fit([df[column].values])\n        df[column] = le.transform(list(df[f].values))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:48:29.905974Z","iopub.execute_input":"2024-12-01T09:48:29.906446Z","iopub.status.idle":"2024-12-01T09:48:29.912969Z","shell.execute_reply.started":"2024-12-01T09:48:29.906407Z","shell.execute_reply":"2024-12-01T09:48:29.911708Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"y = df['Premium Amount']\nX = df.drop(['Premium Amount'], axis = 1)\n\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state = 42)\n\nlr = LinearRegression().fit(X_train,y_train)\ny_train_pred = lr.predict(X_train)\ny_test_pred = lr.predict(X_test)\n\nprint(lr.score(X_test,y_test))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T09:50:42.24156Z","iopub.execute_input":"2024-12-01T09:50:42.241983Z","iopub.status.idle":"2024-12-01T09:50:44.157364Z","shell.execute_reply.started":"2024-12-01T09:50:42.241944Z","shell.execute_reply":"2024-12-01T09:50:44.153998Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# yea no idea if i could do worse than this","metadata":{}},{"cell_type":"code","source":"submission = pd.read_csv('../input/playground-series-s4e12/sample_submission.csv')\nsubmission['Premium Amount'] = np.mean(y_test_pred, axis=0)\nsubmission.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T10:03:51.311728Z","iopub.execute_input":"2024-12-01T10:03:51.312106Z","iopub.status.idle":"2024-12-01T10:03:51.588251Z","shell.execute_reply.started":"2024-12-01T10:03:51.312073Z","shell.execute_reply":"2024-12-01T10:03:51.587179Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission.to_csv('baseline_sub_1.csv', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T10:07:37.45023Z","iopub.execute_input":"2024-12-01T10:07:37.450602Z","iopub.status.idle":"2024-12-01T10:07:39.153566Z","shell.execute_reply.started":"2024-12-01T10:07:37.450571Z","shell.execute_reply":"2024-12-01T10:07:39.152043Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-01T10:07:26.352461Z","iopub.execute_input":"2024-12-01T10:07:26.352861Z","iopub.status.idle":"2024-12-01T10:07:26.360038Z","shell.execute_reply.started":"2024-12-01T10:07:26.352826Z","shell.execute_reply":"2024-12-01T10:07:26.358715Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}