{"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)\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\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\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-14T14:32:47.963334Z","iopub.execute_input":"2023-05-14T14:32:47.963774Z","iopub.status.idle":"2023-05-14T14:32:48.133663Z","shell.execute_reply.started":"2023-05-14T14:32:47.963711Z","shell.execute_reply":"2023-05-14T14:32:48.132682Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport pandas as pd\nimport plotly.graph_objects as go\nimport plotly.express as px\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:34:39.496795Z","iopub.execute_input":"2023-05-14T14:34:39.497994Z","iopub.status.idle":"2023-05-14T14:34:41.139579Z","shell.execute_reply.started":"2023-05-14T14:34:39.497946Z","shell.execute_reply":"2023-05-14T14:34:41.138582Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/train/defog/4c3aa8ea6e.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:37:25.338423Z","iopub.execute_input":"2023-05-14T14:37:25.339318Z","iopub.status.idle":"2023-05-14T14:37:25.444593Z","shell.execute_reply.started":"2023-05-14T14:37:25.339267Z","shell.execute_reply":"2023-05-14T14:37:25.443262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:37:27.523148Z","iopub.execute_input":"2023-05-14T14:37:27.523586Z","iopub.status.idle":"2023-05-14T14:37:27.547411Z","shell.execute_reply.started":"2023-05-14T14:37:27.523551Z","shell.execute_reply":"2023-05-14T14:37:27.546535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[\"Valid\"].value_counts(), df[\"Task\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:37:45.801265Z","iopub.execute_input":"2023-05-14T14:37:45.801713Z","iopub.status.idle":"2023-05-14T14:37:45.816536Z","shell.execute_reply.started":"2023-05-14T14:37:45.801676Z","shell.execute_reply":"2023-05-14T14:37:45.815293Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Valid There were cases during the video annotation that were hard for the annotator to decide if there was an Akinetic \n# (i.e., essentially no movement) FoG or the subject stopped voluntarily. Only event annotations where the series is marked true should be considered as unambiguous. \n#Task Series were only annotated where this value is true. Portions marked false should be considered unannotated.\nvalid_df = df[df[\"Valid\"]== True]\nvalid_df","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:37:53.569028Z","iopub.execute_input":"2023-05-14T14:37:53.569517Z","iopub.status.idle":"2023-05-14T14:37:53.598147Z","shell.execute_reply.started":"2023-05-14T14:37:53.569475Z","shell.execute_reply":"2023-05-14T14:37:53.596770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"valid_df.reset_index(inplace = True, drop = True)\nvalid_df","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:38:02.115762Z","iopub.execute_input":"2023-05-14T14:38:02.116182Z","iopub.status.idle":"2023-05-14T14:38:02.137803Z","shell.execute_reply.started":"2023-05-14T14:38:02.116148Z","shell.execute_reply":"2023-05-14T14:38:02.136575Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(valid_df[\"Valid\"].value_counts(), valid_df[\"Task\"].value_counts())\n","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:38:59.947607Z","iopub.execute_input":"2023-05-14T14:38:59.948654Z","iopub.status.idle":"2023-05-14T14:38:59.957052Z","shell.execute_reply.started":"2023-05-14T14:38:59.948614Z","shell.execute_reply":"2023-05-14T14:38:59.955770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(valid_df[\"StartHesitation\"].value_counts(), valid_df[\"Turn\"].value_counts(), valid_df[\"Walking\"].value_counts())","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:39:02.092332Z","iopub.execute_input":"2023-05-14T14:39:02.093166Z","iopub.status.idle":"2023-05-14T14:39:02.104640Z","shell.execute_reply.started":"2023-05-14T14:39:02.093129Z","shell.execute_reply":"2023-05-14T14:39:02.103504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nfig = go.Figure()\nfig.add_trace(go.Scatter(x=valid_df.index,  y=valid_df.AccV, name='AccV'))\nfig.add_trace(go.Scatter(x=valid_df.index,  y=valid_df.AccML, name='AccML'))\nfig.add_trace(go.Scatter(x=valid_df.index,  y=valid_df.AccAP, name='AccAP'))\nfig.add_trace(go.Scatter(x=valid_df.index,  y=valid_df.StartHesitation.replace({0: -2, 1: 2}), name='StartHesitation',  mode='lines'))\nfig.add_trace(go.Scatter(x=valid_df.index,  y=valid_df.Turn.replace({0: -2, 1: 2}), name='Turn',  mode='lines'))\nfig.add_trace(go.Scatter(x=valid_df.index.to_list(),  y= valid_df.Walking.replace({0: -2, 1: 2}), mode='lines', name='Walking'))\n\n\n\n\nfig.update_layout(\n    title=\"Time series of accelerometer in defog dataset( after removal of Valid = False and Task =  False)\",\n    xaxis_title=\"time index\",\n    yaxis_title=\"Amplitude\"\n)\n\n\n\n# Display the Plotly figure\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:39:17.776540Z","iopub.execute_input":"2023-05-14T14:39:17.776957Z","iopub.status.idle":"2023-05-14T14:39:18.241143Z","shell.execute_reply.started":"2023-05-14T14:39:17.776922Z","shell.execute_reply":"2023-05-14T14:39:18.238059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# chweck if more than one indicator can be 1 at a time\n\nvalid_df[\"sum\"] = valid_df[\"StartHesitation\"] + valid_df[\"Turn\"] + valid_df[\"Walking\"]\nvalid_df[\"sum\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:39:29.241396Z","iopub.execute_input":"2023-05-14T14:39:29.241844Z","iopub.status.idle":"2023-05-14T14:39:29.256013Z","shell.execute_reply.started":"2023-05-14T14:39:29.241809Z","shell.execute_reply":"2023-05-14T14:39:29.254612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(data=valid_df[[ 'AccV', 'AccML', 'AccAP', 'StartHesitation']], hue='StartHesitation')","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:39:44.377898Z","iopub.execute_input":"2023-05-14T14:39:44.379147Z","iopub.status.idle":"2023-05-14T14:39:58.904546Z","shell.execute_reply.started":"2023-05-14T14:39:44.379098Z","shell.execute_reply":"2023-05-14T14:39:58.903102Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(data=valid_df[[ 'AccV', 'AccML', 'AccAP', 'Turn']], hue='Turn')","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:39:58.906445Z","iopub.execute_input":"2023-05-14T14:39:58.906902Z","iopub.status.idle":"2023-05-14T14:40:13.421872Z","shell.execute_reply.started":"2023-05-14T14:39:58.906866Z","shell.execute_reply":"2023-05-14T14:40:13.420647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.pairplot(data=valid_df[[ 'AccV', 'AccML', 'AccAP', 'Walking']], hue='Walking')","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:40:13.424212Z","iopub.execute_input":"2023-05-14T14:40:13.424585Z","iopub.status.idle":"2023-05-14T14:40:28.176916Z","shell.execute_reply.started":"2023-05-14T14:40:13.424552Z","shell.execute_reply":"2023-05-14T14:40:28.175585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nimport pandas as pd\n\n\ndf_melt = pd.melt(valid_df, id_vars=['Walking'], value_vars=['AccV', 'AccML', 'AccAP'],\n                  var_name='Value', value_name='Measurement')\n\nfig = px.box(df_melt, x='Walking', y='Measurement', color='Value')\nfig.update_layout(\n    title=\"Walking state (Valid) box plot for all threes sensor\",\n    xaxis_title=\"Walking state\",\n    yaxis_title=\"Amplitude\"\n)\n\n\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:40:28.179449Z","iopub.execute_input":"2023-05-14T14:40:28.182666Z","iopub.status.idle":"2023-05-14T14:40:30.057206Z","shell.execute_reply.started":"2023-05-14T14:40:28.182618Z","shell.execute_reply":"2023-05-14T14:40:30.055648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nimport pandas as pd\n\ndf_melt = pd.melt(valid_df, id_vars=['Turn'], value_vars=['AccV', 'AccML', 'AccAP'],\n                  var_name='Value', value_name='Measurement')\n\nfig = px.box(df_melt, x='Turn', y='Measurement', color='Value')\nfig.update_layout(\n    title=\"Turn state (Valid) box plot for all threes sensor\",\n    xaxis_title=\"Turn state\",\n    yaxis_title=\"Amplitude\"\n)\n\n\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:40:30.058688Z","iopub.execute_input":"2023-05-14T14:40:30.059090Z","iopub.status.idle":"2023-05-14T14:40:30.196712Z","shell.execute_reply.started":"2023-05-14T14:40:30.059056Z","shell.execute_reply":"2023-05-14T14:40:30.195331Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nimport pandas as pd\n\ndf_melt = pd.melt(valid_df, id_vars=['StartHesitation'], value_vars=['AccV', 'AccML', 'AccAP'],\n                  var_name='Value', value_name='Measurement')\n\nfig = px.box(df_melt, x='StartHesitation', y='Measurement', color='Value')\nfig.update_layout(\n    title=\"StartHesitation state (Valid) box plot for all threes sensor\",\n    xaxis_title=\"StartHesitation state\",\n    yaxis_title=\"Amplitude\"\n)\n\n\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2023-05-14T14:40:32.645068Z","iopub.execute_input":"2023-05-14T14:40:32.646147Z","iopub.status.idle":"2023-05-14T14:40:32.779438Z","shell.execute_reply.started":"2023-05-14T14:40:32.646111Z","shell.execute_reply":"2023-05-14T14:40:32.778227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}