{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":41880,"databundleVersionId":5677426,"sourceType":"competition"}],"dockerImageVersionId":30646,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"\nimport os\nimport numpy as np \nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport glob\nfrom math import sqrt\n\nfrom sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score\nfrom sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay\nfrom sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.svm import SVC\n\n\nimport lightgbm as lgb\nfrom lightgbm import LGBMClassifier\nfrom sklearn.metrics import roc_auc_score as ras \nfrom imblearn.over_sampling import SMOTE\nfrom sklearn.preprocessing import LabelEncoder\nimport itertools\nfrom itertools import *","metadata":{"_uuid":"e2ac1a83-29c4-4e73-927f-258f529f6655","_cell_guid":"bd1e9284-3a87-4f3e-bfea-3cc66bacab28","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:09:02.482036Z","iopub.execute_input":"2024-03-07T20:09:02.482721Z","iopub.status.idle":"2024-03-07T20:09:10.174951Z","shell.execute_reply.started":"2024-03-07T20:09:02.482678Z","shell.execute_reply":"2024-03-07T20:09:10.174135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATA_ROOT_DEFOG = '/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/train/defog/'\ndefog = pd.DataFrame()\nfor root, dirs, files in os.walk(DATA_ROOT_DEFOG):\n    for name in files:       \n        f = os.path.join(root, name)\n        df_list= pd.read_csv(f)\n        words = name.split('.')[0]\n        df_list['file']= name.split('.')[0]\n        defog = pd.concat([defog, df_list], axis=0)\n        \nkeys = np.arange(len(defog))\ndefog = defog.set_index(keys, drop=True, append=False, inplace=False, verify_integrity=True)\ndefog","metadata":{"_uuid":"264512f1-e7d0-4972-99f6-a61d822615ce","_cell_guid":"b0dffe7a-613d-4572-b05a-8d94d0c1a0dc","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:09:10.176818Z","iopub.execute_input":"2024-03-07T20:09:10.177405Z","iopub.status.idle":"2024-03-07T20:10:01.680288Z","shell.execute_reply.started":"2024-03-07T20:09:10.177378Z","shell.execute_reply":"2024-03-07T20:10:01.679300Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defog = defog.drop(['Valid','Task'], axis = 1)\ndefog","metadata":{"_uuid":"38246831-fb1e-4608-989a-7e096f27ec08","_cell_guid":"edaf3c88-53ae-42a4-b3d1-740f98ec6875","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:01.681342Z","iopub.execute_input":"2024-03-07T20:10:01.681596Z","iopub.status.idle":"2024-03-07T20:10:02.133507Z","shell.execute_reply.started":"2024-03-07T20:10:01.681575Z","shell.execute_reply":"2024-03-07T20:10:02.132656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defog['IsFOG'] = defog[['StartHesitation', 'Walking','Turn']].any(axis='columns')\nprint('\\n', defog[['Time','StartHesitation', 'Walking','Turn', 'IsFOG']][1047890:1071070])","metadata":{"_uuid":"45fb81a6-4fc7-4aa3-8c6f-651dee861c68","_cell_guid":"a58b1bbe-9425-49a2-bbcc-9aa8f9be4529","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:02.136269Z","iopub.execute_input":"2024-03-07T20:10:02.136894Z","iopub.status.idle":"2024-03-07T20:10:02.473780Z","shell.execute_reply.started":"2024-03-07T20:10:02.136857Z","shell.execute_reply":"2024-03-07T20:10:02.472776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# making sure there are no missing values:\nprint(len(defog['IsFOG'][defog['IsFOG']==0])+len(defog['IsFOG'][defog['IsFOG']==1]))\n\n# defining the beginings of each file/subj (defog has 91 files):\nsubj_start = (defog['Time'][defog['Time']==0])\nsubj_start_ind = np.array(subj_start.index)\nprint(len(subj_start_ind))\n# defining the ends of each file/subj (doesn't include the last one):\nsubj_end_ind = subj_start_ind[1:] - 1\nprint(len(subj_end_ind))\n\nprint('FOG event at head of subject number: ', np.where(defog['IsFOG'][subj_start_ind]==1))\n\nprint('FOG event at tail of subject number: ',np.where(defog['IsFOG'][subj_end_ind]==1))","metadata":{"_uuid":"abc413a1-a83b-4c51-91d0-60ef504e2d0c","_cell_guid":"671c6367-4711-43c6-a4fb-49f49fe41f0b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:02.474956Z","iopub.execute_input":"2024-03-07T20:10:02.475281Z","iopub.status.idle":"2024-03-07T20:10:03.672838Z","shell.execute_reply.started":"2024-03-07T20:10:02.475254Z","shell.execute_reply":"2024-03-07T20:10:03.671900Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"identify fogs","metadata":{"_uuid":"828f4bb9-125f-48d3-8dbf-455393393e6e","_cell_guid":"286b02e5-ad9b-477c-b851-0a6a095eed6b","trusted":true}},{"cell_type":"code","source":"x = defog[['AccV','AccML','AccAP']]\ny = defog['IsFOG']","metadata":{"_uuid":"7e12e8e3-d1c8-48c5-8be2-4526c1a1430e","_cell_guid":"c36cee36-9f77-47fb-8e6c-d3a92c6cf44d","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:03.674403Z","iopub.execute_input":"2024-03-07T20:10:03.675359Z","iopub.status.idle":"2024-03-07T20:10:03.780684Z","shell.execute_reply.started":"2024-03-07T20:10:03.675322Z","shell.execute_reply":"2024-03-07T20:10:03.779760Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = defog['IsFOG']","metadata":{"_uuid":"25c79b13-439a-46a8-bf5f-2ae696da755b","_cell_guid":"0100255e-a503-49f1-8960-026221c43138","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:03.782015Z","iopub.execute_input":"2024-03-07T20:10:03.782389Z","iopub.status.idle":"2024-03-07T20:10:03.787031Z","shell.execute_reply.started":"2024-03-07T20:10:03.782354Z","shell.execute_reply":"2024-03-07T20:10:03.786034Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, Y_train, Y_test_defog = train_test_split(x, y, test_size = 0.1, random_state = 1 )","metadata":{"_uuid":"cc030946-f31a-4d4e-9c06-ef7528ef215e","_cell_guid":"7d059e0e-ae05-4708-93dd-63666d8ea41b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:03.788204Z","iopub.execute_input":"2024-03-07T20:10:03.788558Z","iopub.status.idle":"2024-03-07T20:10:05.548666Z","shell.execute_reply.started":"2024-03-07T20:10:03.788522Z","shell.execute_reply":"2024-03-07T20:10:05.547734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create LightGBM Datasets for training and validation \nx_train, x_val, y_train, y_val = train_test_split(X_train, Y_train, test_size = 0.1, random_state = 2 )\n\ntrain_data = lgb.Dataset(x_train, label=y_train) \ntest_data = lgb.Dataset(x_val, label=y_val, reference=train_data)  \n\n# Define hyperparameters and objective for LightGBM \nfog_params={\n    'objective': 'binary', #binary target feature\n    'metric': 'auc', \n    'boosting_type': 'gbdt',  #GradientBoostingDecisionTree\n    'learning_rate': 0.03,  \n    'verbose': 1,\n    'max_depth': 6,\n    'num_leaves': 50\n}","metadata":{"_uuid":"bdc7190a-8c9c-4eb0-b0a9-c91221a9d520","_cell_guid":"8ff14dd2-b40d-4b0b-badd-8838c1b432e3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:05.550228Z","iopub.execute_input":"2024-03-07T20:10:05.550695Z","iopub.status.idle":"2024-03-07T20:10:07.075669Z","shell.execute_reply.started":"2024-03-07T20:10:05.550666Z","shell.execute_reply":"2024-03-07T20:10:07.074896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Training a LightGBM Model \nnum_round = 200\n\n\n# Train a LightGBM model using defined parameters, training data, and specified number of rounds \nfog_model = lgb.train(fog_params, train_data, \n                  num_round, valid_sets=[test_data])","metadata":{"_uuid":"97ee7bfe-6e0d-40d2-abb5-0475db7415ea","_cell_guid":"d290302a-b5e2-4698-9706-1340c45b1f19","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:10:07.079082Z","iopub.execute_input":"2024-03-07T20:10:07.079379Z","iopub.status.idle":"2024-03-07T20:11:37.635509Z","shell.execute_reply.started":"2024-03-07T20:10:07.079356Z","shell.execute_reply":"2024-03-07T20:11:37.634629Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train_pred_defog = fog_model.predict(x_train)\ny_val_pred_defog = fog_model.predict(x_val)\ny_test_pred_defog = fog_model.predict(X_test)","metadata":{"_uuid":"70d4ef7c-8bc7-49d1-93ce-3a195afdb1b3","_cell_guid":"9bb9cc23-7c1c-4dc5-8660-3681bece6484","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:11:37.639449Z","iopub.execute_input":"2024-03-07T20:11:37.639742Z","iopub.status.idle":"2024-03-07T20:12:25.510872Z","shell.execute_reply.started":"2024-03-07T20:11:37.639711Z","shell.execute_reply":"2024-03-07T20:12:25.510062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Calculate and print the ROC-AUC scores\nprint(\"Training ROC-AUC: \", ras(y_train, y_train_pred_defog))\nprint(\"Validation ROC-AUC: \", ras(y_val, y_val_pred_defog)) \nprint(\"Test ROC-AUC: \", ras(Y_test_defog, y_test_pred_defog))","metadata":{"_uuid":"59d5118d-11c4-41c4-9b08-c12180616829","_cell_guid":"f2d16115-f61d-455e-83ec-c29da62f7d2b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:25.512122Z","iopub.execute_input":"2024-03-07T20:12:25.515154Z","iopub.status.idle":"2024-03-07T20:12:32.501287Z","shell.execute_reply.started":"2024-03-07T20:12:25.515122Z","shell.execute_reply":"2024-03-07T20:12:32.500329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"secondary model","metadata":{"_uuid":"cfb7a606-fef9-4d39-9955-69cbd52776fc","_cell_guid":"8592fc13-e114-4aba-9c83-731928ce356c","trusted":true}},{"cell_type":"code","source":"# Adding additional features for each axis:\n# - rolling mean\n# - rolling standard deviation\n# - rolling maximum\n# - rolling minimum\n\nwindow_size = 200  # 2 seconds window for 100Hz sampling rate\n\n# Calculating rolling window features for each acceleration axis\nfor axis in ['AccV', 'AccML', 'AccAP']:\n    defog[f'{axis}_rolling_mean'] = defog[axis].rolling(window=window_size, min_periods=1).mean()\n    defog[f'{axis}_rolling_std'] = defog[axis].rolling(window=window_size, min_periods=1).std()\n    defog[f'{axis}_rolling_max'] = defog[axis].rolling(window=window_size, min_periods=1).max()\n    defog[f'{axis}_rolling_min'] = defog[axis].rolling(window=window_size, min_periods=1).min()\n\n# Drop rows that have NaN values which might be introduced by rolling window calculations\ndefog.dropna(inplace=True)","metadata":{"_uuid":"6278c898-e85f-435b-873e-fc10891d4d10","_cell_guid":"f42ea01e-3ed7-499d-b0ee-006020b05304","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:32.502674Z","iopub.execute_input":"2024-03-07T20:12:32.502928Z","iopub.status.idle":"2024-03-07T20:12:41.547426Z","shell.execute_reply.started":"2024-03-07T20:12:32.502905Z","shell.execute_reply":"2024-03-07T20:12:41.546468Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"defog2 = defog[defog['IsFOG'] == True]\ndefog2","metadata":{"_uuid":"ce981bc7-6a5c-4f38-83e3-b8c3a4797dd6","_cell_guid":"e6320676-e7d8-47d0-a804-5909fc430a98","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:41.548685Z","iopub.execute_input":"2024-03-07T20:12:41.549034Z","iopub.status.idle":"2024-03-07T20:12:41.998287Z","shell.execute_reply.started":"2024-03-07T20:12:41.549006Z","shell.execute_reply":"2024-03-07T20:12:41.997121Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Updating feature selection with rolling window features\nfeature_columns = ['AccV', 'AccML', 'AccAP', \n                   'AccV_rolling_mean', 'AccV_rolling_std', 'AccV_rolling_max', 'AccV_rolling_min',\n                   'AccML_rolling_mean', 'AccML_rolling_std', 'AccML_rolling_max', 'AccML_rolling_min',\n                   'AccAP_rolling_mean', 'AccAP_rolling_std', 'AccAP_rolling_max', 'AccAP_rolling_min']\n\nX = defog2[feature_columns]","metadata":{"_uuid":"6ad59bd4-4596-4357-b9f1-b01849df9a7d","_cell_guid":"137fd2b2-ec3b-4868-bef2-a0962cc1a5cc","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:41.999554Z","iopub.execute_input":"2024-03-07T20:12:41.999900Z","iopub.status.idle":"2024-03-07T20:12:42.054695Z","shell.execute_reply.started":"2024-03-07T20:12:41.999870Z","shell.execute_reply":"2024-03-07T20:12:42.053733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# targets\ny_StartHesitation = defog2['StartHesitation']\ny_Turn = defog2['Turn']\ny_Walking = defog2['Walking']","metadata":{"_uuid":"a658fbd8-0cf2-433a-a740-b85d09fd5d09","_cell_guid":"f358ed2f-0bda-49f0-b1f9-245db6087551","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:42.055878Z","iopub.execute_input":"2024-03-07T20:12:42.056189Z","iopub.status.idle":"2024-03-07T20:12:42.060883Z","shell.execute_reply.started":"2024-03-07T20:12:42.056164Z","shell.execute_reply":"2024-03-07T20:12:42.060026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def apply_smote(X, y):\n    smote = SMOTE(random_state=42)\n    X_smote, y_smote = smote.fit_resample(X, y)\n    return X_smote, y_smote","metadata":{"_uuid":"71cb391f-27e9-4ce7-9d26-83dc347bb0f9","_cell_guid":"a9ae007d-fd72-46d0-a6c6-c7d82e9c44e3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:42.062165Z","iopub.execute_input":"2024-03-07T20:12:42.062810Z","iopub.status.idle":"2024-03-07T20:12:42.074797Z","shell.execute_reply.started":"2024-03-07T20:12:42.062777Z","shell.execute_reply":"2024-03-07T20:12:42.074119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Splitting the data into training and testing sets for each target variable\nX_train, X_test_defog, y_train_StartHesitation, y_test_StartHesitation = train_test_split(X, y_StartHesitation, test_size=0.2, random_state=42)\n_, _, y_train_Turn, y_test_Turn = train_test_split(X, y_Turn, test_size=0.2, random_state=42)\n_, _, y_train_Walking, y_test_Walking = train_test_split(X, y_Walking, test_size=0.2, random_state=42)","metadata":{"_uuid":"3a5b1c64-152a-440b-846b-0a519f2d9c27","_cell_guid":"22e1cc44-2c18-475c-97eb-95afd5c6a5d9","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:42.075854Z","iopub.execute_input":"2024-03-07T20:12:42.076118Z","iopub.status.idle":"2024-03-07T20:12:42.554357Z","shell.execute_reply.started":"2024-03-07T20:12:42.076097Z","shell.execute_reply":"2024-03-07T20:12:42.553560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# SMOTE to the training data for each target variable\nX_train_smote_StartHesitation, y_train_smote_StartHesitation = apply_smote(X_train, y_train_StartHesitation)\nX_train_smote_Turn, y_train_smote_Turn = apply_smote(X_train, y_train_Turn)\nX_train_smote_Walking, y_train_smote_Walking = apply_smote(X_train, y_train_Walking)","metadata":{"_uuid":"50793646-c27a-49cd-993a-a66b22fb9403","_cell_guid":"692f434e-2d37-476b-a9b8-bec2e9b2575b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:42.555466Z","iopub.execute_input":"2024-03-07T20:12:42.555751Z","iopub.status.idle":"2024-03-07T20:12:55.814256Z","shell.execute_reply.started":"2024-03-07T20:12:42.555727Z","shell.execute_reply":"2024-03-07T20:12:55.813439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define hyperparameters and objective for LightGBM\nparams = {\n    'objective': 'binary',\n    'metric': 'auc',\n    'boosting_type': 'gbdt',\n    'learning_rate': 0.03,\n    'verbose': 1,\n    'max_depth': 6,\n    'num_leaves': 50,\n}\n\nnum_round = 200","metadata":{"_uuid":"e2d6f8bb-146d-4abb-bcf9-8f5cede4b2bd","_cell_guid":"093b7498-bdec-4572-887e-5dc5f5d43c8a","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:55.815495Z","iopub.execute_input":"2024-03-07T20:12:55.816138Z","iopub.status.idle":"2024-03-07T20:12:55.821009Z","shell.execute_reply.started":"2024-03-07T20:12:55.816104Z","shell.execute_reply":"2024-03-07T20:12:55.820143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preparing LightGBM datasets for StartHesitation\ntrain_data_StartHesitation = lgb.Dataset(X_train_smote_StartHesitation, label=y_train_smote_StartHesitation)\ntest_data_StartHesitation = lgb.Dataset(X_test_defog, label=y_test_StartHesitation, reference=train_data_StartHesitation)\n\n# Training a LightGBM model for StartHesitation\nmodel_StartHesitation = lgb.train(params, train_data_StartHesitation, num_round, valid_sets=[test_data_StartHesitation])","metadata":{"_uuid":"20e1a3d9-b566-4782-96d5-bbc627f343c8","_cell_guid":"ab75c072-1bc2-4a80-a72c-28eabda2bbd3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:12:55.822300Z","iopub.execute_input":"2024-03-07T20:12:55.822626Z","iopub.status.idle":"2024-03-07T20:13:12.660403Z","shell.execute_reply.started":"2024-03-07T20:12:55.822596Z","shell.execute_reply":"2024-03-07T20:13:12.659458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preparing LightGBM datasets for Turn\ntrain_data_Turn = lgb.Dataset(X_train_smote_Turn, label=y_train_smote_Turn)\ntest_data_Turn = lgb.Dataset(X_test_defog, label=y_test_Turn, reference=train_data_Turn)\n\n# Training a LightGBM model for Turn\nmodel_Turn = lgb.train(params, train_data_Turn, num_round, valid_sets=[test_data_Turn])","metadata":{"_uuid":"aa4678fa-29f5-43a9-a881-19cfae383e19","_cell_guid":"00185370-d999-4c95-af4e-88a5e2e344ad","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:13:12.664782Z","iopub.execute_input":"2024-03-07T20:13:12.667278Z","iopub.status.idle":"2024-03-07T20:13:27.992441Z","shell.execute_reply.started":"2024-03-07T20:13:12.667245Z","shell.execute_reply":"2024-03-07T20:13:27.991613Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preparing LightGBM datasets for Walking\ntrain_data_Walking = lgb.Dataset(X_train_smote_Walking, label=y_train_smote_Walking)\ntest_data_Walking = lgb.Dataset(X_test_defog, label=y_test_Walking, reference=train_data_Walking)\n\n# Training a LightGBM model for Walking\nmodel_Walking = lgb.train(params, train_data_Walking, num_round, valid_sets=[test_data_Walking])","metadata":{"_uuid":"e8ed5ea1-6551-4f29-899c-641c07b40a49","_cell_guid":"152a1e93-9b06-4428-a13e-38bef6c717b4","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:13:27.996526Z","iopub.execute_input":"2024-03-07T20:13:27.998424Z","iopub.status.idle":"2024-03-07T20:13:44.193090Z","shell.execute_reply.started":"2024-03-07T20:13:27.998394Z","shell.execute_reply":"2024-03-07T20:13:44.192296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Predicting and evaluating each model\ny_pred_StartHesitation = model_StartHesitation.predict(X_test_defog)\nroc_auc_StartHesitation = roc_auc_score(y_test_StartHesitation, y_pred_StartHesitation)\n\ny_pred_Turn = model_Turn.predict(X_test_defog)\nroc_auc_Turn = roc_auc_score(y_test_Turn, y_pred_Turn)\n\ny_pred_Walking = model_Walking.predict(X_test_defog)\nroc_auc_Walking = roc_auc_score(y_test_Walking, y_pred_Walking)","metadata":{"_uuid":"8d96658f-fc23-456e-93ce-d8fa88921e50","_cell_guid":"3ea88498-c78d-4b32-9194-b4292832b442","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:13:44.194360Z","iopub.execute_input":"2024-03-07T20:13:44.194908Z","iopub.status.idle":"2024-03-07T20:13:45.923113Z","shell.execute_reply.started":"2024-03-07T20:13:44.194879Z","shell.execute_reply":"2024-03-07T20:13:45.922124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Print ROC AUC scores\nprint(f\"ROC AUC for StartHesitation: {roc_auc_StartHesitation}\")\nprint(f\"ROC AUC for Turn: {roc_auc_Turn}\")\nprint(f\"ROC AUC for Walking: {roc_auc_Walking}\")","metadata":{"_uuid":"cccd193f-5648-4274-8325-1d1febc789fe","_cell_guid":"8e39bf1b-856b-44ca-9988-6ad4fdf455d4","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:13:45.924279Z","iopub.execute_input":"2024-03-07T20:13:45.924544Z","iopub.status.idle":"2024-03-07T20:13:45.929671Z","shell.execute_reply.started":"2024-03-07T20:13:45.924522Z","shell.execute_reply":"2024-03-07T20:13:45.928849Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"TDCS MODEL","metadata":{"_uuid":"92d334b3-383b-4ebf-8999-e99bbed398ef","_cell_guid":"d0d470cd-6eed-497d-8d8a-ed36e061a775","trusted":true}},{"cell_type":"code","source":"# separate lgbm, will merge later \n\nDATA_ROOT_TDCSFOG = '/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/train/tdcsfog/'\ntdcsfog = pd.DataFrame()\nfor root, dirs, files in os.walk(DATA_ROOT_TDCSFOG):\n    for name in files:       \n        f = os.path.join(root, name)\n        df_list= pd.read_csv(f)\n        words = name.split('.')[0]\n        df_list['file']= name.split('.')[0]\n        tdcsfog = pd.concat([tdcsfog, df_list], axis=0)\n        \nkeys = np.arange(len(tdcsfog))\ntdcsfog = tdcsfog.set_index(keys, drop=True, append=False, inplace=False, verify_integrity=True)\ntdcsfog","metadata":{"_uuid":"6ebd3d26-7086-4568-9d5a-473244d543bf","_cell_guid":"64e35d3a-87ef-4119-8cee-ce1015180cae","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:13:45.930727Z","iopub.execute_input":"2024-03-07T20:13:45.931010Z","iopub.status.idle":"2024-03-07T20:15:58.655366Z","shell.execute_reply.started":"2024-03-07T20:13:45.930979Z","shell.execute_reply":"2024-03-07T20:15:58.654385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfog['IsFOG'] = tdcsfog[['StartHesitation', 'Walking','Turn']].any(axis='columns')\nprint('\\n', tdcsfog[['Time','StartHesitation', 'Walking','Turn', 'IsFOG']][1047890:1071070])\n# making sure there are no missing values:\nprint(len(tdcsfog['IsFOG'][tdcsfog['IsFOG']==0])+len(tdcsfog['IsFOG'][tdcsfog['IsFOG']==1]))\n\n# defining the beginings of each file/subj (defog has 91 files):\nsubj_start = (tdcsfog['Time'][tdcsfog['Time']==0])\nsubj_start_ind = np.array(subj_start.index)\nprint(len(subj_start_ind))\n# defining the ends of each file/subj (doesn't include the last one):\nsubj_end_ind = subj_start_ind[1:] - 1\nprint(len(subj_end_ind))\n\nprint('FOG event at head of subject number: ', np.where(tdcsfog['IsFOG'][subj_start_ind]==1))\n\nprint('FOG event at tail of subject number: ',np.where(tdcsfog['IsFOG'][subj_end_ind]==1))","metadata":{"_uuid":"662abc2c-a36e-4f76-81b8-55b576ddb760","_cell_guid":"690a1533-55c9-4717-8cf9-dd51c4462057","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:15:58.656637Z","iopub.execute_input":"2024-03-07T20:15:58.656913Z","iopub.status.idle":"2024-03-07T20:15:59.352868Z","shell.execute_reply.started":"2024-03-07T20:15:58.656888Z","shell.execute_reply":"2024-03-07T20:15:59.351946Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = tdcsfog[['AccV','AccML','AccAP']]\ny = tdcsfog['IsFOG']","metadata":{"_uuid":"ec2e104e-c6b8-4c24-afef-60bb7fbaf909","_cell_guid":"812a193c-2988-4c14-b426-9c5cab58aa45","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:15:59.360938Z","iopub.execute_input":"2024-03-07T20:15:59.361235Z","iopub.status.idle":"2024-03-07T20:15:59.419752Z","shell.execute_reply.started":"2024-03-07T20:15:59.361211Z","shell.execute_reply":"2024-03-07T20:15:59.418945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, Y_train, Y_test_tdcs = train_test_split(x, y, test_size = 0.1, random_state = 1 )","metadata":{"_uuid":"06a5b0b8-520f-4308-9fd6-c0157a7b6c7e","_cell_guid":"059049ab-d1f5-41bc-bd2f-945744c62319","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:15:59.421153Z","iopub.execute_input":"2024-03-07T20:15:59.422050Z","iopub.status.idle":"2024-03-07T20:16:00.231646Z","shell.execute_reply.started":"2024-03-07T20:15:59.422012Z","shell.execute_reply":"2024-03-07T20:16:00.230840Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create LightGBM Datasets for training and validation \nx_train, x_val, y_train, y_val = train_test_split(X_train, Y_train, test_size = 0.1, random_state = 2 )\n\ntrain_data = lgb.Dataset(x_train, label=y_train) \ntest_data = lgb.Dataset(x_val, label=y_val, reference=train_data)  \n\n# Define hyperparameters and objective for LightGBM \nfog_params={\n    'objective': 'binary', #binary target feature\n    'metric': 'auc', \n    'boosting_type': 'gbdt',  #GradientBoostingDecisionTree\n    'learning_rate': 0.03,  \n    'verbose': 1,\n    'max_depth': 6,\n    'num_leaves': 50\n}","metadata":{"_uuid":"eb29d290-c44e-42ee-982b-ff1f0107302f","_cell_guid":"b2929dcd-701d-4e93-a22f-45d1eb51c6b4","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:16:00.232797Z","iopub.execute_input":"2024-03-07T20:16:00.233116Z","iopub.status.idle":"2024-03-07T20:16:00.944174Z","shell.execute_reply.started":"2024-03-07T20:16:00.233090Z","shell.execute_reply":"2024-03-07T20:16:00.943355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Training a LightGBM Model \nnum_round = 200\n\n\n# Train a LightGBM model using defined parameters, training data, and specified number of rounds \ntdcsfog_model = lgb.train(fog_params, train_data, \n                  num_round, valid_sets=[test_data])","metadata":{"_uuid":"12b9469b-aeca-4276-a66a-025f9e37c018","_cell_guid":"e6d32d7c-eae7-45a1-9f97-97a418ce6a58","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:16:00.945334Z","iopub.execute_input":"2024-03-07T20:16:00.945628Z","iopub.status.idle":"2024-03-07T20:16:46.995174Z","shell.execute_reply.started":"2024-03-07T20:16:00.945603Z","shell.execute_reply":"2024-03-07T20:16:46.994342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train_pred_tdcs = tdcsfog_model.predict(x_train)\ny_val_pred_tdcs = tdcsfog_model.predict(x_val)\ny_test_pred_tdcs = tdcsfog_model.predict(X_test)","metadata":{"_uuid":"7e48ef85-e58f-4006-a00b-efd80ea2f183","_cell_guid":"49bed59c-e8c3-4f79-bd8a-10882af27ccb","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:16:46.996470Z","iopub.execute_input":"2024-03-07T20:16:46.997051Z","iopub.status.idle":"2024-03-07T20:17:13.501632Z","shell.execute_reply.started":"2024-03-07T20:16:46.997022Z","shell.execute_reply":"2024-03-07T20:17:13.500828Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nprint(\"Training ROC-AUC: \", ras(y_train, y_train_pred_tdcs))\nprint(\"Validation ROC-AUC: \", ras(y_val, y_val_pred_tdcs)) \nprint(\"Test ROC-AUC: \", ras(Y_test_tdcs,y_test_pred_tdcs))","metadata":{"_uuid":"259a1cf7-827b-4f58-bf1b-612e7b06d3b5","_cell_guid":"bd375c8d-f7bd-43d1-b2b3-ea8f76cf3161","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:13.502630Z","iopub.execute_input":"2024-03-07T20:17:13.503086Z","iopub.status.idle":"2024-03-07T20:17:15.851732Z","shell.execute_reply.started":"2024-03-07T20:17:13.503061Z","shell.execute_reply":"2024-03-07T20:17:15.850756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"second model tdcs","metadata":{"_uuid":"c1014831-3744-4ac3-b9f6-8f84ba1e9d03","_cell_guid":"06596113-84ae-4db0-9b0b-dd57b882c185","trusted":true}},{"cell_type":"code","source":"window_size = 200  # 2 seconds window for 100Hz sampling rate\n\n# Calculating rolling window features for each acceleration axis\nfor axis in ['AccV', 'AccML', 'AccAP']:\n    tdcsfog[f'{axis}_rolling_mean'] = tdcsfog[axis].rolling(window=window_size, min_periods=1).mean()\n    tdcsfog[f'{axis}_rolling_std'] = tdcsfog[axis].rolling(window=window_size, min_periods=1).std()\n    tdcsfog[f'{axis}_rolling_max'] = tdcsfog[axis].rolling(window=window_size, min_periods=1).max()\n    tdcsfog[f'{axis}_rolling_min'] = tdcsfog[axis].rolling(window=window_size, min_periods=1).min()\n\n# Drop rows that have NaN values which might be introduced by rolling window calculations\ntdcsfog.dropna(inplace=True)","metadata":{"_uuid":"b164f50f-a8cb-4d20-a4ba-279c4ed61c96","_cell_guid":"1139fbb5-e589-4aa4-8f53-b2e899c8df44","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:15.852833Z","iopub.execute_input":"2024-03-07T20:17:15.853109Z","iopub.status.idle":"2024-03-07T20:17:20.542860Z","shell.execute_reply.started":"2024-03-07T20:17:15.853085Z","shell.execute_reply":"2024-03-07T20:17:20.542078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdcsfog2 = tdcsfog[tdcsfog['IsFOG'] == True]\ntdcsfog2","metadata":{"_uuid":"a9dfcca0-62df-46fe-97b2-a2e0b5ccc95b","_cell_guid":"5b44347a-9509-48ab-8c0a-cc320ce17801","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:20.543952Z","iopub.execute_input":"2024-03-07T20:17:20.544293Z","iopub.status.idle":"2024-03-07T20:17:21.881247Z","shell.execute_reply.started":"2024-03-07T20:17:20.544249Z","shell.execute_reply":"2024-03-07T20:17:21.880211Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Updating feature selection with rolling window features\nfeature_columns = ['AccV', 'AccML', 'AccAP', \n                   'AccV_rolling_mean', 'AccV_rolling_std', 'AccV_rolling_max', 'AccV_rolling_min',\n                   'AccML_rolling_mean', 'AccML_rolling_std', 'AccML_rolling_max', 'AccML_rolling_min',\n                   'AccAP_rolling_mean', 'AccAP_rolling_std', 'AccAP_rolling_max', 'AccAP_rolling_min']\n\nX = tdcsfog2[feature_columns]\n\n# targets\ny_StartHesitation = tdcsfog2['StartHesitation']\ny_Turn = tdcsfog2['Turn']\ny_Walking = tdcsfog2['Walking']","metadata":{"_uuid":"f80182d7-da0e-485f-9f5e-36466672546b","_cell_guid":"2b1d4170-89ed-4b74-a80d-8338df8cb9ea","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:21.882388Z","iopub.execute_input":"2024-03-07T20:17:21.882650Z","iopub.status.idle":"2024-03-07T20:17:22.020708Z","shell.execute_reply.started":"2024-03-07T20:17:21.882628Z","shell.execute_reply":"2024-03-07T20:17:22.019947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def apply_smote(X, y):\n    smote = SMOTE(random_state=42)\n    X_smote, y_smote = smote.fit_resample(X, y)\n    return X_smote, y_smote","metadata":{"_uuid":"714e6c0f-8ea5-439d-a162-71414f01d139","_cell_guid":"45c15613-9cf2-45a1-8b53-049ff5bebf5b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:22.021737Z","iopub.execute_input":"2024-03-07T20:17:22.022025Z","iopub.status.idle":"2024-03-07T20:17:22.026595Z","shell.execute_reply.started":"2024-03-07T20:17:22.021990Z","shell.execute_reply":"2024-03-07T20:17:22.025745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Splitting the data into training and testing sets for each target variable\nX_train, X_test_tdcs, y_train_StartHesitation, y_test_StartHesitation = train_test_split(X, y_StartHesitation, test_size=0.2, random_state=42)\n_, _, y_train_Turn, y_test_Turn = train_test_split(X, y_Turn, test_size=0.2, random_state=42)\n_, _, y_train_Walking, y_test_Walking = train_test_split(X, y_Walking, test_size=0.2, random_state=42)","metadata":{"_uuid":"332b89a3-d571-49a4-92dd-91da1145c0f9","_cell_guid":"896e063d-344b-42ae-8909-21c4b82312d3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:22.027923Z","iopub.execute_input":"2024-03-07T20:17:22.028276Z","iopub.status.idle":"2024-03-07T20:17:23.655653Z","shell.execute_reply.started":"2024-03-07T20:17:22.028245Z","shell.execute_reply":"2024-03-07T20:17:23.654563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# SMOTE to the training data for each target variable\nX_train_smote_StartHesitation, y_train_smote_StartHesitation = apply_smote(X_train, y_train_StartHesitation)\nX_train_smote_Turn, y_train_smote_Turn = apply_smote(X_train, y_train_Turn)\nX_train_smote_Walking, y_train_smote_Walking = apply_smote(X_train, y_train_Walking)","metadata":{"_uuid":"ead47760-1cde-4945-b6a1-d415bc64fe89","_cell_guid":"66e526ec-3be2-4bee-a2eb-4cfc251bbeb3","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:17:23.656948Z","iopub.execute_input":"2024-03-07T20:17:23.657252Z","iopub.status.idle":"2024-03-07T20:19:39.250344Z","shell.execute_reply.started":"2024-03-07T20:17:23.657227Z","shell.execute_reply":"2024-03-07T20:19:39.249539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Define hyperparameters and objective for LightGBM\nparams = {\n    'objective': 'binary',\n    'metric': 'auc',\n    'boosting_type': 'gbdt',\n    'learning_rate': 0.03,\n    'verbose': 1,\n    'max_depth': 6,\n    'num_leaves': 50,\n}\n\nnum_round = 200","metadata":{"_uuid":"69ef8f69-55a4-45cf-a7a6-f46d914f1528","_cell_guid":"ef1a0927-9485-4da2-a263-1bfffef531f4","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:19:39.251429Z","iopub.execute_input":"2024-03-07T20:19:39.251713Z","iopub.status.idle":"2024-03-07T20:19:39.256375Z","shell.execute_reply.started":"2024-03-07T20:19:39.251688Z","shell.execute_reply":"2024-03-07T20:19:39.255526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preparing LightGBM datasets for StartHesitation\ntrain_data_StartHesitation = lgb.Dataset(X_train_smote_StartHesitation, label=y_train_smote_StartHesitation)\ntest_data_StartHesitation = lgb.Dataset(X_test_tdcs, label=y_test_StartHesitation, reference=train_data_StartHesitation)\n\n# Training a LightGBM model for StartHesitation\nmodel_StartHesitation = lgb.train(params, train_data_StartHesitation, num_round, valid_sets=[test_data_StartHesitation])","metadata":{"_uuid":"db3cfbe5-27d0-4dc3-ac77-15067c923a00","_cell_guid":"a607656b-2821-4200-a5dd-7d9037c7a532","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:20:16.218754Z","iopub.execute_input":"2024-03-07T20:20:16.219142Z","iopub.status.idle":"2024-03-07T20:21:05.554856Z","shell.execute_reply.started":"2024-03-07T20:20:16.219110Z","shell.execute_reply":"2024-03-07T20:21:05.554002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preparing LightGBM datasets for Turn\ntrain_data_Turn = lgb.Dataset(X_train_smote_Turn, label=y_train_smote_Turn)\ntest_data_Turn = lgb.Dataset(X_test_tdcs, label=y_test_Turn, reference=train_data_Turn)\n\n# Training a LightGBM model for Turn\nmodel_Turn = lgb.train(params, train_data_Turn, num_round, valid_sets=[test_data_Turn])","metadata":{"execution":{"iopub.status.busy":"2024-03-07T20:22:04.996190Z","iopub.execute_input":"2024-03-07T20:22:04.996819Z","iopub.status.idle":"2024-03-07T20:22:49.914194Z","shell.execute_reply.started":"2024-03-07T20:22:04.996783Z","shell.execute_reply":"2024-03-07T20:22:49.913259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Preparing LightGBM datasets for Walking\ntrain_data_Walking = lgb.Dataset(X_train_smote_Walking, label=y_train_smote_Walking)\ntest_data_Walking = lgb.Dataset(X_test_tdcs, label=y_test_Walking, reference=train_data_Walking)\n\n# Training a LightGBM model for Walking\nmodel_Walking = lgb.train(params, train_data_Walking, num_round, valid_sets=[test_data_Walking])","metadata":{"execution":{"iopub.status.busy":"2024-03-07T20:23:00.206516Z","iopub.execute_input":"2024-03-07T20:23:00.207180Z","iopub.status.idle":"2024-03-07T20:23:49.397217Z","shell.execute_reply.started":"2024-03-07T20:23:00.207149Z","shell.execute_reply":"2024-03-07T20:23:49.396378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Predicting and evaluating each model\ny_pred_StartHesitation = model_StartHesitation.predict(X_test_tdcs)\nroc_auc_StartHesitation = roc_auc_score(y_test_StartHesitation, y_pred_StartHesitation)\n\ny_pred_Turn = model_Turn.predict(X_test_tdcs)\nroc_auc_Turn = roc_auc_score(y_test_Turn, y_pred_Turn)\n\ny_pred_Walking = model_Walking.predict(X_test_tdcs)\nroc_auc_Walking = roc_auc_score(y_test_Walking, y_pred_Walking)","metadata":{"_uuid":"8cca21ca-93b1-4ad2-8966-10182b31c737","_cell_guid":"94f5096d-a253-4005-9827-b29fcdd398ca","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:24:54.183351Z","iopub.execute_input":"2024-03-07T20:24:54.183710Z","iopub.status.idle":"2024-03-07T20:25:00.343406Z","shell.execute_reply.started":"2024-03-07T20:24:54.183682Z","shell.execute_reply":"2024-03-07T20:25:00.342386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"'''# Evaluate using ROC AUC for each target variable\nroc_auc_StartHesitation = roc_auc_score(y_test_StartHesitation, y_pred_proba_StartHesitation_defog)\nroc_auc_Turn = roc_auc_score(y_test_Turn, y_pred_proba_Turn_defog)\nroc_auc_Walking = roc_auc_score(y_test_Walking, y_pred_proba_Walking_defog)'''","metadata":{"_uuid":"5c80141f-e226-4023-97e2-0566a2203070","_cell_guid":"436bd45e-c21c-4708-bf08-100d9e42d2f6","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:03.865957Z","iopub.execute_input":"2024-03-07T20:25:03.866623Z","iopub.status.idle":"2024-03-07T20:25:03.872788Z","shell.execute_reply.started":"2024-03-07T20:25:03.866591Z","shell.execute_reply":"2024-03-07T20:25:03.871800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Print ROC AUC scores\nprint(f\"ROC AUC for StartHesitation: {roc_auc_StartHesitation}\")\nprint(f\"ROC AUC for Turn: {roc_auc_Turn}\")\nprint(f\"ROC AUC for Walking: {roc_auc_Walking}\")","metadata":{"_uuid":"05e328a1-6535-4ccd-b2a9-bd635e557133","_cell_guid":"1280a647-54ff-489e-813b-2654ffbeccf0","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:05.816461Z","iopub.execute_input":"2024-03-07T20:25:05.817324Z","iopub.status.idle":"2024-03-07T20:25:05.822110Z","shell.execute_reply.started":"2024-03-07T20:25:05.817291Z","shell.execute_reply":"2024-03-07T20:25:05.821161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Now merging two models","metadata":{"_uuid":"dda54b74-b63c-4bad-b57a-6c55719a1f1e","_cell_guid":"4c83186a-eb49-4ca9-a8f5-a52a3afff3c6","trusted":true}},{"cell_type":"code","source":"'''X_combined = pd.DataFrame({\n    'StartHesitation_tdcs': y_pred_proba_StartHesitation_tdcs,\n    'Turn_tdcs': y_pred_proba_Turn_tdcs,\n    'Walking_tdcs': y_pred_proba_Walking_tdcs,\n    'StartHesitation_defog': y_pred_proba_StartHesitation_defog,\n    'Turn_defog': y_pred_proba_Turn_defog,\n    'Walking_defog': y_pred_proba_Walking_defog\n})\n\ny_combined = pd.DataFrame(Y_test_tdcs, Y_test_defog)  # Use the original target variable from your training data\n\nmerged_model = LGBMClassifier(objective='binary', random_state=42)\nmerged_model.fit(X_combined, y_combined)'''","metadata":{"_uuid":"8135557b-6d3f-4bcb-a582-18963f9abd75","_cell_guid":"b8fbbc21-4ae8-43c5-b3a3-097db57acd8c","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:10.015827Z","iopub.execute_input":"2024-03-07T20:25:10.016928Z","iopub.status.idle":"2024-03-07T20:25:10.023352Z","shell.execute_reply.started":"2024-03-07T20:25:10.016887Z","shell.execute_reply":"2024-03-07T20:25:10.022454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#combined_pred = merged_model.predict(X_test_combined)","metadata":{"_uuid":"1fc4ddb1-0142-45e9-9a6b-96609ab3753c","_cell_guid":"f648f7fd-cbed-421c-abe3-872b83940454","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:11.997324Z","iopub.execute_input":"2024-03-07T20:25:11.997753Z","iopub.status.idle":"2024-03-07T20:25:12.001877Z","shell.execute_reply.started":"2024-03-07T20:25:11.997724Z","shell.execute_reply":"2024-03-07T20:25:12.000861Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"submission","metadata":{"_uuid":"121ef668-38ee-44f8-84af-3bf253b52bf2","_cell_guid":"d8938152-7aca-44d1-ad19-306411590f31","trusted":true}},{"cell_type":"code","source":"TEST_ROOT_DEFOG = '/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/test/defog/'\ntest_defog = pd.DataFrame()\nfor root, dirs, files in os.walk(TEST_ROOT_DEFOG):\n    for name in files:       \n        f = os.path.join(root, name)\n        df_list= pd.read_csv(f)\n        words = name.split('.')[0]\n        df_list['file']= name.split('.')[0]\n        test_defog = pd.concat([test_defog, df_list], axis=0)\n        \nkeys = np.arange(len(test_defog))\ntest_defog = test_defog.set_index(keys, drop=True, append=False, inplace=False, verify_integrity=True)\ntest_defog","metadata":{"_uuid":"96707e13-eab4-4e5d-8eb7-b0cc62768d26","_cell_guid":"6ed198ce-a8f2-490c-baff-77cfef252f51","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:15.873351Z","iopub.execute_input":"2024-03-07T20:25:15.873975Z","iopub.status.idle":"2024-03-07T20:25:16.396016Z","shell.execute_reply.started":"2024-03-07T20:25:15.873934Z","shell.execute_reply":"2024-03-07T20:25:16.394933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_defog['Id'] = test_defog['file'] + '_' + test_defog['Time'].astype('str')\ntest_defog = test_defog.drop(['file'], axis = 1)\ntest_defog","metadata":{"_uuid":"f02f0562-e1e4-4f01-8149-3ee9423e76bd","_cell_guid":"8ad5c4bd-6484-458e-b802-e4e9c99450c8","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:18.272307Z","iopub.execute_input":"2024-03-07T20:25:18.272635Z","iopub.status.idle":"2024-03-07T20:25:18.495793Z","shell.execute_reply.started":"2024-03-07T20:25:18.272611Z","shell.execute_reply":"2024-03-07T20:25:18.494879Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_defog_df = test_defog.drop(['Time','Id'], axis = 1)\ntest_defog_df","metadata":{"_uuid":"1d48b7a6-ba8b-4713-9a23-bf35437b9211","_cell_guid":"fc0e95e2-c9bc-4d21-aa6c-c28d5fd7227a","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:20.080837Z","iopub.execute_input":"2024-03-07T20:25:20.081477Z","iopub.status.idle":"2024-03-07T20:25:20.095023Z","shell.execute_reply.started":"2024-03-07T20:25:20.081446Z","shell.execute_reply":"2024-03-07T20:25:20.094158Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#add pred column \ndefog_pred_fog = fog_model.predict(test_defog_df)\ntest_defog['FogProb'] = defog_pred_fog\ntest_defog","metadata":{"_uuid":"17a73626-7e2b-412e-9613-b255985831ce","_cell_guid":"d52c0fd2-cd1d-479f-b657-d7cecf4171b0","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:21.293563Z","iopub.execute_input":"2024-03-07T20:25:21.294306Z","iopub.status.idle":"2024-03-07T20:25:22.110490Z","shell.execute_reply.started":"2024-03-07T20:25:21.294270Z","shell.execute_reply":"2024-03-07T20:25:22.109551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\nwindow_size = 200  # 2 seconds window for 100Hz sampling rate\n\n# Calculating rolling window features for each acceleration axis\nfor axis in ['AccV', 'AccML', 'AccAP']:\n    test_defog[f'{axis}_rolling_mean'] = test_defog[axis].rolling(window=window_size, min_periods=1).mean()\n    test_defog[f'{axis}_rolling_std'] = test_defog[axis].rolling(window=window_size, min_periods=1).std()\n    test_defog[f'{axis}_rolling_max'] = test_defog[axis].rolling(window=window_size, min_periods=1).max()\n    test_defog[f'{axis}_rolling_min'] = test_defog[axis].rolling(window=window_size, min_periods=1).min()","metadata":{"_uuid":"76d4639a-8281-414b-b403-4bcacffea077","_cell_guid":"38eb9a9f-2c78-46d3-946c-344753276324","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:23.589577Z","iopub.execute_input":"2024-03-07T20:25:23.590227Z","iopub.status.idle":"2024-03-07T20:25:23.695800Z","shell.execute_reply.started":"2024-03-07T20:25:23.590182Z","shell.execute_reply":"2024-03-07T20:25:23.694794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Updating feature selection with rolling window features\nfeature_columns = ['AccV', 'AccML', 'AccAP', \n                   'AccV_rolling_mean', 'AccV_rolling_std', 'AccV_rolling_max', 'AccV_rolling_min',\n                   'AccML_rolling_mean', 'AccML_rolling_std', 'AccML_rolling_max', 'AccML_rolling_min',\n                   'AccAP_rolling_mean', 'AccAP_rolling_std', 'AccAP_rolling_max', 'AccAP_rolling_min']\n\nX = test_defog[feature_columns]","metadata":{"_uuid":"ebba6d37-a218-4087-ba4b-256bc1cdea36","_cell_guid":"4e754ba2-b3e8-494f-9c48-5977dbd41243","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:25:25.025949Z","iopub.execute_input":"2024-03-07T20:25:25.026645Z","iopub.status.idle":"2024-03-07T20:25:25.044518Z","shell.execute_reply.started":"2024-03-07T20:25:25.026613Z","shell.execute_reply":"2024-03-07T20:25:25.043793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"questions \ni made a model for each (defog and tdcs) and merged it, then submission was done using that merged model. Is it better to just use a separate tdcs model for this?","metadata":{"_uuid":"adbe1c67-d47a-427f-b8ef-5450b19ec110","_cell_guid":"34c86d10-3d1c-4369-8e73-a9fe378fc6a0","trusted":true}},{"cell_type":"code","source":"test_defog_SH_pred =model_StartHesitation.predict(X)\ntest_defog_T_pred = model_Turn.predict(X)\ntest_defog_W_pred = model_Walking.predict(X)","metadata":{"_uuid":"ee3d8e58-76b5-4ace-8a32-c85b18b8cf16","_cell_guid":"19f5f33b-da69-459b-ad15-e1d79adbcbd7","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:26:54.535938Z","iopub.execute_input":"2024-03-07T20:26:54.536753Z","iopub.status.idle":"2024-03-07T20:26:56.986200Z","shell.execute_reply.started":"2024-03-07T20:26:54.536722Z","shell.execute_reply":"2024-03-07T20:26:56.985387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_defog['StartHesitation'] = np.sqrt(test_defog_SH_pred * defog_pred_fog)\ntest_defog['Turn'] = np.sqrt(test_defog_T_pred * defog_pred_fog)\ntest_defog['Walking'] = np.sqrt(test_defog_W_pred * defog_pred_fog)","metadata":{"_uuid":"d6e2ff6a-6e8e-4b80-8434-d211fd155e9d","_cell_guid":"3ea01588-9811-42b2-aee1-ab0772f806e0","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:16.103417Z","iopub.execute_input":"2024-03-07T20:27:16.104237Z","iopub.status.idle":"2024-03-07T20:27:16.114360Z","shell.execute_reply.started":"2024-03-07T20:27:16.104196Z","shell.execute_reply":"2024-03-07T20:27:16.113322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subm = test_defog[['Id','StartHesitation','Turn','Walking']]","metadata":{"_uuid":"7df4b9c1-535d-46a6-a2d0-244735101008","_cell_guid":"eda86e43-d07e-49cd-8cea-7e5f0c235133","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:17.897947Z","iopub.execute_input":"2024-03-07T20:27:17.898583Z","iopub.status.idle":"2024-03-07T20:27:17.911552Z","shell.execute_reply.started":"2024-03-07T20:27:17.898552Z","shell.execute_reply":"2024-03-07T20:27:17.910511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"TEST_ROOT_TDCS= '/kaggle/input/tlvmc-parkinsons-freezing-gait-prediction/test/tdcsfog/'\ntest_tdcs = pd.DataFrame()\nfor root, dirs, files in os.walk(TEST_ROOT_TDCS):\n    for name in files:       \n        f = os.path.join(root, name)\n        df_list= pd.read_csv(f)\n        words = name.split('.')[0]\n        df_list['file']= name.split('.')[0]\n        test_tdcs = pd.concat([test_tdcs, df_list], axis=0)\n        \nkeys = np.arange(len(test_tdcs))\ntest_tdcs = test_tdcs.set_index(keys, drop=True, append=False, inplace=False, verify_integrity=True)\ntest_tdcs","metadata":{"_uuid":"487e7e51-e4a1-4e92-a87f-6a3d08198f77","_cell_guid":"d057bd03-c09c-4de9-8ece-b963e0957511","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:19.228847Z","iopub.execute_input":"2024-03-07T20:27:19.229529Z","iopub.status.idle":"2024-03-07T20:27:19.276442Z","shell.execute_reply.started":"2024-03-07T20:27:19.229497Z","shell.execute_reply":"2024-03-07T20:27:19.275544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_tdcs['Id'] = test_tdcs['file'] + '_' + test_tdcs['Time'].astype('str')\ntest_tdcs = test_tdcs.drop(['file'], axis = 1)\ntest_tdcs","metadata":{"_uuid":"4a58fc9c-64cd-4299-84af-5b10ba42e9d8","_cell_guid":"b96dade4-2d8f-435d-9f05-a35cb30daf8c","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:20.903913Z","iopub.execute_input":"2024-03-07T20:27:20.904384Z","iopub.status.idle":"2024-03-07T20:27:20.924355Z","shell.execute_reply.started":"2024-03-07T20:27:20.904346Z","shell.execute_reply":"2024-03-07T20:27:20.923322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_tdcs_df = test_tdcs.drop(['Time','Id'], axis = 1)\ntest_tdcs_df","metadata":{"_uuid":"0a11a0b9-169c-4102-b677-8caeeb2d1110","_cell_guid":"17e30105-d4c6-407f-8bdc-ba24126b3d33","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:22.891394Z","iopub.execute_input":"2024-03-07T20:27:22.891747Z","iopub.status.idle":"2024-03-07T20:27:22.904126Z","shell.execute_reply.started":"2024-03-07T20:27:22.891719Z","shell.execute_reply":"2024-03-07T20:27:22.903228Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# using separate tdcs\ntdcs_pred_fog = tdcsfog_model.predict(test_tdcs_df)","metadata":{"_uuid":"85e8d539-850e-4327-87b8-4cea800100f9","_cell_guid":"bac6bfb2-1495-412c-92ed-b1f7e3b5e2b6","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:24.480910Z","iopub.execute_input":"2024-03-07T20:27:24.481321Z","iopub.status.idle":"2024-03-07T20:27:24.504585Z","shell.execute_reply.started":"2024-03-07T20:27:24.481290Z","shell.execute_reply":"2024-03-07T20:27:24.503898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_tdcs['FogProb'] = tdcs_pred_fog\ntest_tdcs","metadata":{"_uuid":"a96c09f4-432c-43c3-8a90-de2131a8d07b","_cell_guid":"18cc5d64-aac7-4db0-9adf-9ffdd6bd3911","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:26.941167Z","iopub.execute_input":"2024-03-07T20:27:26.941535Z","iopub.status.idle":"2024-03-07T20:27:26.956088Z","shell.execute_reply.started":"2024-03-07T20:27:26.941507Z","shell.execute_reply":"2024-03-07T20:27:26.955035Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"window_size = 200  # 2 seconds window for 100Hz sampling rate\n\n# Calculating rolling window features for each acceleration axis\nfor axis in ['AccV', 'AccML', 'AccAP']:\n    test_tdcs[f'{axis}_rolling_mean'] = test_tdcs[axis].rolling(window=window_size, min_periods=1).mean()\n    test_tdcs[f'{axis}_rolling_std'] = test_tdcs[axis].rolling(window=window_size, min_periods=1).std()\n    test_tdcs[f'{axis}_rolling_max'] = test_tdcs[axis].rolling(window=window_size, min_periods=1).max()\n    test_tdcs[f'{axis}_rolling_min'] = test_tdcs[axis].rolling(window=window_size, min_periods=1).min()\ntest_tdcs","metadata":{"_uuid":"6d01166a-7e18-403b-87db-24728f17bad1","_cell_guid":"1fce4f15-185d-4652-9f70-f2eefdb6ef21","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:28.934847Z","iopub.execute_input":"2024-03-07T20:27:28.935539Z","iopub.status.idle":"2024-03-07T20:27:28.970328Z","shell.execute_reply.started":"2024-03-07T20:27:28.935506Z","shell.execute_reply":"2024-03-07T20:27:28.969443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Updating feature selection with rolling window features\nfeature_columns = ['AccV', 'AccML', 'AccAP', \n                   'AccV_rolling_mean', 'AccV_rolling_std', 'AccV_rolling_max', 'AccV_rolling_min',\n                   'AccML_rolling_mean', 'AccML_rolling_std', 'AccML_rolling_max', 'AccML_rolling_min',\n                   'AccAP_rolling_mean', 'AccAP_rolling_std', 'AccAP_rolling_max', 'AccAP_rolling_min']\n\nX = test_tdcs[feature_columns]","metadata":{"_uuid":"6f1f44cf-18b9-4b8a-b13f-bdc0b80393e8","_cell_guid":"3de8824e-eedc-4bff-806d-c83cb75e2fcb","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:30.533036Z","iopub.execute_input":"2024-03-07T20:27:30.533395Z","iopub.status.idle":"2024-03-07T20:27:30.540031Z","shell.execute_reply.started":"2024-03-07T20:27:30.533366Z","shell.execute_reply":"2024-03-07T20:27:30.539125Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_tdcs_SH_pred = model_StartHesitation.predict(X)\ntest_tdcs_T_pred = model_Turn.predict(X)\ntest_tdcs_W_pred = model_Walking.predict(X)","metadata":{"_uuid":"3d0581fb-52b4-4a3b-bd93-b3cf56bf51fd","_cell_guid":"fd8cd684-1cf7-4a33-b577-1ce2cbb33ff0","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:44.270845Z","iopub.execute_input":"2024-03-07T20:27:44.271208Z","iopub.status.idle":"2024-03-07T20:27:44.353702Z","shell.execute_reply.started":"2024-03-07T20:27:44.271180Z","shell.execute_reply":"2024-03-07T20:27:44.352957Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_tdcs['StartHesitation'] = np.sqrt(test_tdcs_SH_pred * tdcs_pred_fog)\ntest_tdcs['Turn'] = np.sqrt(test_tdcs_T_pred * tdcs_pred_fog)\ntest_tdcs['Walking'] = np.sqrt(test_tdcs_W_pred * tdcs_pred_fog)","metadata":{"_uuid":"cea2b660-8998-4af8-a25b-0685172926a0","_cell_guid":"546625d4-5bab-4462-ba05-0381d3d24f7f","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:45.416525Z","iopub.execute_input":"2024-03-07T20:27:45.417134Z","iopub.status.idle":"2024-03-07T20:27:45.426601Z","shell.execute_reply.started":"2024-03-07T20:27:45.417090Z","shell.execute_reply":"2024-03-07T20:27:45.425359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subm2 = test_tdcs[['Id','StartHesitation','Turn','Walking']]","metadata":{"_uuid":"30e35237-4cff-47af-a656-6e7623e30634","_cell_guid":"dc027571-9a82-4226-8284-b9a9cfe068ca","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:46.842471Z","iopub.execute_input":"2024-03-07T20:27:46.843191Z","iopub.status.idle":"2024-03-07T20:27:46.848380Z","shell.execute_reply.started":"2024-03-07T20:27:46.843160Z","shell.execute_reply":"2024-03-07T20:27:46.847458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subm2","metadata":{"_uuid":"bf0e3e14-41ea-425a-afc5-399fe41ff625","_cell_guid":"2711a67d-ae92-48bd-ba33-c2118d37848b","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:56.285123Z","iopub.execute_input":"2024-03-07T20:27:56.285485Z","iopub.status.idle":"2024-03-07T20:27:56.298640Z","shell.execute_reply.started":"2024-03-07T20:27:56.285458Z","shell.execute_reply":"2024-03-07T20:27:56.297737Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subm_final = pd.concat([subm, subm2], ignore_index=True)","metadata":{"_uuid":"cf6f0139-1bb3-4cac-b3d4-937d5920b860","_cell_guid":"a4cb31ef-8851-4e6d-aa7d-b774bbaf310d","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:27:57.491903Z","iopub.execute_input":"2024-03-07T20:27:57.492513Z","iopub.status.idle":"2024-03-07T20:27:57.500915Z","shell.execute_reply.started":"2024-03-07T20:27:57.492484Z","shell.execute_reply":"2024-03-07T20:27:57.500165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subm_final.to_csv(\"submission.csv\",index=False)","metadata":{"_uuid":"670bccbe-cef6-4cc0-b78d-a315ef43e6e1","_cell_guid":"bd9710ae-d941-410c-82d9-657cc391ca26","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:28:00.036840Z","iopub.execute_input":"2024-03-07T20:28:00.037488Z","iopub.status.idle":"2024-03-07T20:28:02.016959Z","shell.execute_reply.started":"2024-03-07T20:28:00.037459Z","shell.execute_reply":"2024-03-07T20:28:02.016107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"subm_final","metadata":{"_uuid":"054a2cdf-d874-459f-a2ee-0dfb8d27af93","_cell_guid":"d41348b6-8607-4afd-9832-c740a44f3872","collapsed":false,"jupyter":{"outputs_hidden":false},"execution":{"iopub.status.busy":"2024-03-07T20:28:04.607028Z","iopub.execute_input":"2024-03-07T20:28:04.607828Z","iopub.status.idle":"2024-03-07T20:28:04.621867Z","shell.execute_reply.started":"2024-03-07T20:28:04.607799Z","shell.execute_reply":"2024-03-07T20:28:04.620857Z"},"trusted":true},"execution_count":null,"outputs":[]}]}