{"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":81933,"databundleVersionId":9643020},{"sourceType":"datasetVersion","sourceId":15774137,"datasetId":10110100,"databundleVersionId":16719285}],"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},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\n\ndf = pd.read_csv('/kaggle/input/competitions/child-mind-institute-problematic-internet-use/train.csv')\ndf.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:24:52.684101Z","iopub.execute_input":"2026-04-16T17:24:52.684453Z","iopub.status.idle":"2026-04-16T17:24:52.781984Z","shell.execute_reply.started":"2026-04-16T17:24:52.684427Z","shell.execute_reply":"2026-04-16T17:24:52.780566Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = df[df['sii'].notna()]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:32:56.578262Z","iopub.execute_input":"2026-04-16T17:32:56.578660Z","iopub.status.idle":"2026-04-16T17:32:56.583987Z","shell.execute_reply.started":"2026-04-16T17:32:56.578628Z","shell.execute_reply":"2026-04-16T17:32:56.583335Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X = df.drop(['sii', 'id'], axis=1)\ny = df['sii'].astype(int)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:33:10.245691Z","iopub.execute_input":"2026-04-16T17:33:10.246026Z","iopub.status.idle":"2026-04-16T17:33:10.254484Z","shell.execute_reply.started":"2026-04-16T17:33:10.246004Z","shell.execute_reply":"2026-04-16T17:33:10.252883Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X = pd.get_dummies(X)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:33:23.366596Z","iopub.execute_input":"2026-04-16T17:33:23.367022Z","iopub.status.idle":"2026-04-16T17:33:23.384229Z","shell.execute_reply.started":"2026-04-16T17:33:23.366990Z","shell.execute_reply":"2026-04-16T17:33:23.382209Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\nX_train, X_test, y_train, y_test = train_test_split(\n    X, y, test_size=0.2, random_state=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:33:39.918682Z","iopub.execute_input":"2026-04-16T17:33:39.919007Z","iopub.status.idle":"2026-04-16T17:33:39.931180Z","shell.execute_reply.started":"2026-04-16T17:33:39.918985Z","shell.execute_reply":"2026-04-16T17:33:39.929861Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\n\nscaler = StandardScaler()\nX_train = scaler.fit_transform(X_train)\nX_test = scaler.transform(X_test)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:34:04.403253Z","iopub.execute_input":"2026-04-16T17:34:04.403567Z","iopub.status.idle":"2026-04-16T17:34:04.416062Z","shell.execute_reply.started":"2026-04-16T17:34:04.403544Z","shell.execute_reply":"2026-04-16T17:34:04.414287Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Input\n\nmodel = Sequential([\n    Input(shape=(X_train.shape[1],)),\n    Dense(64, activation='relu'),\n    Dense(32, activation='relu'),\n    Dense(4, activation='softmax')\n])\n\nmodel.compile(optimizer='adam',\n              loss='sparse_categorical_crossentropy',\n              metrics=['accuracy'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:34:19.535205Z","iopub.execute_input":"2026-04-16T17:34:19.535568Z","iopub.status.idle":"2026-04-16T17:34:19.567114Z","shell.execute_reply.started":"2026-04-16T17:34:19.535543Z","shell.execute_reply":"2026-04-16T17:34:19.566286Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"history = model.fit(X_train, y_train,\n                    epochs=5,\n                    batch_size=16,\n                    validation_split=0.2)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:35:30.025038Z","iopub.execute_input":"2026-04-16T17:35:30.025476Z","iopub.status.idle":"2026-04-16T17:35:32.358447Z","shell.execute_reply.started":"2026-04-16T17:35:30.025439Z","shell.execute_reply":"2026-04-16T17:35:32.357119Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nplt.plot(history.history['accuracy'])\nplt.plot(history.history['val_accuracy'])\nplt.title('Model Accuracy')\nplt.xlabel('Epoch')\nplt.ylabel('Accuracy')\nplt.legend(['Train', 'Validation'])\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:36:22.731406Z","iopub.execute_input":"2026-04-16T17:36:22.731795Z","iopub.status.idle":"2026-04-16T17:36:22.924565Z","shell.execute_reply.started":"2026-04-16T17:36:22.731767Z","shell.execute_reply":"2026-04-16T17:36:22.923322Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pred = model.predict(X_test[:10])\nprint(\"Predicted class:\", pred.argmax(axis=1))\nprint(\"Actual class:   \", y_test[:10].values)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-16T17:36:46.455994Z","iopub.execute_input":"2026-04-16T17:36:46.456381Z","iopub.status.idle":"2026-04-16T17:36:46.584797Z","shell.execute_reply.started":"2026-04-16T17:36:46.456357Z","shell.execute_reply":"2026-04-16T17:36:46.583072Z"}},"outputs":[],"execution_count":null}]}