{"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":"markdown","source":"# 1. Preprocessing","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-10-28T13:58:55.324188Z","iopub.execute_input":"2024-10-28T13:58:55.324599Z","iopub.status.idle":"2024-10-28T13:58:58.942837Z","shell.execute_reply.started":"2024-10-28T13:58:55.324557Z","shell.execute_reply":"2024-10-28T13:58:58.941476Z"}}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport math\nimport os\nfrom glob import glob","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.235435Z","iopub.execute_input":"2024-11-06T07:27:36.236626Z","iopub.status.idle":"2024-11-06T07:27:36.243186Z","shell.execute_reply.started":"2024-11-06T07:27:36.236576Z","shell.execute_reply":"2024-11-06T07:27:36.241585Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"dictionary = pd.read_csv('/kaggle/input/child-mind-institute-problematic-internet-use/data_dictionary.csv')\ndictionary","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.246032Z","iopub.execute_input":"2024-11-06T07:27:36.246545Z","iopub.status.idle":"2024-11-06T07:27:36.270989Z","shell.execute_reply.started":"2024-11-06T07:27:36.246465Z","shell.execute_reply":"2024-11-06T07:27:36.269683Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/child-mind-institute-problematic-internet-use/train.csv')\ntrain.head(5)\nbase_path = '/kaggle/input/child-mind-institute-problematic-internet-use/series_train.parquet'\n# Get all folder names in the base directory, which represent the IDs\nid_list = [name for name in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, name))]\n\n# Remove 'id=' prefix from each ID in id_list\nid_list = [name.replace(\"id=\", \"\") for name in id_list]\n\n# Filter the DataFrame to include only rows with IDs in `id_list`\ntrain = train[train['id'].isin(id_list)]\n\n# Display the filtered DataFrame\ntrain","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.273433Z","iopub.execute_input":"2024-11-06T07:27:36.273931Z","iopub.status.idle":"2024-11-06T07:27:36.367180Z","shell.execute_reply.started":"2024-11-06T07:27:36.273879Z","shell.execute_reply":"2024-11-06T07:27:36.365817Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Drop data if there is no sii\nThere is no reference","metadata":{}},{"cell_type":"code","source":"column_to_check = 'sii'\n\ntrain_cleaned = train.dropna(subset=[column_to_check])\n\ntrain_cleaned.head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.369391Z","iopub.execute_input":"2024-11-06T07:27:36.369781Z","iopub.status.idle":"2024-11-06T07:27:36.408750Z","shell.execute_reply.started":"2024-11-06T07:27:36.369741Z","shell.execute_reply":"2024-11-06T07:27:36.407392Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"---","metadata":{}},{"cell_type":"markdown","source":"# Physical Measures","metadata":{}},{"cell_type":"markdown","source":"### Drop the data without Physical-BMI\nJust assume that they are dead","metadata":{}},{"cell_type":"code","source":"column_to_check = 'Physical-BMI'\n\ntrain_cleaned = train.dropna(subset=[column_to_check])\n\ntrain_cleaned.head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.411019Z","iopub.execute_input":"2024-11-06T07:27:36.411385Z","iopub.status.idle":"2024-11-06T07:27:36.453282Z","shell.execute_reply.started":"2024-11-06T07:27:36.411348Z","shell.execute_reply":"2024-11-06T07:27:36.451898Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Drop data if Physical-Diastolic_BP is >90 and <50\n\nnormal: 53-80 <br>\nif the blood pressure is >90 or <50, you should go to the hospital first","metadata":{}},{"cell_type":"code","source":"column_to_check = 'Physical-Diastolic_BP'\n\ntrain_cleaned = train_cleaned[(train_cleaned[column_to_check] >= 50) & (train_cleaned[column_to_check] <= 90)]\n\ntrain_cleaned[column_to_check].head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.454681Z","iopub.execute_input":"2024-11-06T07:27:36.455882Z","iopub.status.idle":"2024-11-06T07:27:36.468024Z","shell.execute_reply.started":"2024-11-06T07:27:36.455835Z","shell.execute_reply":"2024-11-06T07:27:36.466700Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Drop data if heartrate is <55 or >125\n\nschool age(6-12): 70-100 <br>\nadolescents(13-18): 60-100 <br>\nadults(18up): 60-100 <br>\n\nif it is not in this range, you should go to the hospital","metadata":{}},{"cell_type":"code","source":"column_to_check = 'Physical-HeartRate'\n\ntrain_cleaned = train_cleaned[(train_cleaned[column_to_check] >= 55) & (train_cleaned[column_to_check] <= 125)]\n\ntrain_cleaned[column_to_check].head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.469795Z","iopub.execute_input":"2024-11-06T07:27:36.470263Z","iopub.status.idle":"2024-11-06T07:27:36.483188Z","shell.execute_reply.started":"2024-11-06T07:27:36.470213Z","shell.execute_reply":"2024-11-06T07:27:36.481843Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### Drop data if Physical-Systolic_BP is <90 or >135\n\nnormal: 95-130 <br>\nif the blood pressure is <90 or >135, you should go to the hospital first","metadata":{}},{"cell_type":"code","source":"column_to_check = 'Physical-Systolic_BP'\n\ntrain_cleaned = train_cleaned[(train_cleaned[column_to_check] >= 90) & (train_cleaned[column_to_check] <= 135)]\n\ntrain_cleaned[column_to_check].head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.484704Z","iopub.execute_input":"2024-11-06T07:27:36.485503Z","iopub.status.idle":"2024-11-06T07:27:36.498080Z","shell.execute_reply.started":"2024-11-06T07:27:36.485441Z","shell.execute_reply":"2024-11-06T07:27:36.496965Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"| Age Group              | Systolic       | Diastolic      |\n|------------------------|----------------|----------------|\n| Newborns up to 1 month | 60–90 mm Hg    | 20–60 mm Hg    |\n| Infants                | 87–105 mm Hg   | 53–66 mm Hg    |\n| Toddlers               | 95–105 mm Hg   | 53–66 mm Hg    |\n| Preschoolers           | 95–110 mm Hg   | 56–70 mm Hg    |\n| School-aged children   | 97–112 mm Hg   | 57–71 mm Hg    |\n| Adolescents            | 112–128 mm Hg  | 66–80 mm Hg    |\n\n\n<br>\nsrc: https://www.baptisthealth.com/blog/heart-care/healthy-blood-pressure-by-age-and-gender-chart","metadata":{}},{"cell_type":"markdown","source":"### Drop data if CGAS score is <0 or >100\n\n-> this is by definition, so if CGAS is out of range, it should delete it.","metadata":{}},{"cell_type":"code","source":"column_to_check = 'CGAS-CGAS_Score'\n\ntrain_cleaned = train_cleaned[(train_cleaned[column_to_check] >= 0) & (train_cleaned[column_to_check] <= 100)]\n\ntrain_cleaned[column_to_check].head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.499352Z","iopub.execute_input":"2024-11-06T07:27:36.499721Z","iopub.status.idle":"2024-11-06T07:27:36.514056Z","shell.execute_reply.started":"2024-11-06T07:27:36.499685Z","shell.execute_reply":"2024-11-06T07:27:36.512367Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"---","metadata":{}},{"cell_type":"markdown","source":"# FGC","metadata":{}},{"cell_type":"markdown","source":"### FGC_GSND is sparse\n### FGC_GSD is sparse","metadata":{}},{"cell_type":"markdown","source":"### push up seems OK","metadata":{}},{"cell_type":"markdown","source":"---","metadata":{}},{"cell_type":"markdown","source":"# BIA","metadata":{}},{"cell_type":"markdown","source":"### Drop BIA-BIA_BMC if score is <-1\n\nnormal: -1 or higher<br>\nosteoporosis: -2.5 or lower<br>","metadata":{}},{"cell_type":"code","source":"column_to_check = 'BIA-BIA_BMC'\n\ntrain_cleaned = train_cleaned[train_cleaned[column_to_check]>=-1]\n\ntrain_cleaned[column_to_check].head(5)","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.518475Z","iopub.execute_input":"2024-11-06T07:27:36.519528Z","iopub.status.idle":"2024-11-06T07:27:36.531364Z","shell.execute_reply.started":"2024-11-06T07:27:36.519444Z","shell.execute_reply":"2024-11-06T07:27:36.530102Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### BIA-BIA_BMR is calculated according to a equation\n\nBMR: Basal Metabolic Rate\n\nIt is calculated according to weight, height and age\n\nFormula: <br>\nMen: BMR = 5 + (10 x wt in kg) + (6.25 x ht in cm) - (5 x age in years) <br>\nWomen: BMR = 655 + (9.6 x wt in kg) + (1.8 x ht in cm) - (4.7 x age in years)  <br>","metadata":{}},{"cell_type":"markdown","source":"### BIA-BIA_DEE is calculated according to a equation\n\nDEE: Daily Energy Expenditure\n\nequation: BMR x Activity Factor\n\nSedentary = BMR x 1.2 (little or no exercise, desk job) <br> \nLightly active = BMR x 1.375 (light exercise/ sports 1-3 days/week)<br>\nModerately active = BMR x 1.55 (moderate exercise/ sports 6-7 days/week)<br>\nVery active = BMR x 1.725 (hard exercise every day, or exercising 2 xs/day)<br>\nExtra active = BMR x 1.9 (hard exercise 2 or more times per day, or training for marathon, or triathlon, etc. <br> ","metadata":{}},{"cell_type":"markdown","source":"### BIA-BIA_FMI some are less than 0\nnormal range: Male: 18%-24% Female: 25%-31%","metadata":{}},{"cell_type":"code","source":"column_to_check = 'BIA-BIA_FMI'\n\ntrain_cleaned = train_cleaned[train_cleaned[column_to_check]>=0]\n","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.532942Z","iopub.execute_input":"2024-11-06T07:27:36.533425Z","iopub.status.idle":"2024-11-06T07:27:36.542666Z","shell.execute_reply.started":"2024-11-06T07:27:36.533356Z","shell.execute_reply":"2024-11-06T07:27:36.541478Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"### BIA-BIA_Fat some are less than 0\n\nnormal range: Male: 25-30 Female: 30-35","metadata":{}},{"cell_type":"code","source":"column_to_check = 'BIA-BIA_Fat'\n\ntrain_cleaned = train_cleaned[(train_cleaned[column_to_check] >= 15) & (train_cleaned[column_to_check] <= 45)]","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.544070Z","iopub.execute_input":"2024-11-06T07:27:36.544817Z","iopub.status.idle":"2024-11-06T07:27:36.555442Z","shell.execute_reply.started":"2024-11-06T07:27:36.544772Z","shell.execute_reply":"2024-11-06T07:27:36.554037Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"---","metadata":{}},{"cell_type":"markdown","source":"# PCIAT combination test","metadata":{}},{"cell_type":"markdown","source":"### Here is some experience (temporarily)\n","metadata":{}},{"cell_type":"code","source":"train_cleaned.to_csv('train_cleaned.csv')","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.557413Z","iopub.execute_input":"2024-11-06T07:27:36.557881Z","iopub.status.idle":"2024-11-06T07:27:36.583967Z","shell.execute_reply.started":"2024-11-06T07:27:36.557821Z","shell.execute_reply":"2024-11-06T07:27:36.582787Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test = train_cleaned","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.585320Z","iopub.execute_input":"2024-11-06T07:27:36.585722Z","iopub.status.idle":"2024-11-06T07:27:36.591542Z","shell.execute_reply.started":"2024-11-06T07:27:36.585680Z","shell.execute_reply":"2024-11-06T07:27:36.589999Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test['PCIAT-PCIAT_Score'] = test['PCIAT-PCIAT_01']+test['PCIAT-PCIAT_02']+test['PCIAT-PCIAT_03']+test['PCIAT-PCIAT_05']\ntest['PCIAT-PCIAT_Score_left'] = test['PCIAT-PCIAT_Total'] - test['PCIAT-PCIAT_Score']\ntest['PCIAT-PCIAT_Score_square'] = round(np.sqrt(np.sqrt((test['PCIAT-PCIAT_01']+1)*(test['PCIAT-PCIAT_02']+1)*(test['PCIAT-PCIAT_03']+1)*(test['PCIAT-PCIAT_05']+1))))-1","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.593629Z","iopub.execute_input":"2024-11-06T07:27:36.594184Z","iopub.status.idle":"2024-11-06T07:27:36.608209Z","shell.execute_reply.started":"2024-11-06T07:27:36.594129Z","shell.execute_reply":"2024-11-06T07:27:36.606823Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Define the range and columns\ncolumns = [f\"PCIAT-PCIAT_{j:02d}\" for j in range(1, 21)]\n\n# Calculate the product across these columns\ntest['sii_product'] = (test[columns]+1).prod(axis=1)\n\n# Apply the n-th root (replace 'n' with the root degree you need)\ntest['sii_square'] = round((test['sii_product']) ** (1 / 20))-1","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.610211Z","iopub.execute_input":"2024-11-06T07:27:36.610778Z","iopub.status.idle":"2024-11-06T07:27:36.625153Z","shell.execute_reply.started":"2024-11-06T07:27:36.610720Z","shell.execute_reply":"2024-11-06T07:27:36.623813Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test['PCIAT-PCIAT_Score_square']","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.626804Z","iopub.execute_input":"2024-11-06T07:27:36.627303Z","iopub.status.idle":"2024-11-06T07:27:36.642842Z","shell.execute_reply.started":"2024-11-06T07:27:36.627253Z","shell.execute_reply":"2024-11-06T07:27:36.641567Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"jittered_sii = [s + np.random.uniform(-0.1, 0.1) for s in test['sii']]\n\nplt.figure(figsize=(10, 6))\nplt.scatter(jittered_sii, test['PCIAT-PCIAT_Score'], color='blue', alpha=0.6, edgecolors='w', s=100)\n\n# Set titles and labels\nplt.title('Score Distribution across SII Categories with Jitter')\nplt.xlabel('SII')\nplt.ylabel('Score')\nplt.xticks([0, 1, 2, 3], ['None', 'Mild', 'Moderate', 'Severe'])\nplt.show()\n\nplt.figure(figsize=(10, 6))\nplt.scatter(jittered_sii, test['PCIAT-PCIAT_Score_square'], color='blue', alpha=0.6, edgecolors='w', s=100)\n\n# Set titles and labels\nplt.title('Score Distribution across SII Categories with Jitter')\nplt.xlabel('SII')\nplt.ylabel('Score')\nplt.xticks([0, 1, 2, 3], ['None', 'Mild', 'Moderate', 'Severe'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:36.644756Z","iopub.execute_input":"2024-11-06T07:27:36.645235Z","iopub.status.idle":"2024-11-06T07:27:37.174466Z","shell.execute_reply.started":"2024-11-06T07:27:36.645184Z","shell.execute_reply":"2024-11-06T07:27:37.173233Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#question for all\nimport matplotlib.pyplot as plt\n\n# Define the labels for SII categories and PCIAT-PCIAT_Score_square values\nsii_labels = ['None', 'Mild', 'Moderate', 'Severe']\nscore_labels = [0, 1, 2, 3, 4, 5]\n\n# Loop through each SII category to plot pie charts\nfor sii_value, sii_label in enumerate(sii_labels):\n    # Filter the data for the current SII category\n    sii_data = test[test['sii'] == sii_value]\n    \n    # Count occurrences of each score within the current SII category\n    score_counts = sii_data['sii_square'].value_counts().reindex(score_labels).fillna(0)\n    \n    # Calculate the percentage for each score\n    score_percentages = (score_counts / score_counts.sum()) * 100\n    \n    # Plotting the pie chart for the current SII category\n    plt.figure(figsize=(6, 6))\n    plt.pie(score_percentages, labels=score_labels, autopct='%1.1f%%', startangle=140, colors=plt.cm.Paired.colors)\n    \n    # Set the title for each pi\n","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:37.176299Z","iopub.execute_input":"2024-11-06T07:27:37.176803Z","iopub.status.idle":"2024-11-06T07:27:37.885609Z","shell.execute_reply.started":"2024-11-06T07:27:37.176751Z","shell.execute_reply":"2024-11-06T07:27:37.884431Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#question 1,2,3,5\nimport matplotlib.pyplot as plt\n\n# Define the labels for SII categories and PCIAT-PCIAT_Score_square values\nsii_labels = ['None', 'Mild', 'Moderate', 'Severe']\nscore_labels = [0, 1, 2, 3, 4, 5]\n\n# Loop through each SII category to plot pie charts\nfor sii_value, sii_label in enumerate(sii_labels):\n    # Filter the data for the current SII category\n    sii_data = test[test['sii'] == sii_value]\n    \n    # Count occurrences of each score within the current SII category\n    score_counts = sii_data['PCIAT-PCIAT_Score_square'].value_counts().reindex(score_labels).fillna(0)\n    \n    # Calculate the percentage for each score\n    score_percentages = (score_counts / score_counts.sum()) * 100\n    \n    # Plotting the pie chart for the current SII category\n    plt.figure(figsize=(6, 6))\n    plt.pie(score_percentages, labels=score_labels, autopct='%1.1f%%', startangle=140, colors=plt.cm.Paired.colors)\n    \n    # Set the title for each pi\n","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:37.887437Z","iopub.execute_input":"2024-11-06T07:27:37.888242Z","iopub.status.idle":"2024-11-06T07:27:38.705954Z","shell.execute_reply.started":"2024-11-06T07:27:37.888192Z","shell.execute_reply":"2024-11-06T07:27:38.704670Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#question 13,18,16\ntest['PCIAT-PCIAT_Score_square_01'] = round(((test['PCIAT-PCIAT_13']+1)*(test['PCIAT-PCIAT_18']+1)*(test['PCIAT-PCIAT_16']+1)) ** (1 / 3))-1","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:38.708110Z","iopub.execute_input":"2024-11-06T07:27:38.709061Z","iopub.status.idle":"2024-11-06T07:27:38.718050Z","shell.execute_reply.started":"2024-11-06T07:27:38.709002Z","shell.execute_reply":"2024-11-06T07:27:38.716800Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\n# Define the labels for SII categories and PCIAT-PCIAT_Score_square values\nsii_labels = ['None', 'Mild', 'Moderate', 'Severe']\nscore_labels = [0, 1, 2, 3, 4, 5]\n\n# Loop through each SII category to plot pie charts\nfor sii_value, sii_label in enumerate(sii_labels):\n    # Filter the data for the current SII category\n    sii_data = test[test['sii'] == sii_value]\n    \n    # Count occurrences of each score within the current SII category\n    score_counts = sii_data['PCIAT-PCIAT_Score_square_01'].value_counts().reindex(score_labels).fillna(0)\n    \n    # Calculate the percentage for each score\n    score_percentages = (score_counts / score_counts.sum()) * 100\n    \n    # Plotting the pie chart for the current SII category\n    plt.figure(figsize=(6, 6))\n    plt.pie(score_percentages, labels=score_labels, autopct='%1.1f%%', startangle=140, colors=plt.cm.Paired.colors)\n    \n    # Set the title for each pi","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:38.720380Z","iopub.execute_input":"2024-11-06T07:27:38.721512Z","iopub.status.idle":"2024-11-06T07:27:39.414780Z","shell.execute_reply.started":"2024-11-06T07:27:38.721437Z","shell.execute_reply":"2024-11-06T07:27:39.413506Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#question 14 20\ntest['PCIAT-PCIAT_Score_square_02'] = round(((test['PCIAT-PCIAT_14']+1)*(test['PCIAT-PCIAT_20']+1)) ** (1 / 2))-1","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:39.416973Z","iopub.execute_input":"2024-11-06T07:27:39.417904Z","iopub.status.idle":"2024-11-06T07:27:39.426900Z","shell.execute_reply.started":"2024-11-06T07:27:39.417846Z","shell.execute_reply":"2024-11-06T07:27:39.425349Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\n# Define the labels for SII categories and PCIAT-PCIAT_Score_square values\nsii_labels = ['None', 'Mild', 'Moderate', 'Severe']\nscore_labels = [0, 1, 2, 3, 4, 5]\n\n# Loop through each SII category to plot pie charts\nfor sii_value, sii_label in enumerate(sii_labels):\n    # Filter the data for the current SII category\n    sii_data = test[test['sii'] == sii_value]\n    \n    # Count occurrences of each score within the current SII category\n    score_counts = sii_data['PCIAT-PCIAT_Score_square_02'].value_counts().reindex(score_labels).fillna(0)\n    \n    # Calculate the percentage for each score\n    score_percentages = (score_counts / score_counts.sum()) * 100\n    \n    # Plotting the pie chart for the current SII category\n    plt.figure(figsize=(6, 6))\n    plt.pie(score_percentages, labels=score_labels, autopct='%1.1f%%', startangle=140, colors=plt.cm.Paired.colors)\n    \n    # Set the title for each pi","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:39.434898Z","iopub.execute_input":"2024-11-06T07:27:39.435873Z","iopub.status.idle":"2024-11-06T07:27:40.126669Z","shell.execute_reply.started":"2024-11-06T07:27:39.435813Z","shell.execute_reply":"2024-11-06T07:27:40.125381Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#question 12 14\ntest['PCIAT-PCIAT_Score_square_03'] = round(((test['PCIAT-PCIAT_12']+1)*(test['PCIAT-PCIAT_04']+1)) ** (1 / 2))-1","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:40.128904Z","iopub.execute_input":"2024-11-06T07:27:40.129873Z","iopub.status.idle":"2024-11-06T07:27:40.138518Z","shell.execute_reply.started":"2024-11-06T07:27:40.129801Z","shell.execute_reply":"2024-11-06T07:27:40.137287Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Define the labels for SII categories and PCIAT-PCIAT_Score_square values\nsii_labels = ['None', 'Mild', 'Moderate', 'Severe']\nscore_labels = [0, 1, 2, 3, 4, 5]\n\n# Loop through each SII category to plot pie charts\nfor sii_value, sii_label in enumerate(sii_labels):\n    # Filter the data for the current SII category\n    sii_data = test[test['sii'] == sii_value]\n    \n    # Count occurrences of each score within the current SII category\n    score_counts = sii_data['PCIAT-PCIAT_Score_square_03'].value_counts().reindex(score_labels).fillna(0)\n    \n    # Calculate the percentage for each score\n    score_percentages = (score_counts / score_counts.sum()) * 100\n    \n    # Plotting the pie chart for the current SII category\n    plt.figure(figsize=(6, 6))\n    plt.pie(score_percentages, labels=score_labels, autopct='%1.1f%%', startangle=140, colors=plt.cm.Paired.colors)\n    \n    # Set the title for each pi","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:40.141023Z","iopub.execute_input":"2024-11-06T07:27:40.142179Z","iopub.status.idle":"2024-11-06T07:27:40.892179Z","shell.execute_reply.started":"2024-11-06T07:27:40.142116Z","shell.execute_reply":"2024-11-06T07:27:40.888656Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(10, 6))\nsns.boxplot(x='sii', y='PCIAT-PCIAT_Score', data=test, palette='Set3')\n\n# Set titles and labels\nplt.title('Distribution of Score across SII Categories')\nplt.xlabel('SII')\nplt.ylabel('Score')\nplt.xticks([0, 1, 2, 3], ['None', 'Mild', 'Moderate', 'Severe'])\n\n# Show plot\nplt.show()\n\nplt.figure(figsize=(10, 6))\nsns.boxplot(x='sii', y='PCIAT-PCIAT_Score_square', data=test, palette='Set3')\n\n# Set titles and labels\nplt.title('Distribution of Score across SII Categories')\nplt.xlabel('SII')\nplt.ylabel('Score')\nplt.xticks([0, 1, 2, 3], ['None', 'Mild', 'Moderate', 'Severe'])\n\n# Show plot\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-11-06T07:27:40.894505Z","iopub.execute_input":"2024-11-06T07:27:40.894997Z","iopub.status.idle":"2024-11-06T07:27:41.486804Z","shell.execute_reply.started":"2024-11-06T07:27:40.894947Z","shell.execute_reply":"2024-11-06T07:27:41.485683Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}