{"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":"none","dataSources":[{"sourceId":59093,"databundleVersionId":7469972,"sourceType":"competition"},{"sourceId":8041950,"sourceType":"datasetVersion","datasetId":4643243},{"sourceId":8057606,"sourceType":"datasetVersion","datasetId":4709890},{"sourceId":8061767,"sourceType":"datasetVersion","datasetId":4544594},{"sourceId":8170096,"sourceType":"datasetVersion","datasetId":4689282},{"sourceId":8190268,"sourceType":"datasetVersion","datasetId":4850192}],"dockerImageVersionId":30698,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Solution : https://www.kaggle.com/competitions/hms-harmful-brain-activity-classification/discussion/492560","metadata":{}},{"cell_type":"code","source":"%cp /kaggle/input/hms-all-train-and-inference /kaggle/working/ -R","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-04-22T04:37:47.448330Z","iopub.execute_input":"2024-04-22T04:37:47.449245Z","iopub.status.idle":"2024-04-22T04:37:48.973614Z","shell.execute_reply.started":"2024-04-22T04:37:47.449206Z","shell.execute_reply":"2024-04-22T04:37:48.972037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!tree /kaggle/working/","metadata":{"execution":{"iopub.status.busy":"2024-04-22T04:40:14.667066Z","iopub.execute_input":"2024-04-22T04:40:14.667452Z","iopub.status.idle":"2024-04-22T04:40:15.767830Z","shell.execute_reply.started":"2024-04-22T04:40:14.667424Z","shell.execute_reply":"2024-04-22T04:40:15.766373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# !cat /kaggle/input/hms-all-train-and-inference/readme.md","metadata":{"execution":{"iopub.status.busy":"2024-04-22T04:38:11.354656Z","iopub.execute_input":"2024-04-22T04:38:11.355132Z","iopub.status.idle":"2024-04-22T04:38:11.360218Z","shell.execute_reply.started":"2024-04-22T04:38:11.355088Z","shell.execute_reply":"2024-04-22T04:38:11.359330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Hello!\n\nBelow you can find a outline of how to reproduce my solution for the HMS - Harmful Brain Activity Classification competition.\n\n# HARDWARE: (The following specs were used to create the original solution)\n- OS  : Ubuntu 20.04 LTS\n- CPU : Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz\n- GPU : 2 x NVIDIA RTX3090\n\n# SOFTWARE \n- python packages are detailed separately in `requirements.txt`\n  - jax / jaxlib depends on the cuda / cudnn version, so you need to find the appropriate version from [this link](https://storage.googleapis.com/jax-releases/jax_cuda_releases.html), and change the version in requirements.txt.\n- Python 3.8.10\n- CUDA 11.3\n- cudnn 8.2.0\n- nvidia drivers v.470.239.06\n\n# DATA SETUP \n- assumes the [Kaggle API](https://github.com/Kaggle/kaggle-api) is installed\n- below are the shell commands used in each step, as run from the top level directory\n```\nmkdir -p dataset\ncd dataset\nkaggle competitions download -c hms-harmful-brain-activity-classification\nunzip hms-harmful-brain-activity-classification.zip\ncd ..\n```\n\n# OVERVIEW for model build\nOur model is an ensemble of 30 models trained using four different methods.\n- We describe three approaches for training: \n  - A. One where all models are trained collectively \n  - B. Another where the training is conducted individually in four parts\n  - C. And, we have prepared command to train best cv model\n\n## First : COMMON DATA PROCESSING \nPreprocess train.csv. You need to run this command for training.\n```\npython3 generate_groupkfold_csv.py\n```\n\n## A. TRAIN ALL MODEL \nThis will take about 7 days (or more).\n```\nsource train_all.sh\n```\n\n## B. Train Specific MODEL\n### yamash models\nIf you train a specific model, please read a shell script.\n```\ncd yamash\nsource prepare_data_train.sh\n```\n  \n### suguuuuu models\nIf you train a specific model, please read a shell script.\n```\ncd suguuuuu\nsource prepare_data_train.sh\n```\n\n### muku models\nIf you train a specific model, please read a shell script.\n```\ncd muku\nsource prepare_data_train.sh\n```\nIf you want to check the operation simply in debug mode, please give the -d option.\n```\nsource prepare_data_train.sh -d\n```\n\n### kfuji models\nIf you train a specific model, please read a shell script.\n```\ncd kfuji\nsource prepare_data_train.sh\n```\n\n## C. Train Best CV model\nThe best cv is No.19 (written in bottom list) in our model. If you want to train the model, please run below command.\n```\ncd muku\npython3 prepare_data.py\npython3 train_v046_2_to_v062.py v057\n```\n\n# Prediction using weight to score Kaggle leaderboard\n```\npython3 predict.py --pretrained\n```\n\n# Model List\nWeight name to score Kaggle leaderboard and re-train weight name are different. Please refer this list.\n\n|No. | part_name　| CV| weight name to score Kaggle leaderboard | re-train weight name |\n|-|----------|--------|------------|------------|\n|00 | yamash   |0.24520|weights/hms-weights-yamash/022_023/|yamash/output/022_023/|\n|01 | yamash   |0.23852|weights/hms-weights-yamash/026_001_v2/|yamash/output/026_001_v2/|\n|02 | yamash   |0.24575|weights/hms-weights-yamash/026_016/|yamash/output/026_016/|\n|03 | yamash   |0.23514|weights/hms-weights-yamash/026_017/|yamash/output/026_017/|\n|04 | yamash   |0.23094|weights/hms-weights-yamash/030_002/|yamash/output/030_002/|\n|05 | suguuuuu |0.24066|weights/hms-cwt-weights-r02/exp05-78-2_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_labelsmoothingOff/|suguuuuu/output/exp78_2stage/|\n|06 | suguuuuu |0.23985|weights/hms-cwt-weights-r02/exp05-78-4_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_labelsmoothingOff/|suguuuuu/output/exp78-2_finetune/|\n|07 | suguuuuu |0.24069|weights/hms-cwt-weights-r02/exp05-78-5_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_labelsmoothingOff/|suguuuuu/output/exp78-3_finetune/|\n|08 | suguuuuu |0.24262|weights/hms-cwt-weights-r02/exp05-90_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_addData/|suguuuuu/output/exp90_finetune/|\n|09 | suguuuuu |0.24072|weights/hms-cwt-weights-r02/exp05-91_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_1dAnd2d/|suguuuuu/output/exp91_2stage/|\n|10 | suguuuuu |0.23810|weights/hms-cwt-weights-r02/exp05-91-2_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_1dAnd2d/|suguuuuu/output/exp91-2_finetune/|\n|11 | suguuuuu |0.24121|weights/hms-cwt-weights-r02/exp05-91-3_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_1dAnd2d/|suguuuuu/output/exp91-3_finetune/|\n|12 | suguuuuu |0.23948|weights/hms-cwt-weights-r02/exp05-91-5_AMP_cwt_50sec_stride16_18band_maxvit_base_tf_512_1dAnd2d/|suguuuuu/output/exp91-4_finetune/|\n|13 | muku     |0.23095|weights/hms-weights-saito/1dcnn_v062_stage2/1dcnn_v062_stage2/|muku/output/v062_stage2/|\n|14 | muku     |0.23217|weights/hms-weights-saito/1dcnn_v061_stage2/1dcnn_v061_stage2/|muku/output/v061_stage2/|\n|15 | muku     |0.22644|weights/hms-weights-saito/1dcnn_v060_stage2/1dcnn_v060_stage2/|muku/output/v060_stage2/|\n|16 | muku     |0.23935|weights/hms-weights-saito/1dcnn_v059_stage2/1dcnn_v059_stage2/|muku/output/v059_stage2/|\n|17 | muku     |0.22294|weights/hms-weights-saito/1dcnn_v057_stage2/1dcnn_v057_stage2/|muku/output/v057_stage2/|\n|18 | muku     |0.23754|weights/hms-weights-saito/1dcnn_v056_stage2/1dcnn_v056_stage2/|muku/output/v056_stage2/|\n|19 | muku     |0.22941|weights/hms-weights-saito/1dcnn_v055_stage2/1dcnn_v055_stage2/|muku/output/v055_stage2/|\n|20 | muku     |0.23031|weights/hms-weights-saito/1dcnn_v054_stage2/1dcnn_v054_stage2/|muku/output/v054_stage2/|\n|21 | muku     |0.23731|weights/hms-weights-saito/1dcnn_v053_stage2/1dcnn_v053_stage2/|muku/output/v053_stage2/|\n|22 | muku     |0.23006|weights/hms-weights-saito/1dcnn_v051_stage2/1dcnn_v051_stage2/|muku/output/v051_stage2/|\n|23 | muku     |0.24231|weights/hms-weights-saito/1dcnn_v048_stage2/1dcnn_v048_stage2/|muku/output/v048_stage2/|\n|24 | muku     |0.24671|weights/hms-weights-saito/1dcnn_v047_stage2/1dcnn_v047_stage2/|muku/output/v047_stage2/|\n|25 | muku     |0.24582|weights/hms-weights-saito/1dcnn_v046_2_stage2/1dcnn_v046_2_stage2/|muku/output/v046_2_stage2/|\n|26 | muku     |0.25571|weights/hms-weights-saito/1dcnn_v042_stage2/1dcnn_v042_stage2/|muku/output/v042_stage2/|\n|27 | kfuji    |0.23089|weights/hms-weights-fujii/done_51_20240403_1841/|kfuji/output/51_CWT_Paul_len5000_m4/|\n|28 | kfuji    |0.24745|weights/hms-weights-fujii/done_52_20240403_1829/|kfuji/output/52_CWT_Paul_len2000_m4/|\n|29 | kfuji    |0.23113|weights/hms-weights-fujii/done_71_20240406_2039/|kfuji/output/78_CWT_Paul_len5000_m16/|","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}