{"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":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport os\nimport seaborn as sns\npd.plotting.register_matplotlib_converters()\n%matplotlib inline","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:03.886648Z","iopub.execute_input":"2023-04-12T13:31:03.887589Z","iopub.status.idle":"2023-04-12T13:31:03.895680Z","shell.execute_reply.started":"2023-04-12T13:31:03.887546Z","shell.execute_reply":"2023-04-12T13:31:03.894571Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"metadata = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/daily_metadata.csv\")\ndefog = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/defog_metadata.csv\")\nevents = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/events.csv\")\nsubjects = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/subjects.csv\")\ntasks = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/tasks.csv\")\ntdcs = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/tdcsfog_metadata.csv')\ntdcsfog = os.listdir('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/train/tdcsfog')","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:11.209432Z","iopub.execute_input":"2023-04-12T13:31:11.210753Z","iopub.status.idle":"2023-04-12T13:31:11.247308Z","shell.execute_reply.started":"2023-04-12T13:31:11.210700Z","shell.execute_reply":"2023-04-12T13:31:11.246184Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/subjects.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:17.607236Z","iopub.execute_input":"2023-04-12T13:31:17.607772Z","iopub.status.idle":"2023-04-12T13:31:17.618248Z","shell.execute_reply.started":"2023-04-12T13:31:17.607726Z","shell.execute_reply":"2023-04-12T13:31:17.616799Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.tail()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:21.565972Z","iopub.execute_input":"2023-04-12T13:31:21.566571Z","iopub.status.idle":"2023-04-12T13:31:21.590533Z","shell.execute_reply.started":"2023-04-12T13:31:21.566514Z","shell.execute_reply":"2023-04-12T13:31:21.588835Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:14:56.968136Z","iopub.execute_input":"2023-04-12T13:14:56.968670Z","iopub.status.idle":"2023-04-12T13:14:56.981056Z","shell.execute_reply.started":"2023-04-12T13:14:56.968591Z","shell.execute_reply":"2023-04-12T13:14:56.979683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.describe()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:15:04.152931Z","iopub.execute_input":"2023-04-12T13:15:04.154228Z","iopub.status.idle":"2023-04-12T13:15:04.190904Z","shell.execute_reply.started":"2023-04-12T13:15:04.154175Z","shell.execute_reply":"2023-04-12T13:15:04.189658Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.shape[0],subjects['Subject'].nunique()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:26.604923Z","iopub.execute_input":"2023-04-12T13:31:26.605348Z","iopub.status.idle":"2023-04-12T13:31:26.615099Z","shell.execute_reply.started":"2023-04-12T13:31:26.605309Z","shell.execute_reply":"2023-04-12T13:31:26.613800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# replace Nan with 1 in Visit \nsubjects[\"Visit_\"] = subjects[\"Visit\"].fillna(1)\n# replace Nan with 43.0 in UPDRSIII_Off\nsubjects[\"UPDRSIII_Off_\"] = subjects[\"UPDRSIII_Off\"].fillna(43.0)\n# replace Nan with 35.0 in UPDRSIII_On\nsubjects[\"UPDRSIII_On_\"] = subjects[\"UPDRSIII_On\"].fillna(35.0)\nsubjects.head()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:31.011033Z","iopub.execute_input":"2023-04-12T13:31:31.011796Z","iopub.status.idle":"2023-04-12T13:31:31.039238Z","shell.execute_reply.started":"2023-04-12T13:31:31.011754Z","shell.execute_reply":"2023-04-12T13:31:31.037906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.Visit.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:20:04.114242Z","iopub.execute_input":"2023-04-12T13:20:04.114928Z","iopub.status.idle":"2023-04-12T13:20:04.126942Z","shell.execute_reply.started":"2023-04-12T13:20:04.114878Z","shell.execute_reply":"2023-04-12T13:20:04.124966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.any()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:21:20.618283Z","iopub.execute_input":"2023-04-12T13:21:20.619313Z","iopub.status.idle":"2023-04-12T13:21:20.631213Z","shell.execute_reply.started":"2023-04-12T13:21:20.619254Z","shell.execute_reply":"2023-04-12T13:21:20.629654Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = subjects[\"YearsSinceDx\"]\ny = subjects[\"Age\"]\ncorrelation = y.corr(x)\ncorrelation","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:31:59.472236Z","iopub.execute_input":"2023-04-12T13:31:59.472695Z","iopub.status.idle":"2023-04-12T13:31:59.484050Z","shell.execute_reply.started":"2023-04-12T13:31:59.472658Z","shell.execute_reply":"2023-04-12T13:31:59.482372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Checking for correlation between the age of the patient and the numberof years since they are having Parkinsons Disease\nsns.scatterplot(x=x, y=y)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:22:03.757899Z","iopub.execute_input":"2023-04-12T13:22:03.758365Z","iopub.status.idle":"2023-04-12T13:22:04.050339Z","shell.execute_reply.started":"2023-04-12T13:22:03.758298Z","shell.execute_reply":"2023-04-12T13:22:04.049020Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Context 1\n\nFrom here, we can easily conclude that the number of males in the given database is nearly 121 while the number of females is nearly 52 which is quite less","metadata":{}},{"cell_type":"code","source":"sns.histplot(data = subjects, x = 'Sex')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:24:11.413339Z","iopub.execute_input":"2023-04-12T13:24:11.413808Z","iopub.status.idle":"2023-04-12T13:24:11.584767Z","shell.execute_reply.started":"2023-04-12T13:24:11.413771Z","shell.execute_reply":"2023-04-12T13:24:11.583225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data=subjects, x='Age', bins=20, hue='Sex')\nplt.xlabel(\"Age of the Patient\", size=12)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:25:15.244107Z","iopub.execute_input":"2023-04-12T13:25:15.244590Z","iopub.status.idle":"2023-04-12T13:25:15.665831Z","shell.execute_reply.started":"2023-04-12T13:25:15.244550Z","shell.execute_reply":"2023-04-12T13:25:15.664437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Context 2\nThe age of the patients lie between 30 to 90 with the most ranging between 57-81 and the highest (nearly) between 72-75 years","metadata":{}},{"cell_type":"code","source":"sns.histplot(data=subjects, x='YearsSinceDx', bins=30, color='orange', edgecolor ='red')\nplt.xlabel(\"Number of years since patient has\")","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:29:01.855850Z","iopub.execute_input":"2023-04-12T13:29:01.856291Z","iopub.status.idle":"2023-04-12T13:29:02.196547Z","shell.execute_reply.started":"2023-04-12T13:29:01.856255Z","shell.execute_reply":"2023-04-12T13:29:02.194956Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#To look at all the histograms at a glance in the Subjects data:\nsubjects.hist(color='green', figsize=[20,10])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:29:54.286478Z","iopub.execute_input":"2023-04-12T13:29:54.286968Z","iopub.status.idle":"2023-04-12T13:29:55.586370Z","shell.execute_reply.started":"2023-04-12T13:29:54.286928Z","shell.execute_reply":"2023-04-12T13:29:55.585071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcs.tail()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:33:00.687440Z","iopub.execute_input":"2023-04-12T13:33:00.688733Z","iopub.status.idle":"2023-04-12T13:33:00.704423Z","shell.execute_reply.started":"2023-04-12T13:33:00.688692Z","shell.execute_reply":"2023-04-12T13:33:00.702974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"medication = tdcs['Medication']\nsum_updrs = subjects['UPDRSIII_Off']\nsum_updrs2 = subjects['UPDRSIII_On']\nsex = subjects['Sex']\nsum_total = sum_updrs+sum_updrs2","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:33:56.801929Z","iopub.execute_input":"2023-04-12T13:33:56.802936Z","iopub.status.idle":"2023-04-12T13:33:56.809833Z","shell.execute_reply.started":"2023-04-12T13:33:56.802868Z","shell.execute_reply":"2023-04-12T13:33:56.808468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.jointplot(x=sum_updrs, y=sum_updrs2, hue=medication)\nplt.xlabel(\"UPDRS_Off\", size=14)\nplt.ylabel(\"UPDRS_On\", size=14)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:34:23.060218Z","iopub.execute_input":"2023-04-12T13:34:23.060654Z","iopub.status.idle":"2023-04-12T13:34:23.761349Z","shell.execute_reply.started":"2023-04-12T13:34:23.060602Z","shell.execute_reply":"2023-04-12T13:34:23.760057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Context 3\n1.There are definitely some outliers that are present especially when medication is off.\n2.Those having their medication off have a higher UPDRS score","metadata":{}},{"cell_type":"code","source":"sns.jointplot(x=sum_updrs, y=sum_updrs2, hue=sex)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:37:47.738711Z","iopub.execute_input":"2023-04-12T13:37:47.739167Z","iopub.status.idle":"2023-04-12T13:37:48.772234Z","shell.execute_reply.started":"2023-04-12T13:37:47.739131Z","shell.execute_reply":"2023-04-12T13:37:48.770926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Context 4\n1.Majority of the men had their UPDRS score clustered in the centre 2.There were very few outliers present throughout the graph","metadata":{}},{"cell_type":"code","source":"tdcs.describe()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:39:28.177019Z","iopub.execute_input":"2023-04-12T13:39:28.177457Z","iopub.status.idle":"2023-04-12T13:39:28.199777Z","shell.execute_reply.started":"2023-04-12T13:39:28.177420Z","shell.execute_reply":"2023-04-12T13:39:28.198299Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(x=tdcs['Visit'], y=None, hue= tdcs['Medication'], kind='kde')","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:40:41.006209Z","iopub.execute_input":"2023-04-12T13:40:41.006711Z","iopub.status.idle":"2023-04-12T13:40:41.494941Z","shell.execute_reply.started":"2023-04-12T13:40:41.006660Z","shell.execute_reply":"2023-04-12T13:40:41.493856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"a = subjects['Sex'].value_counts()['M']\nb = subjects['Sex'].value_counts()['F']","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:41:15.596997Z","iopub.execute_input":"2023-04-12T13:41:15.597468Z","iopub.status.idle":"2023-04-12T13:41:15.605965Z","shell.execute_reply.started":"2023-04-12T13:41:15.597428Z","shell.execute_reply":"2023-04-12T13:41:15.604362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcs.replace('on', 1, inplace=True)\ntdcs.replace('off', 0, inplace=True)\ntdcs.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:41:39.541014Z","iopub.execute_input":"2023-04-12T13:41:39.541514Z","iopub.status.idle":"2023-04-12T13:41:39.559453Z","shell.execute_reply.started":"2023-04-12T13:41:39.541473Z","shell.execute_reply":"2023-04-12T13:41:39.558180Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x1 = tdcs['Medication']\nx2= tdcs['Visit']\ncorr = x1.corr(x2)\ncorr\n#This correlation shows that Medication and the number of visits are slightly correlated. When Medication is on, number of visits are more.","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:42:15.821744Z","iopub.execute_input":"2023-04-12T13:42:15.822198Z","iopub.status.idle":"2023-04-12T13:42:15.833886Z","shell.execute_reply.started":"2023-04-12T13:42:15.822160Z","shell.execute_reply":"2023-04-12T13:42:15.832302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"events.tail()","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:43:59.127165Z","iopub.execute_input":"2023-04-12T13:43:59.128518Z","iopub.status.idle":"2023-04-12T13:43:59.143221Z","shell.execute_reply.started":"2023-04-12T13:43:59.128466Z","shell.execute_reply":"2023-04-12T13:43:59.142012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start = events['Init']\nend = events['Completion']\nduration_total = end-start\nduration_total","metadata":{"execution":{"iopub.status.busy":"2023-04-12T13:44:03.365165Z","iopub.execute_input":"2023-04-12T13:44:03.365641Z","iopub.status.idle":"2023-04-12T13:44:03.378499Z","shell.execute_reply.started":"2023-04-12T13:44:03.365582Z","shell.execute_reply":"2023-04-12T13:44:03.376798Z"},"trusted":true},"execution_count":null,"outputs":[]}]}