{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\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\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.\n\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-03-22T03:35:46.371657Z","iopub.execute_input":"2023-03-22T03:35:46.373523Z","iopub.status.idle":"2023-03-22T03:35:46.382138Z","shell.execute_reply.started":"2023-03-22T03:35:46.373440Z","shell.execute_reply":"2023-03-22T03:35:46.379969Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"events = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/events.csv')\n# For events, I'm going to add in a column that calculates the duration of the event, \n# as I'm curious as to how long these events are lasting.\nevents['eventDuration'] = events['Completion'] - events['Init']\nevents.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:36:10.556260Z","iopub.execute_input":"2023-03-22T03:36:10.556757Z","iopub.status.idle":"2023-03-22T03:36:10.586446Z","shell.execute_reply.started":"2023-03-22T03:36:10.556719Z","shell.execute_reply":"2023-03-22T03:36:10.584203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/subjects.csv')\nsubjects.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:36:13.545288Z","iopub.execute_input":"2023-03-22T03:36:13.545832Z","iopub.status.idle":"2023-03-22T03:36:13.572582Z","shell.execute_reply.started":"2023-03-22T03:36:13.545771Z","shell.execute_reply":"2023-03-22T03:36:13.571545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tasks = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/tasks.csv')\ntasks.head()\n","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:36:27.054596Z","iopub.execute_input":"2023-03-22T03:36:27.056108Z","iopub.status.idle":"2023-03-22T03:36:27.085676Z","shell.execute_reply.started":"2023-03-22T03:36:27.056046Z","shell.execute_reply":"2023-03-22T03:36:27.084520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogMeta = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/defog_metadata.csv')\ndefogMeta.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:36:39.471939Z","iopub.execute_input":"2023-03-22T03:36:39.473881Z","iopub.status.idle":"2023-03-22T03:36:39.500234Z","shell.execute_reply.started":"2023-03-22T03:36:39.473784Z","shell.execute_reply":"2023-03-22T03:36:39.499122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfogMeta = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/tdcsfog_metadata.csv')\ntdcsfogMeta.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:36:50.875137Z","iopub.execute_input":"2023-03-22T03:36:50.875638Z","iopub.status.idle":"2023-03-22T03:36:50.900432Z","shell.execute_reply.started":"2023-03-22T03:36:50.875597Z","shell.execute_reply":"2023-03-22T03:36:50.899363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dailyMeta = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/daily_metadata.csv')\ndailyMeta.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:37:07.121180Z","iopub.execute_input":"2023-03-22T03:37:07.121648Z","iopub.status.idle":"2023-03-22T03:37:07.142947Z","shell.execute_reply.started":"2023-03-22T03:37:07.121606Z","shell.execute_reply":"2023-03-22T03:37:07.141236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"events.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:37:18.136695Z","iopub.execute_input":"2023-03-22T03:37:18.138441Z","iopub.status.idle":"2023-03-22T03:37:18.152540Z","shell.execute_reply.started":"2023-03-22T03:37:18.138383Z","shell.execute_reply":"2023-03-22T03:37:18.150278Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:37:27.030103Z","iopub.execute_input":"2023-03-22T03:37:27.030661Z","iopub.status.idle":"2023-03-22T03:37:27.044742Z","shell.execute_reply.started":"2023-03-22T03:37:27.030613Z","shell.execute_reply":"2023-03-22T03:37:27.043551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tasks.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:37:37.410863Z","iopub.execute_input":"2023-03-22T03:37:37.411395Z","iopub.status.idle":"2023-03-22T03:37:37.425446Z","shell.execute_reply.started":"2023-03-22T03:37:37.411350Z","shell.execute_reply":"2023-03-22T03:37:37.423530Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogMeta.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:37:49.430608Z","iopub.execute_input":"2023-03-22T03:37:49.431192Z","iopub.status.idle":"2023-03-22T03:37:49.446162Z","shell.execute_reply.started":"2023-03-22T03:37:49.431148Z","shell.execute_reply":"2023-03-22T03:37:49.444100Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfogMeta.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:48:18.332928Z","iopub.execute_input":"2023-03-22T03:48:18.333491Z","iopub.status.idle":"2023-03-22T03:48:18.349313Z","shell.execute_reply.started":"2023-03-22T03:48:18.333449Z","shell.execute_reply":"2023-03-22T03:48:18.347586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dailyMeta.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:48:34.190451Z","iopub.execute_input":"2023-03-22T03:48:34.190954Z","iopub.status.idle":"2023-03-22T03:48:34.202702Z","shell.execute_reply.started":"2023-03-22T03:48:34.190911Z","shell.execute_reply":"2023-03-22T03:48:34.201388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogMetaSubjects = pd.merge(defogMeta, subjects, on=['Subject', 'Visit'])\nprint(defogMeta.Id.count())\nprint(defogMetaSubjects.Id.count())\n\ndefogMetaSubjects.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:49:09.008759Z","iopub.execute_input":"2023-03-22T03:49:09.009281Z","iopub.status.idle":"2023-03-22T03:49:09.050603Z","shell.execute_reply.started":"2023-03-22T03:49:09.009242Z","shell.execute_reply":"2023-03-22T03:49:09.049060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(nrows=3, ncols=3)\n\ndefogMetaSubjects.Medication.value_counts().plot.bar(ax=axes[0,0])\ndefogMetaSubjects.Age.plot.box(ax=axes[0,1])\ndefogMetaSubjects.Sex.value_counts().plot.bar(ax=axes[0,2])\ndefogMetaSubjects.YearsSinceDx.plot.box(ax=axes[1,0])\ndefogMetaSubjects.UPDRSIII_On.plot.box(ax=axes[1,1])\ndefogMetaSubjects.UPDRSIII_Off.plot.box(ax=axes[1,2])\ndefogMetaSubjects.NFOGQ.plot.box(ax=axes[2,1])\n\n\naxes[0,0].set_xlabel('Medication')\naxes[0,0].set_ylabel('Count')\naxes[0,1].set_ylabel('Age')\naxes[0,2].set_xlabel('Sex')\naxes[0,2].set_ylabel('Count')\naxes[1,0].set_ylabel('Years')\naxes[1,1].set_ylabel('Score')\naxes[1,2].set_ylabel('Score')\naxes[2,1].set_ylabel('Score')\nfig.set_figwidth(9)\nfig.set_figheight(9)\nfig.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:49:49.290192Z","iopub.execute_input":"2023-03-22T03:49:49.290740Z","iopub.status.idle":"2023-03-22T03:49:50.701984Z","shell.execute_reply.started":"2023-03-22T03:49:49.290695Z","shell.execute_reply":"2023-03-22T03:49:50.700977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogMetaSubjectsEvents = pd.merge(defogMetaSubjects, events, on=['Id'])\nprint(defogMetaSubjectsEvents.Id.count())\ndefogMetaSubjectsEvents.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:50:07.349066Z","iopub.execute_input":"2023-03-22T03:50:07.349531Z","iopub.status.idle":"2023-03-22T03:50:07.383780Z","shell.execute_reply.started":"2023-03-22T03:50:07.349493Z","shell.execute_reply":"2023-03-22T03:50:07.382214Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogMetaSubjectsEvents.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:50:17.832312Z","iopub.execute_input":"2023-03-22T03:50:17.832723Z","iopub.status.idle":"2023-03-22T03:50:17.847794Z","shell.execute_reply.started":"2023-03-22T03:50:17.832689Z","shell.execute_reply":"2023-03-22T03:50:17.845777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(nrows=1, ncols=2)\n\neventsPerRecording = defogMetaSubjectsEvents.groupby('Id').Type.count()\n\neventsPerRecording.plot.box(ax=axes[0])\nq_low = defogMetaSubjectsEvents.eventDuration.quantile(0.01)\nq_hi  = defogMetaSubjectsEvents.eventDuration.quantile(0.99)\n\ndefogMetaSubjectsEvents[(defogMetaSubjectsEvents.eventDuration < q_hi) & (defogMetaSubjectsEvents.eventDuration > q_low)].eventDuration.plot.hist(ax=axes[1])\n\naxes[0].set_xlabel('# of Events per Recording')\naxes[0].set_ylabel('Count')\n\n\nfig.set_figwidth(9)\nfig.set_figheight(3)\nfig.tight_layout()\neventsPerRecordingBySex = defogMetaSubjectsEvents.groupby(['Sex','Id']).aggregate({'Type': 'count'})\nprint(eventsPerRecordingBySex.Type.groupby('Sex').mean())","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:50:39.541029Z","iopub.execute_input":"2023-03-22T03:50:39.541538Z","iopub.status.idle":"2023-03-22T03:50:39.911237Z","shell.execute_reply.started":"2023-03-22T03:50:39.541495Z","shell.execute_reply":"2023-03-22T03:50:39.909627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(nrows=1, ncols=2)\nax = sns.violinplot(defogMetaSubjectsEvents, x='Type', y='eventDuration', inner='quartile', ax=axes[0])\n\neventsPerRecording = defogMetaSubjectsEvents.groupby('Id').Type.count()\n\neventsPerRecording.plot.hist(ax=axes[1])\nq_low = defogMetaSubjectsEvents.eventDuration.quantile(0.01)\nq_hi  = defogMetaSubjectsEvents.eventDuration.quantile(0.99)\n\ndefogMetaSubjectsEvents[(defogMetaSubjectsEvents.eventDuration < q_hi) & (defogMetaSubjectsEvents.eventDuration > q_low)].eventDuration.plot.hist(ax=axes[1])\naxes[1].set_xlabel('Duration of Events\\n(excluding outliers)')\naxes[1].set_ylabel('Count')\nfig.set_figwidth(12)\nfig.set_figheight(4)\nfig.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:51:10.309153Z","iopub.execute_input":"2023-03-22T03:51:10.309680Z","iopub.status.idle":"2023-03-22T03:51:11.020022Z","shell.execute_reply.started":"2023-03-22T03:51:10.309637Z","shell.execute_reply":"2023-03-22T03:51:11.018319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(nrows=1, ncols=1)\nax = sns.violinplot(defogMetaSubjectsEvents, x='Sex', y='eventDuration',  inner='quartile', ax=axes)\nfig.set_figwidth(8)\nfig.set_figheight(4)\nfig.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:51:14.655451Z","iopub.execute_input":"2023-03-22T03:51:14.656022Z","iopub.status.idle":"2023-03-22T03:51:14.854292Z","shell.execute_reply.started":"2023-03-22T03:51:14.655978Z","shell.execute_reply":"2023-03-22T03:51:14.852918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogByType = defogMetaSubjectsEvents.groupby('Type').aggregate({'Id': 'count'})\nprint(defogByType)\ndefogByType.plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:51:26.427694Z","iopub.execute_input":"2023-03-22T03:51:26.429043Z","iopub.status.idle":"2023-03-22T03:51:26.620861Z","shell.execute_reply.started":"2023-03-22T03:51:26.428973Z","shell.execute_reply":"2023-03-22T03:51:26.619428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defogByTypeBySubject = defogMetaSubjectsEvents.groupby(['Id', 'Subject', 'Type']).aggregate({'Id': 'count'})\ndefogByTypeBySubject.groupby('Type').median().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:51:41.930836Z","iopub.execute_input":"2023-03-22T03:51:41.931377Z","iopub.status.idle":"2023-03-22T03:51:42.174776Z","shell.execute_reply.started":"2023-03-22T03:51:41.931335Z","shell.execute_reply":"2023-03-22T03:51:42.173375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"uniquedefogTypeSets = defogMetaSubjectsEvents[defogMetaSubjectsEvents['Type'].notna()].groupby(['Id','Subject']).aggregate({'Type': lambda x: set(x.unique())})\nuniquedefogTypeSets['Type'].value_counts().plot.bar()\ntotal = uniquedefogTypeSets['Type'].count() \nprint(total)\nprint(uniquedefogTypeSets['Type'].value_counts() / total)","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:52:07.552989Z","iopub.execute_input":"2023-03-22T03:52:07.553569Z","iopub.status.idle":"2023-03-22T03:52:07.812198Z","shell.execute_reply.started":"2023-03-22T03:52:07.553520Z","shell.execute_reply":"2023-03-22T03:52:07.810375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfogMetaSubjects = pd.merge(tdcsfogMeta, subjects, on=['Subject'])\ntdcsfogMetaSubjects.drop('Visit_y', inplace=True, axis=1)\ntdcsfogMetaSubjects.rename({'Visit_x': 'Visit'}, inplace=True, axis=1)\nprint(tdcsfogMeta.Id.count())\nprint(tdcsfogMetaSubjects.Id.count())\n\ntdcsfogMetaSubjects.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:52:20.582002Z","iopub.execute_input":"2023-03-22T03:52:20.582498Z","iopub.status.idle":"2023-03-22T03:52:20.619860Z","shell.execute_reply.started":"2023-03-22T03:52:20.582456Z","shell.execute_reply":"2023-03-22T03:52:20.617945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(nrows=3, ncols=3)\n\ntdcsfogMetaSubjects.Medication.value_counts().plot.bar(ax=axes[0,0])\ntdcsfogMetaSubjects.Age.plot.box(ax=axes[0,1])\ntdcsfogMetaSubjects.Sex.value_counts().plot.bar(ax=axes[0,2])\ntdcsfogMetaSubjects.YearsSinceDx.plot.box(ax=axes[1,0])\ntdcsfogMetaSubjects.UPDRSIII_On.plot.box(ax=axes[1,1])\ntdcsfogMetaSubjects.UPDRSIII_Off.plot.box(ax=axes[1,2])\ntdcsfogMetaSubjects.NFOGQ.plot.box(ax=axes[2,1])\n\n\naxes[0,0].set_xlabel('Medication')\naxes[0,0].set_ylabel('Count')\naxes[0,1].set_ylabel('Age')\naxes[0,2].set_xlabel('Sex')\naxes[0,2].set_ylabel('Count')\naxes[1,0].set_ylabel('Years')\naxes[1,1].set_ylabel('Score')\naxes[1,2].set_ylabel('Score')\naxes[2,1].set_ylabel('Score')\nfig.set_figwidth(9)\nfig.set_figheight(9)\nfig.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:52:33.861287Z","iopub.execute_input":"2023-03-22T03:52:33.861872Z","iopub.status.idle":"2023-03-22T03:52:35.213133Z","shell.execute_reply.started":"2023-03-22T03:52:33.861825Z","shell.execute_reply":"2023-03-22T03:52:35.211583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfogMetaSubjectsEvents = pd.merge(tdcsfogMetaSubjects, events, on=['Id'])\nprint(tdcsfogMetaSubjects.Id.count())\nprint(tdcsfogMetaSubjectsEvents.Id.count())\n\ntdcsfogMetaSubjectsEvents.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:52:48.437287Z","iopub.execute_input":"2023-03-22T03:52:48.437878Z","iopub.status.idle":"2023-03-22T03:52:48.474728Z","shell.execute_reply.started":"2023-03-22T03:52:48.437829Z","shell.execute_reply":"2023-03-22T03:52:48.473047Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfogMetaSubjectsEvents.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:52:58.619981Z","iopub.execute_input":"2023-03-22T03:52:58.620713Z","iopub.status.idle":"2023-03-22T03:52:58.639122Z","shell.execute_reply.started":"2023-03-22T03:52:58.620656Z","shell.execute_reply":"2023-03-22T03:52:58.637104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(nrows=1, ncols=2)\n\neventsPerRecording = tdcsfogMetaSubjectsEvents.groupby('Id').Type.count()\n\neventsPerRecording.plot.box(ax=axes[0])\nq_low = tdcsfogMetaSubjectsEvents.eventDuration.quantile(0.01)\nq_hi  = tdcsfogMetaSubjectsEvents.eventDuration.quantile(0.99)\n\ntdcsfogMetaSubjectsEvents[(tdcsfogMetaSubjectsEvents.eventDuration < q_hi) & (tdcsfogMetaSubjectsEvents.eventDuration > q_low)].eventDuration.plot.hist(ax=axes[1])\n\naxes[0].set_xlabel('# of Events per Recording')\naxes[0].set_ylabel('Count')\naxes[1].set_xlabel('Duration of Events\\n(excluding outliers)')\naxes[1].set_ylabel('Count')\n\nfig.set_figwidth(9)\nfig.set_figheight(3)\nfig.tight_layout()\neventsPerRecordingBySex = tdcsfogMetaSubjectsEvents.groupby(['Sex','Id']).aggregate({'Type': 'count'})\nprint(eventsPerRecordingBySex.Type.groupby('Sex').mean())","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:53:10.467910Z","iopub.execute_input":"2023-03-22T03:53:10.468388Z","iopub.status.idle":"2023-03-22T03:53:10.964246Z","shell.execute_reply.started":"2023-03-22T03:53:10.468352Z","shell.execute_reply":"2023-03-22T03:53:10.962326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax = sns.violinplot(tdcsfogMetaSubjectsEvents, x='Type', y='eventDuration', scale='count', inner='quartile')","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:53:23.395534Z","iopub.execute_input":"2023-03-22T03:53:23.396048Z","iopub.status.idle":"2023-03-22T03:53:23.635159Z","shell.execute_reply.started":"2023-03-22T03:53:23.396007Z","shell.execute_reply":"2023-03-22T03:53:23.633566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfogByType = tdcsfogMetaSubjectsEvents.groupby('Type').aggregate({'Id': 'count'})\nprint(tdcsfogByType)\ntdcsfogByType.plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:53:32.980939Z","iopub.execute_input":"2023-03-22T03:53:32.981526Z","iopub.status.idle":"2023-03-22T03:53:33.256118Z","shell.execute_reply.started":"2023-03-22T03:53:32.981477Z","shell.execute_reply":"2023-03-22T03:53:33.253835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"uniquetdcsfogTypeSets = tdcsfogMetaSubjectsEvents.groupby(['Id','Subject']).aggregate({'Type': lambda x: set(x.unique())})\nuniquetdcsfogTypeSets['Type'].value_counts().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:53:44.180917Z","iopub.execute_input":"2023-03-22T03:53:44.182589Z","iopub.status.idle":"2023-03-22T03:53:44.479793Z","shell.execute_reply.started":"2023-03-22T03:53:44.182528Z","shell.execute_reply":"2023-03-22T03:53:44.478118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"allFog = tdcsfogMetaSubjectsEvents.append(defogMetaSubjectsEvents)\nuniqueallFog = allFog.groupby(['Id','Subject']).aggregate({'Type': lambda x: set(x.unique())})\ntotalUniqueSets = uniqueallFog.count().item()\nprint((uniqueallFog['Type'].value_counts() / totalUniqueSets) )\n\nuniqueallFog['Type'].value_counts().plot.bar()","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:54:18.381505Z","iopub.execute_input":"2023-03-22T03:54:18.383039Z","iopub.status.idle":"2023-03-22T03:54:18.716408Z","shell.execute_reply.started":"2023-03-22T03:54:18.382969Z","shell.execute_reply":"2023-03-22T03:54:18.715202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"allEventsPerRecording = allFog.groupby('Id').Type.count()\nprint(allEventsPerRecording.mean())\nprint(allEventsPerRecording.median())\nprint(allEventsPerRecording.mad())\nprint(allEventsPerRecording.value_counts())","metadata":{"execution":{"iopub.status.busy":"2023-03-22T03:54:42.175311Z","iopub.execute_input":"2023-03-22T03:54:42.176707Z","iopub.status.idle":"2023-03-22T03:54:42.193649Z","shell.execute_reply.started":"2023-03-22T03:54:42.176649Z","shell.execute_reply":"2023-03-22T03:54:42.191937Z"},"trusted":true},"execution_count":null,"outputs":[]}]}