{
  "id": 492938,
  "title": "62th Place Solution",
  "url": "/competitions/hms-harmful-brain-activity-classification/discussion/492938",
  "author_name": "Yumeng717",
  "post_date": "2024-04-11T14:08:33.018000",
  "votes": 9,
  "comment_count": 0,
  "views": 0,
  "content": "<p>This was my first time trying the EEG related task, and I found it to be a highly valuable learning experience. Thanks to Harvard Medical School and Kaggle for hosting this fun competition.</p>\n<h2>Data</h2>\n<h3>Train Data</h3>\n<p>The input data is duplicate by eeg_id and votes columns, and final obtain 20183 samples in train data. </p>\n<pre><code> = pd.read_csv()\n = df.columns[-:]\n = df.drop_duplicates(subset=[] + list(TARGETS))\n</code></pre>\n<p>I split this train data into 5-fold by using GroupKFold method with expert_consensus and patient_id label.</p>\n<h3>Multi-Modal Input Data</h3>\n<p>In my solution, the input data include eeg signal (1D) and spectrogram (2D). For the spectrogram input, I refer <a href=\"https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine\" target=\"_blank\">rafaelzimmermann1's notebook</a> to convert eeg to spectrogram, and final combine the exist kaggle spectrogram and converted spectorgram as model's input.</p>\n<h2>Model</h2>\n<p>There are three cv models for ensemble:</p>\n<ul>\n<li>Model1: EfficientNet-B1 with spectrogram data<br>\nI refer <a href=\"https://www.kaggle.com/code/minhsienweng/train-infer-efficientnetb0-starter\" target=\"_blank\">minhsienweng's notebook</a> to build and train the model, and I adopt EfficientNet-B1 model for better performance.</li>\n<li>Model2: ResNet-1D + EfficientNet-B1 with eeg and spectrogram data<br>\nI refer <a href=\"https://www.kaggle.com/code/nischaydnk/training-multimodal-1d-2d-approach-eegs\" target=\"_blank\">nischaydnk's notebook</a> to build multi-modal model for eeg and spectrogram data.</li>\n<li>Model3: WaveNet + EfficientNet-B1 with eeg and spectrogram data<br>\nBase on the ResNet-1D + EfficientNet-B1 multi-modal model architecture, I replace the ResNet-1D with WaveNet (which refers <a href=\"https://www.kaggle.com/code/abaojiang/lb-0-46-dilatedinception-wavenet-training\" target=\"_blank\">abaojiang's notebook</a>) model for better processing power for eeg signals.</li>\n</ul>\n<p>Final, I ensemble the prediction results of three cv models by: 0.34 * Model1 + 0.32 * Model2 + 0.34 * Model3</p>\n<h2>Key Training Strategies</h2>\n<h3>Two-stage training</h3>\n<p>I adpated the two-stage training strategy refers to the <a href=\"https://www.kaggle.com/code/seanbearden/effnetb0-2-pop-model-train-twice-lb-0-39\" target=\"_blank\">seanbearden's notebook</a>. And this strategy bring significant public LB metric imporvement in WaveNet and EfficientNet models (for pre-validation), and I find the cv metric for fine data is seem strong correlation with public LB metric:</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>Public LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>WaveNet</td>\n<td>0.46</td>\n</tr>\n<tr>\n<td>WaveNet (two-stage)</td>\n<td>0.39</td>\n</tr>\n<tr>\n<td>EfficientNet-B0</td>\n<td>0.42</td>\n</tr>\n<tr>\n<td>EfficientNet-B0 (two-stage)</td>\n<td>0.34</td>\n</tr>\n</tbody>\n</table>\n<h3>Label refine training</h3>\n<p>After two-stage training strategy, I also tried the label refine training strategy according to <a href=\"https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine\" target=\"_blank\">rafaelzimmermann1's notebook</a>. I tested this strategy and get improvement of local cv metric:</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>CV</th>\n<th>Public LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>EfficientNet-B1</td>\n<td>0.3102</td>\n<td>--</td>\n</tr>\n<tr>\n<td>EfficientNet-B0 (label-refine)</td>\n<td>0.3058</td>\n<td>--</td>\n</tr>\n<tr>\n<td>WaveNet + EfficientNet-B1</td>\n<td>0.2903</td>\n<td>--</td>\n</tr>\n<tr>\n<td>WaveNet + EfficientNet-B0 (label-refine)</td>\n<td>0.2686</td>\n<td>0.28</td>\n</tr>\n</tbody>\n</table>\n<h3>Other tricks</h3>\n<h4>CutMix Augmentation</h4>\n<p>I used the <a href=\"https://www.kaggle.com/competitions/hms-harmful-brain-activity-classification/discussion/479446\" target=\"_blank\">CutMix</a> Augmentation during model training, and this trick could bring some improvement of cv metric:</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>CV</th>\n<th>Public LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>EfficientNet-B1</td>\n<td>0.3130</td>\n<td>0.30</td>\n</tr>\n<tr>\n<td>EfficientNet-B0 (label-refine)</td>\n<td>0.3102</td>\n<td>--</td>\n</tr>\n</tbody>\n</table>\n<h4>Iteration Steps</h4>\n<p>In the label refine training pipeline, I set the iteration equals to 1 for models except for EfficientNet-B1 model. For the EfficientNet-B1 model, I set the iteration equals to 2 for better performance (just a little).</p>\n<h3>Final training pipeline</h3>\n<p>The final training pipeline can be concluded: <img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7951864%2Faf2152ac5a9a165a53b5e9c562a373e2%2FLabel-Refine-Pipeline.png?generation=1712843769135040&amp;alt=media\" alt=\"Pipeline\"></p>\n<h4>Final Submission</h4>\n<p>Finally, In order to avoid the possible data drift in two-stage training mode, I selected the teacher model (trained with pseudo-label coarse data and fine data, public LB: 0.29) and the student model (finetuned with pseudo-label fine data, public LB: 0.27) as final models.</p>",
  "messages": [
    {
      "id": 2746849,
      "postDate": "2024-04-11T14:08:33.017Z",
      "content": "<p>This was my first time trying the EEG related task, and I found it to be a highly valuable learning experience. Thanks to Harvard Medical School and Kaggle for hosting this fun competition.</p>\n<h2>Data</h2>\n<h3>Train Data</h3>\n<p>The input data is duplicate by eeg_id and votes columns, and final obtain 20183 samples in train data. </p>\n<pre><code> = pd.read_csv()\n = df.columns[-:]\n = df.drop_duplicates(subset=[] + list(TARGETS))\n</code></pre>\n<p>I split this train data into 5-fold by using GroupKFold method with expert_consensus and patient_id label.</p>\n<h3>Multi-Modal Input Data</h3>\n<p>In my solution, the input data include eeg signal (1D) and spectrogram (2D). For the spectrogram input, I refer <a href=\"https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine\" target=\"_blank\">rafaelzimmermann1's notebook</a> to convert eeg to spectrogram, and final combine the exist kaggle spectrogram and converted spectorgram as model's input.</p>\n<h2>Model</h2>\n<p>There are three cv models for ensemble:</p>\n<ul>\n<li>Model1: EfficientNet-B1 with spectrogram data<br>\nI refer <a href=\"https://www.kaggle.com/code/minhsienweng/train-infer-efficientnetb0-starter\" target=\"_blank\">minhsienweng's notebook</a> to build and train the model, and I adopt EfficientNet-B1 model for better performance.</li>\n<li>Model2: ResNet-1D + EfficientNet-B1 with eeg and spectrogram data<br>\nI refer <a href=\"https://www.kaggle.com/code/nischaydnk/training-multimodal-1d-2d-approach-eegs\" target=\"_blank\">nischaydnk's notebook</a> to build multi-modal model for eeg and spectrogram data.</li>\n<li>Model3: WaveNet + EfficientNet-B1 with eeg and spectrogram data<br>\nBase on the ResNet-1D + EfficientNet-B1 multi-modal model architecture, I replace the ResNet-1D with WaveNet (which refers <a href=\"https://www.kaggle.com/code/abaojiang/lb-0-46-dilatedinception-wavenet-training\" target=\"_blank\">abaojiang's notebook</a>) model for better processing power for eeg signals.</li>\n</ul>\n<p>Final, I ensemble the prediction results of three cv models by: 0.34 * Model1 + 0.32 * Model2 + 0.34 * Model3</p>\n<h2>Key Training Strategies</h2>\n<h3>Two-stage training</h3>\n<p>I adpated the two-stage training strategy refers to the <a href=\"https://www.kaggle.com/code/seanbearden/effnetb0-2-pop-model-train-twice-lb-0-39\" target=\"_blank\">seanbearden's notebook</a>. And this strategy bring significant public LB metric imporvement in WaveNet and EfficientNet models (for pre-validation), and I find the cv metric for fine data is seem strong correlation with public LB metric:</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>Public LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>WaveNet</td>\n<td>0.46</td>\n</tr>\n<tr>\n<td>WaveNet (two-stage)</td>\n<td>0.39</td>\n</tr>\n<tr>\n<td>EfficientNet-B0</td>\n<td>0.42</td>\n</tr>\n<tr>\n<td>EfficientNet-B0 (two-stage)</td>\n<td>0.34</td>\n</tr>\n</tbody>\n</table>\n<h3>Label refine training</h3>\n<p>After two-stage training strategy, I also tried the label refine training strategy according to <a href=\"https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine\" target=\"_blank\">rafaelzimmermann1's notebook</a>. I tested this strategy and get improvement of local cv metric:</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>CV</th>\n<th>Public LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>EfficientNet-B1</td>\n<td>0.3102</td>\n<td>--</td>\n</tr>\n<tr>\n<td>EfficientNet-B0 (label-refine)</td>\n<td>0.3058</td>\n<td>--</td>\n</tr>\n<tr>\n<td>WaveNet + EfficientNet-B1</td>\n<td>0.2903</td>\n<td>--</td>\n</tr>\n<tr>\n<td>WaveNet + EfficientNet-B0 (label-refine)</td>\n<td>0.2686</td>\n<td>0.28</td>\n</tr>\n</tbody>\n</table>\n<h3>Other tricks</h3>\n<h4>CutMix Augmentation</h4>\n<p>I used the <a href=\"https://www.kaggle.com/competitions/hms-harmful-brain-activity-classification/discussion/479446\" target=\"_blank\">CutMix</a> Augmentation during model training, and this trick could bring some improvement of cv metric:</p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>CV</th>\n<th>Public LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>EfficientNet-B1</td>\n<td>0.3130</td>\n<td>0.30</td>\n</tr>\n<tr>\n<td>EfficientNet-B0 (label-refine)</td>\n<td>0.3102</td>\n<td>--</td>\n</tr>\n</tbody>\n</table>\n<h4>Iteration Steps</h4>\n<p>In the label refine training pipeline, I set the iteration equals to 1 for models except for EfficientNet-B1 model. For the EfficientNet-B1 model, I set the iteration equals to 2 for better performance (just a little).</p>\n<h3>Final training pipeline</h3>\n<p>The final training pipeline can be concluded: <img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7951864%2Faf2152ac5a9a165a53b5e9c562a373e2%2FLabel-Refine-Pipeline.png?generation=1712843769135040&amp;alt=media\" alt=\"Pipeline\"></p>\n<h4>Final Submission</h4>\n<p>Finally, In order to avoid the possible data drift in two-stage training mode, I selected the teacher model (trained with pseudo-label coarse data and fine data, public LB: 0.29) and the student model (finetuned with pseudo-label fine data, public LB: 0.27) as final models.</p>",
      "rawMarkdown": "This was my first time trying the EEG related task, and I found it to be a highly valuable learning experience. Thanks to Harvard Medical School and Kaggle for hosting this fun competition.\n\n## Data\n### Train Data\nThe input data is duplicate by eeg_id and votes columns, and final obtain 20183 samples in train data. \n```\ndf = pd.read_csv('train.csv')\nTARGETS = df.columns[-6:]\ntrain_df = df.drop_duplicates(subset=['eeg_id'] + list(TARGETS))\n```\nI split this train data into 5-fold by using GroupKFold method with expert_consensus and patient_id label.\n\n### Multi-Modal Input Data\nIn my solution, the input data include eeg signal (1D) and spectrogram (2D). For the spectrogram input, I refer [rafaelzimmermann1's notebook](https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine) to convert eeg to spectrogram, and final combine the exist kaggle spectrogram and converted spectorgram as model's input.\n\n## Model\nThere are three cv models for ensemble:\n+ Model1: EfficientNet-B1 with spectrogram data\nI refer [minhsienweng's notebook](https://www.kaggle.com/code/minhsienweng/train-infer-efficientnetb0-starter) to build and train the model, and I adopt EfficientNet-B1 model for better performance.\n+ Model2: ResNet-1D + EfficientNet-B1 with eeg and spectrogram data\nI refer [nischaydnk's notebook](https://www.kaggle.com/code/nischaydnk/training-multimodal-1d-2d-approach-eegs) to build multi-modal model for eeg and spectrogram data.\n+ Model3: WaveNet + EfficientNet-B1 with eeg and spectrogram data\nBase on the ResNet-1D + EfficientNet-B1 multi-modal model architecture, I replace the ResNet-1D with WaveNet (which refers [abaojiang's notebook](https://www.kaggle.com/code/abaojiang/lb-0-46-dilatedinception-wavenet-training)) model for better processing power for eeg signals.\n\nFinal, I ensemble the prediction results of three cv models by: 0.34 * Model1 + 0.32 * Model2 + 0.34 * Model3\n\n## Key Training Strategies\n### Two-stage training\nI adpated the two-stage training strategy refers to the [seanbearden's notebook](https://www.kaggle.com/code/seanbearden/effnetb0-2-pop-model-train-twice-lb-0-39). And this strategy bring significant public LB metric imporvement in WaveNet and EfficientNet models (for pre-validation), and I find the cv metric for fine data is seem strong correlation with public LB metric:\n| Model           | Public LB |\n|-----------------|:--------:|\n| WaveNet             |   0.46   |\n| WaveNet (two-stage)      |   0.39   |\n| EfficientNet-B0             |   0.42   |\n| EfficientNet-B0 (two-stage)      |   0.34   |\n\n### Label refine training\nAfter two-stage training strategy, I also tried the label refine training strategy according to [rafaelzimmermann1's notebook](https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine). I tested this strategy and get improvement of local cv metric:\n\n| Model           | CV | Public LB |\n|-----------------|:--------:|:--------:|\n| EfficientNet-B1             |   0.3102   |   --   |\n| EfficientNet-B0 (label-refine)      |   0.3058   |   --   |\n| WaveNet + EfficientNet-B1             |   0.2903   |   --   |\n| WaveNet + EfficientNet-B0 (label-refine)      |   0.2686   |   0.28   |\n\n### Other tricks\n#### CutMix Augmentation\nI used the [CutMix](https://www.kaggle.com/competitions/hms-harmful-brain-activity-classification/discussion/479446) Augmentation during model training, and this trick could bring some improvement of cv metric:\n\n| Model           | CV | Public LB |\n|-----------------|:--------:|:--------:|\n| EfficientNet-B1             |   0.3130   |   0.30   |\n| EfficientNet-B0 (label-refine)      |   0.3102   |   --   |\n\n#### Iteration Steps ####\nIn the label refine training pipeline, I set the iteration equals to 1 for models except for EfficientNet-B1 model. For the EfficientNet-B1 model, I set the iteration equals to 2 for better performance (just a little).\n\n### Final training pipeline\nThe final training pipeline can be concluded: ![Pipeline](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7951864%2Faf2152ac5a9a165a53b5e9c562a373e2%2FLabel-Refine-Pipeline.png?generation=1712843769135040&alt=media)\n\n#### Final Submission ###\nFinally, In order to avoid the possible data drift in two-stage training mode, I selected the teacher model (trained with pseudo-label coarse data and fine data, public LB: 0.29) and the student model (finetuned with pseudo-label fine data, public LB: 0.27) as final models.",
      "votes": 9
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2746849": "This was my first time trying the EEG related task, and I found it to be a highly valuable learning experience. Thanks to Harvard Medical School and Kaggle for hosting this fun competition.\n\n## Data\n### Train Data\nThe input data is duplicate by eeg_id and votes columns, and final obtain 20183 samples in train data. \n```\ndf = pd.read_csv('train.csv')\nTARGETS = df.columns[-6:]\ntrain_df = df.drop_duplicates(subset=['eeg_id'] + list(TARGETS))\n```\nI split this train data into 5-fold by using GroupKFold method with expert_consensus and patient_id label.\n\n### Multi-Modal Input Data\nIn my solution, the input data include eeg signal (1D) and spectrogram (2D). For the spectrogram input, I refer [rafaelzimmermann1's notebook](https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine) to convert eeg to spectrogram, and final combine the exist kaggle spectrogram and converted spectorgram as model's input.\n\n## Model\nThere are three cv models for ensemble:\n+ Model1: EfficientNet-B1 with spectrogram data\nI refer [minhsienweng's notebook](https://www.kaggle.com/code/minhsienweng/train-infer-efficientnetb0-starter) to build and train the model, and I adopt EfficientNet-B1 model for better performance.\n+ Model2: ResNet-1D + EfficientNet-B1 with eeg and spectrogram data\nI refer [nischaydnk's notebook](https://www.kaggle.com/code/nischaydnk/training-multimodal-1d-2d-approach-eegs) to build multi-modal model for eeg and spectrogram data.\n+ Model3: WaveNet + EfficientNet-B1 with eeg and spectrogram data\nBase on the ResNet-1D + EfficientNet-B1 multi-modal model architecture, I replace the ResNet-1D with WaveNet (which refers [abaojiang's notebook](https://www.kaggle.com/code/abaojiang/lb-0-46-dilatedinception-wavenet-training)) model for better processing power for eeg signals.\n\nFinal, I ensemble the prediction results of three cv models by: 0.34 * Model1 + 0.32 * Model2 + 0.34 * Model3\n\n## Key Training Strategies\n### Two-stage training\nI adpated the two-stage training strategy refers to the [seanbearden's notebook](https://www.kaggle.com/code/seanbearden/effnetb0-2-pop-model-train-twice-lb-0-39). And this strategy bring significant public LB metric imporvement in WaveNet and EfficientNet models (for pre-validation), and I find the cv metric for fine data is seem strong correlation with public LB metric:\n| Model           | Public LB |\n|-----------------|:--------:|\n| WaveNet             |   0.46   |\n| WaveNet (two-stage)      |   0.39   |\n| EfficientNet-B0             |   0.42   |\n| EfficientNet-B0 (two-stage)      |   0.34   |\n\n### Label refine training\nAfter two-stage training strategy, I also tried the label refine training strategy according to [rafaelzimmermann1's notebook](https://www.kaggle.com/code/rafaelzimmermann1/no-ensemble-new-spectrograms-label-refine). I tested this strategy and get improvement of local cv metric:\n\n| Model           | CV | Public LB |\n|-----------------|:--------:|:--------:|\n| EfficientNet-B1             |   0.3102   |   --   |\n| EfficientNet-B0 (label-refine)      |   0.3058   |   --   |\n| WaveNet + EfficientNet-B1             |   0.2903   |   --   |\n| WaveNet + EfficientNet-B0 (label-refine)      |   0.2686   |   0.28   |\n\n### Other tricks\n#### CutMix Augmentation\nI used the [CutMix](https://www.kaggle.com/competitions/hms-harmful-brain-activity-classification/discussion/479446) Augmentation during model training, and this trick could bring some improvement of cv metric:\n\n| Model           | CV | Public LB |\n|-----------------|:--------:|:--------:|\n| EfficientNet-B1             |   0.3130   |   0.30   |\n| EfficientNet-B0 (label-refine)      |   0.3102   |   --   |\n\n#### Iteration Steps ####\nIn the label refine training pipeline, I set the iteration equals to 1 for models except for EfficientNet-B1 model. For the EfficientNet-B1 model, I set the iteration equals to 2 for better performance (just a little).\n\n### Final training pipeline\nThe final training pipeline can be concluded: ![Pipeline](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F7951864%2Faf2152ac5a9a165a53b5e9c562a373e2%2FLabel-Refine-Pipeline.png?generation=1712843769135040&alt=media)\n\n#### Final Submission ###\nFinally, In order to avoid the possible data drift in two-stage training mode, I selected the teacher model (trained with pseudo-label coarse data and fine data, public LB: 0.29) and the student model (finetuned with pseudo-label fine data, public LB: 0.27) as final models."
  }
}