{"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":"# we are started\n\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport os\nimport seaborn as sns\n\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":"2023-05-21T15:31:33.797304Z","iopub.execute_input":"2023-05-21T15:31:33.797818Z","iopub.status.idle":"2023-05-21T15:31:33.804042Z","shell.execute_reply.started":"2023-05-21T15:31:33.797778Z","shell.execute_reply":"2023-05-21T15:31:33.802761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defog = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/defog_metadata.csv\")\nsubjects = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/subjects.csv\")\ntdcs = pd.read_csv('/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/tdcsfog_metadata.csv')","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:33.848353Z","iopub.execute_input":"2023-05-21T15:31:33.849000Z","iopub.status.idle":"2023-05-21T15:31:33.869094Z","shell.execute_reply.started":"2023-05-21T15:31:33.848790Z","shell.execute_reply":"2023-05-21T15:31:33.867824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.head()","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:33.905213Z","iopub.execute_input":"2023-05-21T15:31:33.906441Z","iopub.status.idle":"2023-05-21T15:31:33.925128Z","shell.execute_reply.started":"2023-05-21T15:31:33.906396Z","shell.execute_reply":"2023-05-21T15:31:33.923726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"For a better understanding of the assessment of the disease, you can read the article at the <a href='https://www.sciencedirect.com/science/article/abs/pii/S0966636209002008?via%3Dihub'>link</a>","metadata":{}},{"cell_type":"code","source":"subjects.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.149003Z","iopub.execute_input":"2023-05-21T15:31:34.149484Z","iopub.status.idle":"2023-05-21T15:31:34.159769Z","shell.execute_reply.started":"2023-05-21T15:31:34.149429Z","shell.execute_reply":"2023-05-21T15:31:34.158761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.describe()","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.214495Z","iopub.execute_input":"2023-05-21T15:31:34.215130Z","iopub.status.idle":"2023-05-21T15:31:34.249427Z","shell.execute_reply.started":"2023-05-21T15:31:34.215095Z","shell.execute_reply":"2023-05-21T15:31:34.248511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects[\"Visit\"] = subjects[\"Visit\"].fillna(1)\nsubjects[\"UPDRSIII_On\"] = subjects[\"UPDRSIII_On\"].fillna(int(subjects[\"UPDRSIII_On\"].median()))","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.262816Z","iopub.execute_input":"2023-05-21T15:31:34.263482Z","iopub.status.idle":"2023-05-21T15:31:34.271187Z","shell.execute_reply.started":"2023-05-21T15:31:34.263424Z","shell.execute_reply":"2023-05-21T15:31:34.270011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects = subjects.dropna()","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.312727Z","iopub.execute_input":"2023-05-21T15:31:34.313546Z","iopub.status.idle":"2023-05-21T15:31:34.321471Z","shell.execute_reply.started":"2023-05-21T15:31:34.313506Z","shell.execute_reply":"2023-05-21T15:31:34.320020Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.361417Z","iopub.execute_input":"2023-05-21T15:31:34.361865Z","iopub.status.idle":"2023-05-21T15:31:34.389762Z","shell.execute_reply.started":"2023-05-21T15:31:34.361829Z","shell.execute_reply":"2023-05-21T15:31:34.388306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = subjects, x = 'Sex');\nplt.show();","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.402746Z","iopub.execute_input":"2023-05-21T15:31:34.403760Z","iopub.status.idle":"2023-05-21T15:31:34.621815Z","shell.execute_reply.started":"2023-05-21T15:31:34.403715Z","shell.execute_reply":"2023-05-21T15:31:34.620546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data=subjects, x='Age', bins=20, hue='Sex', multiple=\"stack\");\nplt.xlabel(\"Age of the Patient\", size=12);","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:34.624336Z","iopub.execute_input":"2023-05-21T15:31:34.625121Z","iopub.status.idle":"2023-05-21T15:31:35.099057Z","shell.execute_reply.started":"2023-05-21T15:31:34.625078Z","shell.execute_reply":"2023-05-21T15:31:35.097564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data=subjects, x='YearsSinceDx', bins=30, hue='Sex',  multiple=\"stack\");\nplt.xlabel(\"Number of years since patient has\");","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:35.101234Z","iopub.execute_input":"2023-05-21T15:31:35.101691Z","iopub.status.idle":"2023-05-21T15:31:35.640850Z","shell.execute_reply.started":"2023-05-21T15:31:35.101650Z","shell.execute_reply":"2023-05-21T15:31:35.639421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"most likely, mostly men are ill.","metadata":{}},{"cell_type":"code","source":"x = subjects[\"YearsSinceDx\"]\ny = subjects[\"Age\"]\nsns.scatterplot(x=x, y=y);","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:35.644876Z","iopub.execute_input":"2023-05-21T15:31:35.645617Z","iopub.status.idle":"2023-05-21T15:31:35.940390Z","shell.execute_reply.started":"2023-05-21T15:31:35.645568Z","shell.execute_reply":"2023-05-21T15:31:35.939071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Most of the patients are examined for 15 years, while their age ranges from 50 to 80 years.","metadata":{}},{"cell_type":"code","source":"subjects.hist(bins=40, figsize=(15,15));","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:35.941919Z","iopub.execute_input":"2023-05-21T15:31:35.942296Z","iopub.status.idle":"2023-05-21T15:31:38.180197Z","shell.execute_reply.started":"2023-05-21T15:31:35.942261Z","shell.execute_reply":"2023-05-21T15:31:38.178966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subjects.groupby(['Visit']).count()","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:38.182285Z","iopub.execute_input":"2023-05-21T15:31:38.183128Z","iopub.status.idle":"2023-05-21T15:31:38.201164Z","shell.execute_reply.started":"2023-05-21T15:31:38.183079Z","shell.execute_reply":"2023-05-21T15:31:38.200140Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defog","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:38.202564Z","iopub.execute_input":"2023-05-21T15:31:38.202983Z","iopub.status.idle":"2023-05-21T15:31:38.227841Z","shell.execute_reply.started":"2023-05-21T15:31:38.202947Z","shell.execute_reply":"2023-05-21T15:31:38.225779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res = subjects.merge(defog[['Medication','Subject']], on='Subject', how ='right')\nres.loc[res['Medication']=='on','Medication_defog'] = 1\nres.loc[res['Medication']=='off','Medication_defog'] = 0\nres['Medication_defog'] = res['Medication_defog'].astype(int)\nres = res.drop_duplicates().reset_index(drop=True)\nres","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:38.229169Z","iopub.execute_input":"2023-05-21T15:31:38.232846Z","iopub.status.idle":"2023-05-21T15:31:38.277181Z","shell.execute_reply.started":"2023-05-21T15:31:38.232797Z","shell.execute_reply":"2023-05-21T15:31:38.275885Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"correlation = res.corr();\ncorrelation.style.background_gradient(cmap='RdYlGn')","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:38.280513Z","iopub.execute_input":"2023-05-21T15:31:38.280912Z","iopub.status.idle":"2023-05-21T15:31:38.316876Z","shell.execute_reply.started":"2023-05-21T15:31:38.280878Z","shell.execute_reply":"2023-05-21T15:31:38.315520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"based on the data obtained, we can say that taking medication does not affect the assessment of the disease.","metadata":{}},{"cell_type":"code","source":"tdcs.loc[tdcs['Test']==1, 'Test_1'] = 1\ntdcs.loc[tdcs['Test']==2, 'Test_2'] = 1\ntdcs.loc[tdcs['Test']==3, 'Test_3'] = 1\ntdcs = tdcs.fillna(0)\ntdcs.loc[tdcs['Medication']=='on','Medication_tdcs'] = 1\ntdcs.loc[tdcs['Medication']=='off','Medication_tdcs'] = 0\ntdcs['Medication_tdcs'] = tdcs['Medication_tdcs'].astype(int)\ntdcs = tdcs.drop('Test', axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:38.318190Z","iopub.execute_input":"2023-05-21T15:31:38.318594Z","iopub.status.idle":"2023-05-21T15:31:38.337207Z","shell.execute_reply.started":"2023-05-21T15:31:38.318559Z","shell.execute_reply":"2023-05-21T15:31:38.335998Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"correlation = tdcs.corr();\ncorrelation.style.background_gradient(cmap='RdYlGn')","metadata":{"execution":{"iopub.status.busy":"2023-05-21T15:31:38.338268Z","iopub.execute_input":"2023-05-21T15:31:38.338656Z","iopub.status.idle":"2023-05-21T15:31:38.368620Z","shell.execute_reply.started":"2023-05-21T15:31:38.338623Z","shell.execute_reply":"2023-05-21T15:31:38.367411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"based on the dependencies obtained, **we can say that taking medications does not affect** the assessment of the disease, self-assessment and passing tests (<u>regardless of the level of complexity</u>)","metadata":{}}]}