{"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":30775,"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\n# data processing, CSV file I/O (e.g. pd.read_csv)\n\n\n\n\n\n\n\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))\n0\\\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-09-30T08:50:18.49037Z","iopub.execute_input":"2024-09-30T08:50:18.490762Z","iopub.status.idle":"2024-09-30T08:50:19.448552Z","shell.execute_reply.started":"2024-09-30T08:50:18.490724Z","shell.execute_reply":"2024-09-30T08:50:19.447404Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2024-09-30T08:47:30.748148Z","iopub.execute_input":"2024-09-30T08:47:30.748601Z","iopub.status.idle":"2024-09-30T08:47:31.534881Z","shell.execute_reply.started":"2024-09-30T08:47:30.748555Z","shell.execute_reply":"2024-09-30T08:47:31.533183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(datatrain.head())\ndataDic = pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/data_dictionary.csv\")","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:33:46.880615Z","iopub.execute_input":"2024-09-30T05:33:46.881069Z","iopub.status.idle":"2024-09-30T05:33:46.907463Z","shell.execute_reply.started":"2024-09-30T05:33:46.881026Z","shell.execute_reply":"2024-09-30T05:33:46.906104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(dataDic.head())","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:33:52.552726Z","iopub.execute_input":"2024-09-30T05:33:52.553238Z","iopub.status.idle":"2024-09-30T05:33:52.563268Z","shell.execute_reply.started":"2024-09-30T05:33:52.55319Z","shell.execute_reply":"2024-09-30T05:33:52.561912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_path = '/kaggle/input/child-mind-institute-problematic-internet-use/series_test.parquet/id=00115b9f/part-0.parquet'\ndf = pd.read_parquet(file_path)\n\n# Display the first few rows of the dataframe\nprint(df.head())","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:33:57.631475Z","iopub.execute_input":"2024-09-30T05:33:57.632098Z","iopub.status.idle":"2024-09-30T05:33:57.83666Z","shell.execute_reply.started":"2024-09-30T05:33:57.632037Z","shell.execute_reply":"2024-09-30T05:33:57.835315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define the file path\nfile_path = '/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet/id=00115b9f/part-0.parquet'\n\n# Read the Parquet file\ndf_train = pd.read_parquet(file_path)\n\n# Display the first few rows of the dataframe\nprint(df_train.head())","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:34:02.66088Z","iopub.execute_input":"2024-09-30T05:34:02.661378Z","iopub.status.idle":"2024-09-30T05:34:02.70216Z","shell.execute_reply.started":"2024-09-30T05:34:02.661331Z","shell.execute_reply":"2024-09-30T05:34:02.700668Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datatest.describe()","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:34:08.831135Z","iopub.execute_input":"2024-09-30T05:34:08.831654Z","iopub.status.idle":"2024-09-30T05:34:08.964595Z","shell.execute_reply.started":"2024-09-30T05:34:08.831588Z","shell.execute_reply":"2024-09-30T05:34:08.963319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Visulaize of whole data","metadata":{}},{"cell_type":"code","source":"basic = datatest[\"Basic_Demos-Enroll_Season\"]\nplt.hist(basic,  color='skyblue', edgecolor='black')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:19:49.138482Z","iopub.execute_input":"2024-09-30T05:19:49.138968Z","iopub.status.idle":"2024-09-30T05:19:49.389022Z","shell.execute_reply.started":"2024-09-30T05:19:49.138919Z","shell.execute_reply":"2024-09-30T05:19:49.387688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"basic = datatrain[\"Basic_Demos-Enroll_Season\"]\nplt.hist(basic,  color='skyblue', edgecolor='black')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:20:43.579408Z","iopub.execute_input":"2024-09-30T05:20:43.579911Z","iopub.status.idle":"2024-09-30T05:20:43.820541Z","shell.execute_reply.started":"2024-09-30T05:20:43.579861Z","shell.execute_reply":"2024-09-30T05:20:43.819122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"basicAge = datatest[\"Basic_Demos-Age\"]\nplt.hist(basicAge, color='skyblue', edgecolor='black' )","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:24:51.101764Z","iopub.execute_input":"2024-09-30T05:24:51.102263Z","iopub.status.idle":"2024-09-30T05:24:51.407434Z","shell.execute_reply.started":"2024-09-30T05:24:51.102216Z","shell.execute_reply":"2024-09-30T05:24:51.406126Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import StandardScaler\nfrom torch.utils.data import Dataset, DataLoader\nfrom sklearn.metrics import accuracy_score, f1_score\nimport os\n","metadata":{"execution":{"iopub.status.busy":"2024-09-30T08:50:51.410441Z","iopub.execute_input":"2024-09-30T08:50:51.411429Z","iopub.status.idle":"2024-09-30T08:50:52.191171Z","shell.execute_reply.started":"2024-09-30T08:50:51.41138Z","shell.execute_reply":"2024-09-30T08:50:52.189536Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load tabular data\ntrain_df = pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/train.csv\")\ntest_df = pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/test.csv\")\nsample_submission = pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/sample_submission.csv\")\n\n# Load accelerometer data (series data)\ndef load_parquet_data(file_path):\n    data = pd.read_parquet(file_path)\n    return data\n\n# Example for loading a specific id parquet file\ntrain_series_path = \"/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet\"\ntrain_series_data = load_parquet_data(train_series_path)\n","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:33:12.151498Z","iopub.execute_input":"2024-09-30T05:33:12.152338Z","iopub.status.idle":"2024-09-30T05:33:12.193532Z","shell.execute_reply.started":"2024-09-30T05:33:12.152279Z","shell.execute_reply":"2024-09-30T05:33:12.191419Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Impute or fill missing values\ntrain_df.fillna(train_df.median(), inplace=True)\ntest_df.fillna(test_df.median(), inplace=True)\n\n# Separate features and target\nX = train_df.drop(['sii', 'id'], axis=1)  # Exclude the target and id\ny = train_df['sii']  # Target: Severity Impairment Index\n\n# Train-test split\nX_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# Normalize the data\nscaler = StandardScaler()\nX_train = scaler.fit_transform(X_train)\nX_val = scaler.transform(X_val)\nX_test = scaler.transform(test_df.drop('id', axis=1))\n","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:32:57.254602Z","iopub.execute_input":"2024-09-30T05:32:57.256176Z","iopub.status.idle":"2024-09-30T05:32:57.296646Z","shell.execute_reply.started":"2024-09-30T05:32:57.256098Z","shell.execute_reply":"2024-09-30T05:32:57.295032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class InternetUseDataset(Dataset):\n    def __init__(self, X, y=None):\n        self.X = X\n        self.y = y\n\n    def __len__(self):\n        return len(self.X)\n\n    def __getitem__(self, idx):\n        if self.y is not None:\n            return torch.tensor(self.X[idx], dtype=torch.float32), torch.tensor(self.y[idx], dtype=torch.long)\n        else:\n            return torch.tensor(self.X[idx], dtype=torch.float32)\n\n# Create datasets\ntrain_dataset = InternetUseDataset(X_train, y_train.values)\nval_dataset = InternetUseDataset(X_val, y_val.values)\ntest_dataset = InternetUseDataset(X_test)\n","metadata":{"execution":{"iopub.status.busy":"2024-09-30T05:31:24.169427Z","iopub.execute_input":"2024-09-30T05:31:24.169999Z","iopub.status.idle":"2024-09-30T05:31:24.620821Z","shell.execute_reply.started":"2024-09-30T05:31:24.169934Z","shell.execute_reply":"2024-09-30T05:31:24.619178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}