{"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":81933,"databundleVersionId":9643020,"sourceType":"competition"}],"dockerImageVersionId":30786,"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","execution":{"iopub.status.busy":"2024-10-29T03:57:40.706113Z","iopub.execute_input":"2024-10-29T03:57:40.706573Z","iopub.status.idle":"2024-10-29T03:57:45.390200Z","shell.execute_reply.started":"2024-10-29T03:57:40.706527Z","shell.execute_reply":"2024-10-29T03:57:45.388158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Reading the training data\ntrain_df = pd.read_csv('/kaggle/input/child-mind-institute-problematic-internet-use/train.csv')\n\n# Reading the testing data\ntest_df = pd.read_csv('/kaggle/input/child-mind-institute-problematic-internet-use/test.csv')\n\n# Displaying the first few rows of the datasets\nprint(\"Training Data:\")\nprint(train_df.head())\n\nprint(\"\\nTesting Data:\")\nprint(test_df.head())","metadata":{"execution":{"iopub.status.busy":"2024-10-29T03:58:59.206936Z","iopub.execute_input":"2024-10-29T03:58:59.207682Z","iopub.status.idle":"2024-10-29T03:58:59.347393Z","shell.execute_reply.started":"2024-10-29T03:58:59.207625Z","shell.execute_reply":"2024-10-29T03:58:59.346197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#separating id column to add later\nlatertrain_df = train_df[['id']]\nlatertrain_df = train_df[['id']]","metadata":{"execution":{"iopub.status.busy":"2024-10-29T04:00:38.226632Z","iopub.execute_input":"2024-10-29T04:00:38.227937Z","iopub.status.idle":"2024-10-29T04:00:38.236075Z","shell.execute_reply.started":"2024-10-29T04:00:38.227828Z","shell.execute_reply":"2024-10-29T04:00:38.234356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Keep only relevant columns\ntrain_df = train_df[['Physical-BMI', 'sii']]\ntest_df = test_df[['Physical-BMI']]","metadata":{"execution":{"iopub.status.busy":"2024-10-29T04:01:43.785640Z","iopub.execute_input":"2024-10-29T04:01:43.787001Z","iopub.status.idle":"2024-10-29T04:01:43.794655Z","shell.execute_reply.started":"2024-10-29T04:01:43.786939Z","shell.execute_reply":"2024-10-29T04:01:43.793152Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nfrom sklearn.ensemble import RandomForestClassifier\n\ntrain_df = train_df.dropna()\ntest_df = test_df.dropna()\n\n\n\n# Feature engineering (apply techniques from the notebook)\n\n# Split data\nX_train = train_df['Physical-BMI']\ny_train = train_df['sii']\n\n# Train model\nmodel = RandomForestClassifier()\nmodel.fit(X_train.values.reshape(-1, 1), y_train)\n\n# Make predictions\ny_pred = model.predict(test_df['Physical-BMI'].values.reshape(-1, 1))\nsubmission_df = pd.DataFrame({ 'sii': y_pred})","metadata":{"execution":{"iopub.status.busy":"2024-10-29T04:06:06.985883Z","iopub.execute_input":"2024-10-29T04:06:06.986352Z","iopub.status.idle":"2024-10-29T04:06:09.026956Z","shell.execute_reply.started":"2024-10-29T04:06:06.986306Z","shell.execute_reply":"2024-10-29T04:06:09.024870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(submission_df)","metadata":{"execution":{"iopub.status.busy":"2024-10-29T04:11:39.731469Z","iopub.execute_input":"2024-10-29T04:11:39.732238Z","iopub.status.idle":"2024-10-29T04:11:39.744193Z","shell.execute_reply.started":"2024-10-29T04:11:39.732183Z","shell.execute_reply":"2024-10-29T04:11:39.742185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Assuming 'id' column exists in latertrain_df\nsubmission_df['id'] = latertrain_df['id']\n\n# Reorder columns\nsubmission_df = submission_df[['id', 'sii']]\n\n# Remove the first row\nsubmission_df = submission_df.iloc[0:]\n\n# Now 'submission_df' will have 'id' at the 0th index and 'sii' at the 1st\nprint(submission_df)","metadata":{"execution":{"iopub.status.busy":"2024-10-29T04:16:51.251109Z","iopub.execute_input":"2024-10-29T04:16:51.251566Z","iopub.status.idle":"2024-10-29T04:16:51.262713Z","shell.execute_reply.started":"2024-10-29T04:16:51.251512Z","shell.execute_reply":"2024-10-29T04:16:51.261420Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_df.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-10-29T04:17:12.590460Z","iopub.execute_input":"2024-10-29T04:17:12.591032Z","iopub.status.idle":"2024-10-29T04:17:12.604082Z","shell.execute_reply.started":"2024-10-29T04:17:12.590970Z","shell.execute_reply":"2024-10-29T04:17:12.602745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}