{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":68479,"databundleVersionId":10950255,"isSourceIdPinned":false}],"dockerImageVersionId":31328,"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":"2026-04-10T16:31:20.481354Z","iopub.execute_input":"2026-04-10T16:31:20.481775Z","iopub.status.idle":"2026-04-10T16:31:20.498294Z","shell.execute_reply.started":"2026-04-10T16:31:20.481744Z","shell.execute_reply":"2026-04-10T16:31:20.497354Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import seaborn as sns\nimport matplotlib.pyplot as plt\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import r2_score\nimport tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:32:53.512328Z","iopub.execute_input":"2026-04-10T16:32:53.512678Z","iopub.status.idle":"2026-04-10T16:33:32.992276Z","shell.execute_reply.started":"2026-04-10T16:32:53.512645Z","shell.execute_reply":"2026-04-10T16:33:32.991318Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv(\"/kaggle/input/competitions/playground-series-s4e2/train.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:31:21.711564Z","iopub.execute_input":"2026-04-10T16:31:21.711879Z","iopub.status.idle":"2026-04-10T16:31:21.782519Z","shell.execute_reply.started":"2026-04-10T16:31:21.711850Z","shell.execute_reply":"2026-04-10T16:31:21.781515Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:31:29.472132Z","iopub.execute_input":"2026-04-10T16:31:29.472677Z","iopub.status.idle":"2026-04-10T16:31:29.521216Z","shell.execute_reply.started":"2026-04-10T16:31:29.472643Z","shell.execute_reply":"2026-04-10T16:31:29.519732Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:32:35.621123Z","iopub.execute_input":"2026-04-10T16:32:35.621546Z","iopub.status.idle":"2026-04-10T16:32:35.642752Z","shell.execute_reply.started":"2026-04-10T16:32:35.621513Z","shell.execute_reply":"2026-04-10T16:32:35.641850Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train[\"NObeyesdad\"].unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:33:32.993502Z","iopub.execute_input":"2026-04-10T16:33:32.994041Z","iopub.status.idle":"2026-04-10T16:33:33.002455Z","shell.execute_reply.started":"2026-04-10T16:33:32.994010Z","shell.execute_reply":"2026-04-10T16:33:33.001643Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"mapping = {\n    'Insufficient_Weight': 0,\n    'Normal_Weight': 1,\n    'Overweight_Level_I': 2,\n    'Overweight_Level_II': 3,\n    'Obesity_Type_I': 4,\n    'Obesity_Type_II': 5,\n    'Obesity_Type_III': 6\n}\n\ntrain['NObeyesdad'] = train['NObeyesdad'].map(mapping)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:35:07.250986Z","iopub.execute_input":"2026-04-10T16:35:07.251397Z","iopub.status.idle":"2026-04-10T16:35:07.260436Z","shell.execute_reply.started":"2026-04-10T16:35:07.251362Z","shell.execute_reply":"2026-04-10T16:35:07.259076Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:35:11.563544Z","iopub.execute_input":"2026-04-10T16:35:11.563933Z","iopub.status.idle":"2026-04-10T16:35:11.583579Z","shell.execute_reply.started":"2026-04-10T16:35:11.563888Z","shell.execute_reply":"2026-04-10T16:35:11.581853Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x = train.drop([\"id\",\"NObeyesdad\"], axis=1)\ny = train['NObeyesdad']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:35:48.071715Z","iopub.execute_input":"2026-04-10T16:35:48.072527Z","iopub.status.idle":"2026-04-10T16:35:48.080187Z","shell.execute_reply.started":"2026-04-10T16:35:48.072487Z","shell.execute_reply":"2026-04-10T16:35:48.079050Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x = pd.get_dummies(x,drop_first = True).astype(int)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:35:58.351792Z","iopub.execute_input":"2026-04-10T16:35:58.352153Z","iopub.status.idle":"2026-04-10T16:35:58.383379Z","shell.execute_reply.started":"2026-04-10T16:35:58.352122Z","shell.execute_reply":"2026-04-10T16:35:58.382409Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"scaler = StandardScaler()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:36:03.621921Z","iopub.execute_input":"2026-04-10T16:36:03.622934Z","iopub.status.idle":"2026-04-10T16:36:03.628062Z","shell.execute_reply.started":"2026-04-10T16:36:03.622893Z","shell.execute_reply":"2026-04-10T16:36:03.626971Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x = scaler.fit_transform(x)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:37:03.752665Z","iopub.execute_input":"2026-04-10T16:37:03.753039Z","iopub.status.idle":"2026-04-10T16:37:03.775390Z","shell.execute_reply.started":"2026-04-10T16:37:03.753009Z","shell.execute_reply":"2026-04-10T16:37:03.774567Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential()\nmodel.add(Dense(130,activation = \"relu\"))\nmodel.add(Dense(70,activation = \"relu\"))\nmodel.add(Dense(25,activation = \"relu\"))\nmodel.add(Dense(12,activation = \"relu\"))\nmodel.add(Dense(7,activation = \"softmax\"))\nmodel.compile(loss = \"sparse_categorical_crossentropy\",optimizer = \"adam\",metrics = [\"accuracy\"])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:40:09.044597Z","iopub.execute_input":"2026-04-10T16:40:09.044975Z","iopub.status.idle":"2026-04-10T16:40:09.063312Z","shell.execute_reply.started":"2026-04-10T16:40:09.044927Z","shell.execute_reply":"2026-04-10T16:40:09.061174Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"history = model.fit(x,y,epochs = 30,batch_size = 1000,validation_split = 0.2,verbose = 1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-10T16:40:10.129706Z","iopub.execute_input":"2026-04-10T16:40:10.130074Z","iopub.status.idle":"2026-04-10T16:40:18.173619Z","shell.execute_reply.started":"2026-04-10T16:40:10.130040Z","shell.execute_reply":"2026-04-10T16:40:18.172027Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}