{"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)\ninput_folder = \"/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction\"\nimport os","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-04-13T23:08:01.808751Z","iopub.execute_input":"2023-04-13T23:08:01.809290Z","iopub.status.idle":"2023-04-13T23:08:01.818194Z","shell.execute_reply.started":"2023-04-13T23:08:01.809236Z","shell.execute_reply":"2023-04-13T23:08:01.817244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_folders = [\n    os.path.join(input_folder, 'test', 'tdcsfog'),    \n    os.path.join(input_folder, 'test', 'defog'),\n]","metadata":{"execution":{"iopub.status.busy":"2023-04-13T23:08:01.820767Z","iopub.execute_input":"2023-04-13T23:08:01.821534Z","iopub.status.idle":"2023-04-13T23:08:01.830045Z","shell.execute_reply.started":"2023-04-13T23:08:01.821492Z","shell.execute_reply":"2023-04-13T23:08:01.828941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_list = []\nfor folder in test_folders:\n    for fn in os.listdir(folder):\n        series_id = fn.split('.')[0]\n        series = pd.read_csv(os.path.join(folder, fn))\n        series['Id'] = series['Time'].apply(lambda time: f\"{series_id}_{time}\")\n        series['StartHesitation'] = 0\n        series['Turn'] = 0\n        series['Walking'] = 0\n        submission_list.append(series[['Id', 'StartHesitation', 'Turn', 'Walking']])\n        ","metadata":{"execution":{"iopub.status.busy":"2023-04-13T23:08:01.831737Z","iopub.execute_input":"2023-04-13T23:08:01.832883Z","iopub.status.idle":"2023-04-13T23:08:02.631378Z","shell.execute_reply.started":"2023-04-13T23:08:01.832838Z","shell.execute_reply":"2023-04-13T23:08:02.630200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.concat(submission_list).reset_index(drop=True)","metadata":{"execution":{"iopub.status.busy":"2023-04-13T23:08:02.632997Z","iopub.execute_input":"2023-04-13T23:08:02.633668Z","iopub.status.idle":"2023-04-13T23:08:02.667813Z","shell.execute_reply.started":"2023-04-13T23:08:02.633627Z","shell.execute_reply":"2023-04-13T23:08:02.666500Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2023-04-13T23:08:02.670583Z","iopub.execute_input":"2023-04-13T23:08:02.671045Z","iopub.status.idle":"2023-04-13T23:08:03.110638Z","shell.execute_reply.started":"2023-04-13T23:08:02.670999Z","shell.execute_reply":"2023-04-13T23:08:03.109409Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.head(n=100)","metadata":{"execution":{"iopub.status.busy":"2023-04-13T23:09:19.563309Z","iopub.execute_input":"2023-04-13T23:09:19.563808Z","iopub.status.idle":"2023-04-13T23:09:19.579725Z","shell.execute_reply.started":"2023-04-13T23:09:19.563756Z","shell.execute_reply":"2023-04-13T23:09:19.578266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}