{"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 numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport os\nimport glob\nimport gc","metadata":{"execution":{"iopub.status.busy":"2023-03-13T09:45:07.145354Z","iopub.execute_input":"2023-03-13T09:45:07.146252Z","iopub.status.idle":"2023-03-13T09:45:07.158290Z","shell.execute_reply.started":"2023-03-13T09:45:07.146213Z","shell.execute_reply":"2023-03-13T09:45:07.156539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-03-13T09:45:07.164193Z","iopub.execute_input":"2023-03-13T09:45:07.166930Z","iopub.status.idle":"2023-03-13T09:45:07.194643Z","shell.execute_reply.started":"2023-03-13T09:45:07.166864Z","shell.execute_reply":"2023-03-13T09:45:07.192928Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#understanding metadata\ndefog_meatadata = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/defog_metadata.csv\")\ndefog_meatadata.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-13T09:45:07.195733Z","iopub.execute_input":"2023-03-13T09:45:07.196072Z","iopub.status.idle":"2023-03-13T09:45:07.215605Z","shell.execute_reply.started":"2023-03-13T09:45:07.196038Z","shell.execute_reply":"2023-03-13T09:45:07.214353Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##defog contains 45 unique subjects with 137 visits\n\ndefog_meatadata.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2023-03-13T09:45:09.584639Z","iopub.execute_input":"2023-03-13T09:45:09.585312Z","iopub.status.idle":"2023-03-13T09:45:09.604342Z","shell.execute_reply.started":"2023-03-13T09:45:09.585271Z","shell.execute_reply":"2023-03-13T09:45:09.603275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#check defog timeseries for 1 subject out of these 45 subjects\ndf_list=[]\npath='/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/train/defog/'\nfilenames = glob.glob(os.path.join(path , \"*.csv\"))\nfor filename in filenames[0:1]:\n    print(filename)\n    for filename in filenames:\n        df= pd.read_csv(filename)\n        df_list.append(df)\n        \n","metadata":{"execution":{"iopub.status.busy":"2023-03-13T09:48:56.724430Z","iopub.execute_input":"2023-03-13T09:48:56.724858Z","iopub.status.idle":"2023-03-13T09:49:05.046123Z","shell.execute_reply.started":"2023-03-13T09:48:56.724821Z","shell.execute_reply":"2023-03-13T09:49:05.044994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_be9d33541d = df_list[0]","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:30:33.437518Z","iopub.execute_input":"2023-03-13T10:30:33.438507Z","iopub.status.idle":"2023-03-13T10:30:33.444700Z","shell.execute_reply.started":"2023-03-13T10:30:33.438456Z","shell.execute_reply":"2023-03-13T10:30:33.442739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##df_be9d33541d= pd.concat(df_list , ignore_index = True, axis =0)\ndf_be9d33541d.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:30:34.323333Z","iopub.execute_input":"2023-03-13T10:30:34.323783Z","iopub.status.idle":"2023-03-13T10:30:34.337863Z","shell.execute_reply.started":"2023-03-13T10:30:34.323741Z","shell.execute_reply":"2023-03-13T10:30:34.336092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_be9d33541d.shape","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:30:36.667148Z","iopub.execute_input":"2023-03-13T10:30:36.667618Z","iopub.status.idle":"2023-03-13T10:30:36.674574Z","shell.execute_reply.started":"2023-03-13T10:30:36.667543Z","shell.execute_reply":"2023-03-13T10:30:36.673545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##ignore invalid records since these are not annotated\n\ndf_be9d33541d  = df_be9d33541d[(df_be9d33541d[\"Task\"] == True) & (df_be9d33541d[\"Valid\"] == True)]\ndf_be9d33541d.shape","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:30:39.136295Z","iopub.execute_input":"2023-03-13T10:30:39.136719Z","iopub.status.idle":"2023-03-13T10:30:39.150505Z","shell.execute_reply.started":"2023-03-13T10:30:39.136681Z","shell.execute_reply":"2023-03-13T10:30:39.148988Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_be9d33541d","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:38:55.068982Z","iopub.execute_input":"2023-03-13T10:38:55.069340Z","iopub.status.idle":"2023-03-13T10:38:55.089862Z","shell.execute_reply.started":"2023-03-13T10:38:55.069308Z","shell.execute_reply":"2023-03-13T10:38:55.088224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Turn --------> {df_be9d33541d[df_be9d33541d.Turn == 1].count()}\") ## Turn 3158    \nprint(f\"Walking --------> {df_be9d33541d[df_be9d33541d.Walking == 1].count()}\") ## Walking  0\nprint(f\"StartHesitation --------> {df_be9d33541d[df_be9d33541d.StartHesitation == 1].count()}\") ## StartHesitation 0","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:31:17.908461Z","iopub.execute_input":"2023-03-13T10:31:17.908890Z","iopub.status.idle":"2023-03-13T10:31:17.923829Z","shell.execute_reply.started":"2023-03-13T10:31:17.908857Z","shell.execute_reply":"2023-03-13T10:31:17.921951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_be9d33541d.describe()","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:30:56.478760Z","iopub.execute_input":"2023-03-13T10:30:56.479168Z","iopub.status.idle":"2023-03-13T10:30:56.519133Z","shell.execute_reply.started":"2023-03-13T10:30:56.479127Z","shell.execute_reply":"2023-03-13T10:30:56.517464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"##Analyzing the 3 target classes \n\ndf_be9d33541d[['StartHesitation','Turn','Walking']].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:31:32.524590Z","iopub.execute_input":"2023-03-13T10:31:32.525051Z","iopub.status.idle":"2023-03-13T10:31:32.543006Z","shell.execute_reply.started":"2023-03-13T10:31:32.525006Z","shell.execute_reply":"2023-03-13T10:31:32.541187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#read events data for timeseries\n\ndf_events = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/events.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:35:50.326971Z","iopub.execute_input":"2023-03-13T10:35:50.327349Z","iopub.status.idle":"2023-03-13T10:35:50.338718Z","shell.execute_reply.started":"2023-03-13T10:35:50.327311Z","shell.execute_reply":"2023-03-13T10:35:50.337749Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#check with series id\n##event annotation in already done in DEFOG and TDSFOG data, needed only for notype\n#notype lacks typelevel annotations , can be done through events data\n\n\ndf_events[df_events.Id =='be9d33541d']","metadata":{"execution":{"iopub.status.busy":"2023-03-13T10:35:53.554167Z","iopub.execute_input":"2023-03-13T10:35:53.554553Z","iopub.status.idle":"2023-03-13T10:35:53.577944Z","shell.execute_reply.started":"2023-03-13T10:35:53.554522Z","shell.execute_reply":"2023-03-13T10:35:53.576797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#get task data \ndf_tasks = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/tasks.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-13T11:02:44.772408Z","iopub.execute_input":"2023-03-13T11:02:44.772792Z","iopub.status.idle":"2023-03-13T11:02:44.785315Z","shell.execute_reply.started":"2023-03-13T11:02:44.772763Z","shell.execute_reply":"2023-03-13T11:02:44.783780Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tasks[df_tasks.Id =='be9d33541d']","metadata":{"execution":{"iopub.status.busy":"2023-03-13T11:03:06.849068Z","iopub.execute_input":"2023-03-13T11:03:06.849505Z","iopub.status.idle":"2023-03-13T11:03:06.867088Z","shell.execute_reply.started":"2023-03-13T11:03:06.849465Z","shell.execute_reply":"2023-03-13T11:03:06.865839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}