{"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":30761,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Published on September 19, 2024. By Marília Prata, mpwolke","metadata":{}},{"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn import feature_extraction, linear_model, model_selection, preprocessing\nimport plotly.graph_objs as go\nimport plotly.offline as py\nimport plotly.express as px\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\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))\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-09-19T20:51:18.095694Z","iopub.execute_input":"2024-09-19T20:51:18.096961Z","iopub.status.idle":"2024-09-19T20:51:24.043155Z","shell.execute_reply.started":"2024-09-19T20:51:18.096896Z","shell.execute_reply":"2024-09-19T20:51:24.041794Z"},"_kg_hide-input":true,"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://familycaregiversonline.net/wp-content/uploads/PIU_FISM.png)Family Caregivers online.","metadata":{}},{"cell_type":"markdown","source":"### \"Problematic Internet Use (PIU)\n\n\"Problematic Internet Use (PIU) is a widespread phenomenon that is becoming increasingly prevalent in contemporary society and in older adults.\n\n\"There are many internet-based activities which, if over-used, can impede function and cause distress in people of all ages. We hear a lot about Internet Gaming Disorder in the media, which mainly affects younger adults, but there are online activities that older adults are more susceptible to including, among others:\"\n\nonline gambling\n\nsocial media\n\nonline shopping\n\nonline pornography\"\n\nhttps://familycaregiversonline.net/problematic-internet-use-piu-in-older-adults/","metadata":{}},{"cell_type":"markdown","source":"## Competition Citation\n\n@misc{child-mind-institute-problematic-internet-use,\n\n    author = {Adam Santorelli, Arianna Zuanazzi, Michael Leyden, Logan Lawler, Maggie Devkin, Yuki Kotani, Gregory Kiar},\n    \n    title = {Child Mind Institute — Problematic Internet Use},\n    \n    publisher = {Kaggle},\n    year = {2024},","metadata":{}},{"cell_type":"markdown","source":"![](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSvlEW1j7odvV3wAaNb1yQSIH_oBVTvXIrEwQ&s)TeePublic","metadata":{}},{"cell_type":"markdown","source":"#Problematic Internet use (PIU)\n\nProblematic Internet use (PIU), personality profiles and emotion dysregulation in a cohort of young adults: trajectories from risky behaviors to addiction\n\nAuthors: Mauro Pettorruso, Stephanie Valle, Elizabeth Cavic, Giovanni Martinotti,Massimo di Giannantonio, Jon E. Grant  - https://doi.org/10.1016/j.psychres.2020.113036\n\n\"11.2% of a large sample of non-treatment seeking young adults met criteria for problematic Internet use.\"\n\n\"Young adults with problematic Internet use exhibited lower novelty seeking, harm avoidance, and reward dependence.\"\n\n\"Problematic Internet use was associated with more pronounced motor impulsivity and problems with emotional regulation.\"\n\n\"Problematic Internet Use (PIU) encloses excessive online activities (like video gaming, social media use, web-streaming, pornography viewing, buying). Despite its psychological burden, risk factors related to PIU remain still unclear. In the present study the authors explored the role of personality traits and emotion dysregulation as potential vulnerability factors for PIU. In a sample of American young adults with different PIU risk levels (established through the Internet Addiction Diagnostic Questionnaire), we administered the **Tridimensional Personality Questionnaire (TPQ)**, the **Difficulties in Emotion Regulation Scale (DERS)**, the Barratt Impulsiveness Scale, the Hamilton Depression Rating Scale, the Hamilton Anxiety Rating Scale.\"\n\n\"PIU participants were more likely to report lower TPQ scores in novelty seeking, harm avoidance and reward dependence. Moreover, DERS total scores significantly differed across PIU-risk groups, along with a progressively higher occurrence of depression, anxiety and impulsivity. These results preliminarily support the hypothesis of PIU as a mainly behavior aimed at ‘escaping’ from negative affects. Besides confirming the role of some personality traits and emotional dysregulation, the authors proposed the concept of risk-trajectories to monitor and prevent the emergence of PIU. Gaining more insight into PIU vulnerability factors may allow us to establish targeted interventions to cope with emotion dysregulation and negative affects.\"\n\nhttps://www.sciencedirect.com/science/article/abs/pii/S0165178119320098#:~:text=Problematic%20Internet%20use%20(PIU)%20is,Beard%20and%20Wolf%2C%202001).","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv('../input/child-mind-institute-problematic-internet-use/train.csv')\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T20:57:09.528968Z","iopub.execute_input":"2024-09-19T20:57:09.529447Z","iopub.status.idle":"2024-09-19T20:57:09.655909Z","shell.execute_reply.started":"2024-09-19T20:57:09.529405Z","shell.execute_reply":"2024-09-19T20:57:09.654546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Describe showing Only the requested statistics (mean, minimum and maximum). Then, transpose the table.\n\ntrain.describe().loc[['mean','min','max']].T","metadata":{"execution":{"iopub.status.busy":"2024-09-19T22:30:19.898933Z","iopub.execute_input":"2024-09-19T22:30:19.899419Z","iopub.status.idle":"2024-09-19T22:30:20.080500Z","shell.execute_reply.started":"2024-09-19T22:30:19.899380Z","shell.execute_reply":"2024-09-19T22:30:20.079163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Gabriel Preda https://www.kaggle.com/code/gpreda/presidential-candidates-nigeria-2023-eda\n\ndef missing_data(train):\n    total = train.isnull().sum()\n    percent = (train.isnull().sum()/train.isnull().count()*100)\n    tt = pd.concat([total, percent], axis=1, keys=['Total', 'Percent'])\n    types = []\n    for col in train.columns:\n        dtype = str(train[col].dtype)\n        types.append(dtype)\n    tt['Types'] = types\n    return(np.transpose(tt))","metadata":{"execution":{"iopub.status.busy":"2024-09-19T23:24:02.314140Z","iopub.execute_input":"2024-09-19T23:24:02.314666Z","iopub.status.idle":"2024-09-19T23:24:02.323578Z","shell.execute_reply.started":"2024-09-19T23:24:02.314620Z","shell.execute_reply":"2024-09-19T23:24:02.322208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Missing values and percents","metadata":{}},{"cell_type":"code","source":"#By Gabriel Preda https://www.kaggle.com/code/gpreda/presidential-candidates-nigeria-2023-eda\n\nmissing_data(train)","metadata":{"execution":{"iopub.status.busy":"2024-09-19T23:24:14.936965Z","iopub.execute_input":"2024-09-19T23:24:14.937479Z","iopub.status.idle":"2024-09-19T23:24:14.988362Z","shell.execute_reply.started":"2024-09-19T23:24:14.937432Z","shell.execute_reply":"2024-09-19T23:24:14.987151Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Target: sii\n\n\"Note in particular **the field PCIAT-PCIAT_Total**. The target sii for this competition is derived from this field as described in the data dictionary: 0 for None, 1 for Mild, 2 for Moderate, and 3 for Severe. Additionally, each participant has been assigned a unique identifier id.\"","metadata":{}},{"cell_type":"code","source":"sub = pd.read_csv('../input/child-mind-institute-problematic-internet-use/sample_submission.csv')\nsub.head(3)","metadata":{"execution":{"iopub.status.busy":"2024-09-19T21:14:54.575664Z","iopub.execute_input":"2024-09-19T21:14:54.576178Z","iopub.status.idle":"2024-09-19T21:14:54.592500Z","shell.execute_reply.started":"2024-09-19T21:14:54.576134Z","shell.execute_reply":"2024-09-19T21:14:54.590929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Read at least one parquet file","metadata":{}},{"cell_type":"code","source":"sii = pd.read_parquet('../input/child-mind-institute-problematic-internet-use/series_test.parquet/id=00115b9f/part-0.parquet')\nsii.tail()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T21:12:54.334024Z","iopub.execute_input":"2024-09-19T21:12:54.334476Z","iopub.status.idle":"2024-09-19T21:12:54.369176Z","shell.execute_reply.started":"2024-09-19T21:12:54.334437Z","shell.execute_reply":"2024-09-19T21:12:54.367566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### non-wear_flag  (one dash and one underscore : ) \n\nnon-wear_flag - A flag (0: watch is being worn, 1: the watch is not worn) to help determine periods when the watch has been removed, based on the GGIR definition, which uses the standard deviation and range of the accelerometer data.","metadata":{}},{"cell_type":"code","source":"#Tricky non-wear_flag (one dash and one underscore)\n\nsii['non-wear_flag'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T22:10:25.159147Z","iopub.execute_input":"2024-09-19T22:10:25.159610Z","iopub.status.idle":"2024-09-19T22:10:25.170765Z","shell.execute_reply.started":"2024-09-19T22:10:25.159571Z","shell.execute_reply":"2024-09-19T22:10:25.169526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Fiat LUX! \n\n#### We can see the Light!\n\nlight - Measure of ambient light in lux. See Lux measurements for details.\n\n\"Lux Measurements - Nov 8, 2018\n\n\"**Lux, or ambient light**, is measured by **ActiGraph’s ActiSleep, ActiSleep+, ActiTrainer, GT3X+**, and our new wireless wGT3X+ and wActiSleep+ devices. Ambient light may affect subject sleeping habits and thus is a useful tool in analyzing circadian rhythms and sleeping patterns. Lux data is stored once per epoch. For GT3X+/ActiSleep+/wGT3X+/wActiSleep+ devices, Lux data is stored once per second. When converting a GT3X+ raw file into an accumulated *.agd format with epoch lengths greater than one second, the lux values for that epoch are averaged.\" \n\nhttps://actigraphcorp.my.site.com/support/s/article/Lux-Measurements","metadata":{}},{"cell_type":"code","source":"sii['light'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T22:10:59.713983Z","iopub.execute_input":"2024-09-19T22:10:59.714466Z","iopub.status.idle":"2024-09-19T22:10:59.729195Z","shell.execute_reply.started":"2024-09-19T22:10:59.714426Z","shell.execute_reply":"2024-09-19T22:10:59.727913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Z-Angle presented by Van Hees (2018)\n\n\"From the use of accelerometers, it's possible to estimate different variables related to sleep, such as duration and efficiency. For this, The authors have used the Heuristic algorithm, looking at Distribution of Change in z-Angle presented by Van Hees (2018). This algorithm identifies the longest period of inactivity within 24 hours, with the least number of interruptions, classifying as a sleep period.\"\n\nhttps://eleva.ufsc.br/en/acelerometros/","metadata":{}},{"cell_type":"code","source":"#By Sarthak Jain https://www.kaggle.com/code/sarthak333/predict-sleep\n\nfig, ax = plt.subplots(figsize=(20, 3))\nsns.lineplot(data=sii, x=\"step\", y=\"anglez\",hue=\"non-wear_flag\", linewidth = 0.5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T22:08:03.995265Z","iopub.execute_input":"2024-09-19T22:08:03.995991Z","iopub.status.idle":"2024-09-19T22:08:04.923950Z","shell.execute_reply.started":"2024-09-19T22:08:03.995916Z","shell.execute_reply":"2024-09-19T22:08:04.922520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Euclidean Norm Minus One (Enmo)\n\nIntensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches\n\nCitation: Bakrania K, Yates T, Rowlands AV, Esliger DW, Bunnewell S, Sanders J, et al. (2016) Intensity Thresholds on Raw Acceleration Data: Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) Approaches. PLoS ONE 11(10): e0164045. https://doi.org/10.1371/journal.pone.0164045\n\n\" To develop and internally-validate Euclidean Norm Minus One (ENMO) and Mean Amplitude Deviation (MAD) thresholds for separating sedentary behaviours from common light-intensity physical activities using raw acceleration data collected from both hip- and wrist-worn tri-axial accelerometers; and to compare and evaluate the performances between the ENMO and MAD metrics.\"","metadata":{}},{"cell_type":"code","source":"#By Sarthak Jain https://www.kaggle.com/code/sarthak333/predict-sleep\n\nfig, ax = plt.subplots(figsize=(20, 3))\nsns.lineplot(data=sii, x=\"step\", y=\"enmo\", color='r', linewidth = 0.5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T22:14:52.803313Z","iopub.execute_input":"2024-09-19T22:14:52.803787Z","iopub.status.idle":"2024-09-19T22:14:53.390054Z","shell.execute_reply.started":"2024-09-19T22:14:52.803745Z","shell.execute_reply":"2024-09-19T22:14:53.388452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Dictionary data","metadata":{}},{"cell_type":"code","source":"dic = pd.read_csv('../input/child-mind-institute-problematic-internet-use/data_dictionary.csv')\ndic.tail()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T20:58:15.998535Z","iopub.execute_input":"2024-09-19T20:58:15.999076Z","iopub.status.idle":"2024-09-19T20:58:16.020374Z","shell.execute_reply.started":"2024-09-19T20:58:15.999031Z","shell.execute_reply":"2024-09-19T20:58:16.019113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### HBN Instruments\n\nThe Healthy Brain Network (HBN) Instruments:\n\nDemographics - Information about age and sex of participants.\n\nInternet Use - Number of hours of using computer/internet per day.\n\nChildren's Global Assessment Scale - Numeric scale used by mental health clinicians to rate the general functioning of youths under the age of 18.\n\nPhysical Measures - Collection of blood pressure, heart rate, height, weight and waist, and hip measurements.\n\nFitnessGram Vitals and Treadmill - Measurements of cardiovascular fitness assessed using the NHANES treadmill protocol.\n\nFitnessGram Child - Health related physical fitness assessment measuring five different parameters including aerobic capacity, muscular strength, muscular endurance, flexibility, and body composition.\n\nBio-electric Impedance Analysis - Measure of key body composition elements, including BMI, fat, muscle, and water content.\n\nPhysical Activity Questionnaire - Information about children's participation in vigorous activities over the last 7 days.\n\nSleep Disturbance Scale - Scale to categorize sleep disorders in children.\n\nActigraphy - Objective measure of ecological physical activity through a research-grade biotracker.\n\nParent-Child Internet Addiction Test - 20-item scale that measures characteristics and behaviors associated with compulsive use of the Internet including compulsivity, escapism, and dependency.\n\nhttps://www.kaggle.com/competitions/child-mind-institute-problematic-internet-use/data","metadata":{}},{"cell_type":"code","source":"ax = dic['Instrument'].value_counts().plot.barh(figsize=(14, 6), color='orange')\nax.set_title('HBN Instruments Distribution',color='green', size=18)\nax.set_ylabel('HBN Instruments', size=14)\nax.set_xlabel('Count', size=14);","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2024-09-19T23:25:59.447872Z","iopub.execute_input":"2024-09-19T23:25:59.448437Z","iopub.status.idle":"2024-09-19T23:25:59.844404Z","shell.execute_reply.started":"2024-09-19T23:25:59.448386Z","shell.execute_reply":"2024-09-19T23:25:59.843000Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Basically ALL Seasons, users are on the Internet","metadata":{}},{"cell_type":"code","source":"##Code by Taha07  https://www.kaggle.com/taha07/data-scientists-jobs-analysis-visualization/notebook\n\nfrom wordcloud import WordCloud\nfrom wordcloud import STOPWORDS\nstopwords = set(STOPWORDS)\nwordcloud = WordCloud(background_color = 'white',\n                      color_func=lambda *args, **kwargs: \"black\",\n                      height =2000,\n                      width = 2000\n                     ).generate(str(train[\"Basic_Demos-Enroll_Season\"]))\nplt.rcParams['figure.figsize'] = (8,8)\nplt.axis(\"off\")\nplt.imshow(wordcloud)\nplt.title(\"Basic Enroll Seasons\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-09-19T23:19:31.470304Z","iopub.execute_input":"2024-09-19T23:19:31.470988Z","iopub.status.idle":"2024-09-19T23:19:34.026123Z","shell.execute_reply.started":"2024-09-19T23:19:31.470943Z","shell.execute_reply":"2024-09-19T23:19:34.024796Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### No Internet. No code. No problem.\n","metadata":{}},{"cell_type":"markdown","source":"#Acknowledgements:\n\nGabriel Preda https://www.kaggle.com/code/gpreda/presidential-candidates-nigeria-2023-eda\n\nSarthak Jain https://www.kaggle.com/code/sarthak333/predict-sleep","metadata":{}}]}