{
  "id": 603553,
  "title": "55th Place Solution",
  "url": "/competitions/cmi-detect-behavior-with-sensor-data/discussion/603553",
  "author_name": "SangSong",
  "post_date": "2025-09-03T02:24:25.993000",
  "votes": 10,
  "comment_count": 0,
  "views": 0,
  "content": "<p>First of all, I would like to extend my gratitude to the organizers for hosting this interesting competition. I also appreciate the great notebooks and discussions which I learned a lot from. And congratulate all the winners!</p>\n<p>I set personal theme on this competition that was taking on a challenge in earnest to build CNN models using pytorch. I am pleased that I have achieved some results and achieved my goals.</p>\n<p>I would like to share my solution in the hope that it will be helpful to someone.</p>\n<h1>Sumary</h1>\n<p>I used the following 8 models:</p>\n<table>\n<thead>\n<tr>\n<th>#</th>\n<th>Main Architecture</th>\n<th>Prediction Target</th>\n<th>Used Data</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1</td>\n<td>LSTM (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>2</td>\n<td>LSTM (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>3</td>\n<td>Bert (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>4</td>\n<td>Bert (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>5</td>\n<td>LSTM (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>All</td>\n</tr>\n<tr>\n<td>6</td>\n<td>LSTM (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>All</td>\n</tr>\n<tr>\n<td>7</td>\n<td>Bert (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>All</td>\n</tr>\n<tr>\n<td>8</td>\n<td>Bert (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>All</td>\n</tr>\n</tbody>\n</table>\n<p>IMU only means acc_[x/y/z] and rot_[w/x/y/z] were used for the prediction. All means thm_[1-5] and tof_[1-5]_v[0-63] used for the prediction in addition to the IMU data, i.e., acc_[x/y/z] and rot_[w/x/y/z].</p>\n<p>I combined multi classifier and binary classifier for each main architectures and data to make predictions. For example, in the case using LSTM model and IMU only data, the final prediction probability was calculated as follows:<br>\n$$ p = <br>\n\\begin{cases} <br>\np1 \\times p2 &amp; \\text{(for BFRB-like gestures),} \\\\<br>\np1 \\times (1-p2) &amp; \\text{(for non-BFRB-like gestures),} \\end{cases}$$<br>\nwhere \\(p_1\\) and \\(p_2\\) are the prediction probabilities from the model #1 and #2 respectively. Below is an architecture outline of each models:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2712565%2F8179c7986c5889a54975a89cadd937d4%2FCMI2025_model_architecture.png?generation=1756879033907772&amp;alt=media\" alt=\"\"></p>\n<p>Final prediction was made by blending these models according to weights that was tuned by maximizing CV score with Optuna. For the samples that does not include both thermal and TOF data,<br>\n$$ p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35, $$<br>\nand for the samples that include both thermal and TOF data,<br>\n$$ (p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35) \\times 0.33 + (p_{\\text{LSTM, All}} \\times 0.6 + p_{\\text{Bert, All}} \\times 0.4) \\times 0.67. $$<br>\nMy CV and LB score heavily pushed up by bleding not only predictions from all-data based models but also imu-only-data based models when both thermal and TOF data were available.</p>\n<h1>Details</h1>\n<h2>Validation Strategy</h2>\n<p>The data was splitted into 5 folds by StratifiedGroupKFold with groups=subject.</p>\n<h2>Feature Engineering</h2>\n<ul>\n<li>Magnitude of acc features, i.e, \\(\\sqrt{ {\\text{acc}_\\text{x}}^2 + {\\text{acc}_\\text{y}}^2 + {\\text{acc}_\\text{z}}^2 }\\).</li>\n<li>Angular velocities.</li>\n<li>Differences of acc_[x/y/z] and rot_[w].</li>\n<li>Mean, standard deviation, maximum and minimum of thm_[1-5] and tof_[i]_v[0-63] for each i.</li>\n</ul>\n<h2>Preprocessing</h2>\n<ul>\n<li>Treatment of NaN's: Applied ffill, bfill and fillna(0) in this order.</li>\n<li>Normalization: StandardScaler was used.</li>\n<li>Padding/Truncating: zeros were added to the start of sequence or truncated the start of sequence to make the length 100.</li>\n</ul>\n<h2>Post-processing</h2>\n<p>Not used at all.</p>\n<h2>Data Augmentation</h2>\n<p>Applied mixup with alpha=0.2 for multi-classifier models.</p>\n<h2>Training Configuration</h2>\n<ul>\n<li>Optimizer: Adam with lr=1e-3 and weight_decay=3e-3.</li>\n<li>Scheduler: Cosine LR Scheduler with 20 epochs warm-up.</li>\n<li>Batch Size: 256 for LSTM-used models and 128 for Bert-used models.</li>\n<li>EMA: decay=0.999.</li>\n</ul>\n<h2>Results</h2>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>cv (for IMU only)</th>\n<th>cv (for All data)</th>\n<th>Public</th>\n<th>Private</th>\n<th>Note</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Blend Weight 1</td>\n<td>0.821</td>\n<td>0.866</td>\n<td>0.855</td>\n<td>0.840</td>\n<td>Selected; final submission</td>\n</tr>\n<tr>\n<td>Blend Weight 2</td>\n<td>??</td>\n<td>??</td>\n<td>0.854</td>\n<td>0.842</td>\n<td>Not selected; my best private score submission</td>\n</tr>\n<tr>\n<td>LSTM-used model only</td>\n<td>0.814</td>\n<td>??</td>\n<td>0.848</td>\n<td>0.838</td>\n<td>Not selected</td>\n</tr>\n</tbody>\n</table>\n<h1>Conclusion</h1>\n<p>It was my first challenge to consider and build NN models using pytorch myself in earnest. I learned a lot from this competition. Regrettably, I could not come up with valiable post-processing, but I really enjoyed the competiton. Thank you for reading!</p>",
  "messages": [
    {
      "id": 3280665,
      "postDate": "2025-09-03T02:24:25.993Z",
      "content": "<p>First of all, I would like to extend my gratitude to the organizers for hosting this interesting competition. I also appreciate the great notebooks and discussions which I learned a lot from. And congratulate all the winners!</p>\n<p>I set personal theme on this competition that was taking on a challenge in earnest to build CNN models using pytorch. I am pleased that I have achieved some results and achieved my goals.</p>\n<p>I would like to share my solution in the hope that it will be helpful to someone.</p>\n<h1>Sumary</h1>\n<p>I used the following 8 models:</p>\n<table>\n<thead>\n<tr>\n<th>#</th>\n<th>Main Architecture</th>\n<th>Prediction Target</th>\n<th>Used Data</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1</td>\n<td>LSTM (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>2</td>\n<td>LSTM (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>3</td>\n<td>Bert (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>4</td>\n<td>Bert (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>IMU only</td>\n</tr>\n<tr>\n<td>5</td>\n<td>LSTM (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>All</td>\n</tr>\n<tr>\n<td>6</td>\n<td>LSTM (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>All</td>\n</tr>\n<tr>\n<td>7</td>\n<td>Bert (Multi Classifier)</td>\n<td>18 gesutures</td>\n<td>All</td>\n</tr>\n<tr>\n<td>8</td>\n<td>Bert (Binary Classifier)</td>\n<td>BFRB-like gestures or not</td>\n<td>All</td>\n</tr>\n</tbody>\n</table>\n<p>IMU only means acc_[x/y/z] and rot_[w/x/y/z] were used for the prediction. All means thm_[1-5] and tof_[1-5]_v[0-63] used for the prediction in addition to the IMU data, i.e., acc_[x/y/z] and rot_[w/x/y/z].</p>\n<p>I combined multi classifier and binary classifier for each main architectures and data to make predictions. For example, in the case using LSTM model and IMU only data, the final prediction probability was calculated as follows:<br>\n$$ p = <br>\n\\begin{cases} <br>\np1 \\times p2 &amp; \\text{(for BFRB-like gestures),} \\\\<br>\np1 \\times (1-p2) &amp; \\text{(for non-BFRB-like gestures),} \\end{cases}$$<br>\nwhere \\(p_1\\) and \\(p_2\\) are the prediction probabilities from the model #1 and #2 respectively. Below is an architecture outline of each models:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2712565%2F8179c7986c5889a54975a89cadd937d4%2FCMI2025_model_architecture.png?generation=1756879033907772&amp;alt=media\" alt=\"\"></p>\n<p>Final prediction was made by blending these models according to weights that was tuned by maximizing CV score with Optuna. For the samples that does not include both thermal and TOF data,<br>\n$$ p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35, $$<br>\nand for the samples that include both thermal and TOF data,<br>\n$$ (p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35) \\times 0.33 + (p_{\\text{LSTM, All}} \\times 0.6 + p_{\\text{Bert, All}} \\times 0.4) \\times 0.67. $$<br>\nMy CV and LB score heavily pushed up by bleding not only predictions from all-data based models but also imu-only-data based models when both thermal and TOF data were available.</p>\n<h1>Details</h1>\n<h2>Validation Strategy</h2>\n<p>The data was splitted into 5 folds by StratifiedGroupKFold with groups=subject.</p>\n<h2>Feature Engineering</h2>\n<ul>\n<li>Magnitude of acc features, i.e, \\(\\sqrt{ {\\text{acc}_\\text{x}}^2 + {\\text{acc}_\\text{y}}^2 + {\\text{acc}_\\text{z}}^2 }\\).</li>\n<li>Angular velocities.</li>\n<li>Differences of acc_[x/y/z] and rot_[w].</li>\n<li>Mean, standard deviation, maximum and minimum of thm_[1-5] and tof_[i]_v[0-63] for each i.</li>\n</ul>\n<h2>Preprocessing</h2>\n<ul>\n<li>Treatment of NaN's: Applied ffill, bfill and fillna(0) in this order.</li>\n<li>Normalization: StandardScaler was used.</li>\n<li>Padding/Truncating: zeros were added to the start of sequence or truncated the start of sequence to make the length 100.</li>\n</ul>\n<h2>Post-processing</h2>\n<p>Not used at all.</p>\n<h2>Data Augmentation</h2>\n<p>Applied mixup with alpha=0.2 for multi-classifier models.</p>\n<h2>Training Configuration</h2>\n<ul>\n<li>Optimizer: Adam with lr=1e-3 and weight_decay=3e-3.</li>\n<li>Scheduler: Cosine LR Scheduler with 20 epochs warm-up.</li>\n<li>Batch Size: 256 for LSTM-used models and 128 for Bert-used models.</li>\n<li>EMA: decay=0.999.</li>\n</ul>\n<h2>Results</h2>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>cv (for IMU only)</th>\n<th>cv (for All data)</th>\n<th>Public</th>\n<th>Private</th>\n<th>Note</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Blend Weight 1</td>\n<td>0.821</td>\n<td>0.866</td>\n<td>0.855</td>\n<td>0.840</td>\n<td>Selected; final submission</td>\n</tr>\n<tr>\n<td>Blend Weight 2</td>\n<td>??</td>\n<td>??</td>\n<td>0.854</td>\n<td>0.842</td>\n<td>Not selected; my best private score submission</td>\n</tr>\n<tr>\n<td>LSTM-used model only</td>\n<td>0.814</td>\n<td>??</td>\n<td>0.848</td>\n<td>0.838</td>\n<td>Not selected</td>\n</tr>\n</tbody>\n</table>\n<h1>Conclusion</h1>\n<p>It was my first challenge to consider and build NN models using pytorch myself in earnest. I learned a lot from this competition. Regrettably, I could not come up with valiable post-processing, but I really enjoyed the competiton. Thank you for reading!</p>",
      "rawMarkdown": "First of all, I would like to extend my gratitude to the organizers for hosting this interesting competition. I also appreciate the great notebooks and discussions which I learned a lot from. And congratulate all the winners!\n\nI set personal theme on this competition that was taking on a challenge in earnest to build CNN models using pytorch. I am pleased that I have achieved some results and achieved my goals.\n\nI would like to share my solution in the hope that it will be helpful to someone.\n\n# Sumary\nI used the following 8 models:\n| # | Main Architecture | Prediction Target | Used Data |\n| ---| --- | --- | --- |\n| 1 | LSTM (Multi Classifier) | 18 gesutures | IMU only |\n| 2 | LSTM (Binary Classifier) | BFRB-like gestures or not | IMU only |\n| 3 | Bert (Multi Classifier) | 18 gesutures | IMU only |\n| 4 | Bert (Binary Classifier) | BFRB-like gestures or not | IMU only |\n| 5 | LSTM (Multi Classifier) | 18 gesutures | All |\n| 6 | LSTM (Binary Classifier) | BFRB-like gestures or not | All |\n| 7 | Bert (Multi Classifier) | 18 gesutures | All |\n| 8 | Bert (Binary Classifier) | BFRB-like gestures or not | All |\n\nIMU only means acc_[x/y/z] and rot_[w/x/y/z] were used for the prediction. All means thm_[1-5] and tof_[1-5]\\_v[0-63] used for the prediction in addition to the IMU data, i.e., acc_[x/y/z] and rot_[w/x/y/z].\n\nI combined multi classifier and binary classifier for each main architectures and data to make predictions. For example, in the case using LSTM model and IMU only data, the final prediction probability was calculated as follows:\n$$ p = \n\\begin{cases} \np1 \\times p2 & \\text{(for BFRB-like gestures),} \\\\\\\\\np1 \\times (1-p2) & \\text{(for non-BFRB-like gestures),} \\end{cases}$$\nwhere \\\\(p_1\\\\) and \\\\(p_2\\\\) are the prediction probabilities from the model #1 and #2 respectively. Below is an architecture outline of each models:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2712565%2F8179c7986c5889a54975a89cadd937d4%2FCMI2025_model_architecture.png?generation=1756879033907772&alt=media)\n\nFinal prediction was made by blending these models according to weights that was tuned by maximizing CV score with Optuna. For the samples that does not include both thermal and TOF data,\n$$ p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35, $$\nand for the samples that include both thermal and TOF data,\n$$ (p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35) \\times 0.33 + (p_{\\text{LSTM, All}} \\times 0.6 + p_{\\text{Bert, All}} \\times 0.4) \\times 0.67. $$\nMy CV and LB score heavily pushed up by bleding not only predictions from all-data based models but also imu-only-data based models when both thermal and TOF data were available.\n\n# Details\n\n## Validation Strategy\n\nThe data was splitted into 5 folds by StratifiedGroupKFold with groups=subject.\n\n## Feature Engineering\n\n- Magnitude of acc features, i.e, \\\\(\\sqrt{ {\\text{acc}\\_\\text{x}}^2 + {\\text{acc}\\_\\text{y}}^2 + {\\text{acc}\\_\\text{z}}^2 }\\\\).\n- Angular velocities.\n- Differences of acc_[x/y/z] and rot_[w].\n- Mean, standard deviation, maximum and minimum of thm\\_[1-5] and tof_[i]\\_v[0-63] for each i.\n\n## Preprocessing \n\n- Treatment of NaN's: Applied ffill, bfill and fillna(0) in this order.\n- Normalization: StandardScaler was used.\n- Padding/Truncating: zeros were added to the start of sequence or truncated the start of sequence to make the length 100.\n\n## Post-processing\n\nNot used at all.\n\n## Data Augmentation\nApplied mixup with alpha=0.2 for multi-classifier models.\n\n## Training Configuration\n\n- Optimizer: Adam with lr=1e-3 and weight_decay=3e-3.\n- Scheduler: Cosine LR Scheduler with 20 epochs warm-up.\n- Batch Size: 256 for LSTM-used models and 128 for Bert-used models.\n- EMA: decay=0.999.\n\n## Results\n\n|  | cv (for IMU only) | cv (for All data) | Public | Private | Note |\n| --- | --- | --- | --- | --- |\n| Blend Weight 1 | 0.821 | 0.866 | 0.855 | 0.840 | Selected; final submission |\n| Blend Weight 2 | ?? | ?? | 0.854 | 0.842 | Not selected; my best private score submission |\n| LSTM-used model only | 0.814 | ?? | 0.848 | 0.838 | Not selected |\n\n# Conclusion\nIt was my first challenge to consider and build NN models using pytorch myself in earnest. I learned a lot from this competition. Regrettably, I could not come up with valiable post-processing, but I really enjoyed the competiton. Thank you for reading!\n",
      "votes": 10
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "3280665": "First of all, I would like to extend my gratitude to the organizers for hosting this interesting competition. I also appreciate the great notebooks and discussions which I learned a lot from. And congratulate all the winners!\n\nI set personal theme on this competition that was taking on a challenge in earnest to build CNN models using pytorch. I am pleased that I have achieved some results and achieved my goals.\n\nI would like to share my solution in the hope that it will be helpful to someone.\n\n# Sumary\nI used the following 8 models:\n| # | Main Architecture | Prediction Target | Used Data |\n| ---| --- | --- | --- |\n| 1 | LSTM (Multi Classifier) | 18 gesutures | IMU only |\n| 2 | LSTM (Binary Classifier) | BFRB-like gestures or not | IMU only |\n| 3 | Bert (Multi Classifier) | 18 gesutures | IMU only |\n| 4 | Bert (Binary Classifier) | BFRB-like gestures or not | IMU only |\n| 5 | LSTM (Multi Classifier) | 18 gesutures | All |\n| 6 | LSTM (Binary Classifier) | BFRB-like gestures or not | All |\n| 7 | Bert (Multi Classifier) | 18 gesutures | All |\n| 8 | Bert (Binary Classifier) | BFRB-like gestures or not | All |\n\nIMU only means acc_[x/y/z] and rot_[w/x/y/z] were used for the prediction. All means thm_[1-5] and tof_[1-5]\\_v[0-63] used for the prediction in addition to the IMU data, i.e., acc_[x/y/z] and rot_[w/x/y/z].\n\nI combined multi classifier and binary classifier for each main architectures and data to make predictions. For example, in the case using LSTM model and IMU only data, the final prediction probability was calculated as follows:\n$$ p = \n\\begin{cases} \np1 \\times p2 & \\text{(for BFRB-like gestures),} \\\\\\\\\np1 \\times (1-p2) & \\text{(for non-BFRB-like gestures),} \\end{cases}$$\nwhere \\\\(p_1\\\\) and \\\\(p_2\\\\) are the prediction probabilities from the model #1 and #2 respectively. Below is an architecture outline of each models:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F2712565%2F8179c7986c5889a54975a89cadd937d4%2FCMI2025_model_architecture.png?generation=1756879033907772&alt=media)\n\nFinal prediction was made by blending these models according to weights that was tuned by maximizing CV score with Optuna. For the samples that does not include both thermal and TOF data,\n$$ p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35, $$\nand for the samples that include both thermal and TOF data,\n$$ (p_{\\text{LSTM, IMU}} \\times 0.65 + p_{\\text{Bert, IMU}} \\times 0.35) \\times 0.33 + (p_{\\text{LSTM, All}} \\times 0.6 + p_{\\text{Bert, All}} \\times 0.4) \\times 0.67. $$\nMy CV and LB score heavily pushed up by bleding not only predictions from all-data based models but also imu-only-data based models when both thermal and TOF data were available.\n\n# Details\n\n## Validation Strategy\n\nThe data was splitted into 5 folds by StratifiedGroupKFold with groups=subject.\n\n## Feature Engineering\n\n- Magnitude of acc features, i.e, \\\\(\\sqrt{ {\\text{acc}\\_\\text{x}}^2 + {\\text{acc}\\_\\text{y}}^2 + {\\text{acc}\\_\\text{z}}^2 }\\\\).\n- Angular velocities.\n- Differences of acc_[x/y/z] and rot_[w].\n- Mean, standard deviation, maximum and minimum of thm\\_[1-5] and tof_[i]\\_v[0-63] for each i.\n\n## Preprocessing \n\n- Treatment of NaN's: Applied ffill, bfill and fillna(0) in this order.\n- Normalization: StandardScaler was used.\n- Padding/Truncating: zeros were added to the start of sequence or truncated the start of sequence to make the length 100.\n\n## Post-processing\n\nNot used at all.\n\n## Data Augmentation\nApplied mixup with alpha=0.2 for multi-classifier models.\n\n## Training Configuration\n\n- Optimizer: Adam with lr=1e-3 and weight_decay=3e-3.\n- Scheduler: Cosine LR Scheduler with 20 epochs warm-up.\n- Batch Size: 256 for LSTM-used models and 128 for Bert-used models.\n- EMA: decay=0.999.\n\n## Results\n\n|  | cv (for IMU only) | cv (for All data) | Public | Private | Note |\n| --- | --- | --- | --- | --- |\n| Blend Weight 1 | 0.821 | 0.866 | 0.855 | 0.840 | Selected; final submission |\n| Blend Weight 2 | ?? | ?? | 0.854 | 0.842 | Not selected; my best private score submission |\n| LSTM-used model only | 0.814 | ?? | 0.848 | 0.838 | Not selected |\n\n# Conclusion\nIt was my first challenge to consider and build NN models using pytorch myself in earnest. I learned a lot from this competition. Regrettably, I could not come up with valiable post-processing, but I really enjoyed the competiton. Thank you for reading!\n"
  },
  "complete": true,
  "source": "existing_discussion",
  "competition_id": 102335,
  "competition_slug": "cmi-detect-behavior-with-sensor-data",
  "team_id": 13917283,
  "solution_url": "/competitions/cmi-detect-behavior-with-sensor-data/writeups/private-55th-place-solution"
}