{
  "id": 603566,
  "title": "Short Note on Converting Left-handed Data into Pseudo Right-handed Data",
  "url": "/competitions/cmi-detect-behavior-with-sensor-data/discussion/603566",
  "author_name": "Bilzard",
  "post_date": "2025-09-03T04:31:33.121000",
  "votes": 17,
  "comment_count": 4,
  "views": 0,
  "content": "<h2>Summary</h2>\n<p>Since left handed data contains only ~10% of training data. So I hypothesized making left-handed sensor data <strong>looks similar</strong> to right-handed sensor data will improve the result.</p>\n<h2>Approach</h2>\n<p>Below is the hand note of my approach.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F6eda71e63604f81d8684b45636e9439b%2Fwhiteboard.png?generation=1756873163829292&amp;alt=media\" alt=\"\"></p>\n<h2>Result</h2>\n<p>For example, below is the result of ToF statistics before and after invariant transform. The statistics improved slightly better (MAE: 9.67 -&gt; 7.75).</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F3382172f16fce862379f2c186497702e%2Finvariant_transform_ToF.png?generation=1756873115879969&amp;alt=media\" alt=\"\"></p>\n<h2>Code snippet</h2>\n<p>For example, the transform of ToF data is like this:</p>\n<pre><code> () -&gt; [np.ndarray, np.ndarray]:\n    \n    tof[:, ] = np.rot90(tof[:, ], k=-, axes=(-, -))\n    tof[:, ] = np.rot90(tof[:, ], k=-, axes=(-, -))\n\n    \n     subject  FLIPPED_SUBJECTS:\n        \n        tmp = tof.copy()\n        tof[:, [, ], :, :] = tmp[:, [, ], :, :]\n        \n        tof[:, [, ], :, :] = tmp[:, [, ], :, :]\n\n        \n        tof = np.rot90(tof, k=-, axes=(-, -))\n\n        \n        tmp = thermo.copy()\n        thermo[:, [, ]] = tmp[:, [, ]]\n        thermo[:, [, ]] = tmp[:, [, ]]\n\n     handedness == :\n        \n        tof = np.flip(tof, axis=-)\n\n        \n        tmp = tof.copy()\n        tof[:, [, ], :, :] = tmp[:, [, ], :, :]\n\n        \n        tmp = thermo.copy()\n        thermo[:, [, ]] = tmp[:, [, ]]\n\n     tof, thermo\n</code></pre>",
  "messages": [
    {
      "id": 3280723,
      "postDate": "2025-09-03T04:31:33.120Z",
      "content": "<h2>Summary</h2>\n<p>Since left handed data contains only ~10% of training data. So I hypothesized making left-handed sensor data <strong>looks similar</strong> to right-handed sensor data will improve the result.</p>\n<h2>Approach</h2>\n<p>Below is the hand note of my approach.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F6eda71e63604f81d8684b45636e9439b%2Fwhiteboard.png?generation=1756873163829292&amp;alt=media\" alt=\"\"></p>\n<h2>Result</h2>\n<p>For example, below is the result of ToF statistics before and after invariant transform. The statistics improved slightly better (MAE: 9.67 -&gt; 7.75).</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F3382172f16fce862379f2c186497702e%2Finvariant_transform_ToF.png?generation=1756873115879969&amp;alt=media\" alt=\"\"></p>\n<h2>Code snippet</h2>\n<p>For example, the transform of ToF data is like this:</p>\n<pre><code> () -&gt; [np.ndarray, np.ndarray]:\n    \n    tof[:, ] = np.rot90(tof[:, ], k=-, axes=(-, -))\n    tof[:, ] = np.rot90(tof[:, ], k=-, axes=(-, -))\n\n    \n     subject  FLIPPED_SUBJECTS:\n        \n        tmp = tof.copy()\n        tof[:, [, ], :, :] = tmp[:, [, ], :, :]\n        \n        tof[:, [, ], :, :] = tmp[:, [, ], :, :]\n\n        \n        tof = np.rot90(tof, k=-, axes=(-, -))\n\n        \n        tmp = thermo.copy()\n        thermo[:, [, ]] = tmp[:, [, ]]\n        thermo[:, [, ]] = tmp[:, [, ]]\n\n     handedness == :\n        \n        tof = np.flip(tof, axis=-)\n\n        \n        tmp = tof.copy()\n        tof[:, [, ], :, :] = tmp[:, [, ], :, :]\n\n        \n        tmp = thermo.copy()\n        thermo[:, [, ]] = tmp[:, [, ]]\n\n     tof, thermo\n</code></pre>",
      "rawMarkdown": "## Summary\n\nSince left handed data contains only ~10% of training data. So I hypothesized making left-handed sensor data **looks similar** to right-handed sensor data will improve the result.\n\n## Approach\n\nBelow is the hand note of my approach.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F6eda71e63604f81d8684b45636e9439b%2Fwhiteboard.png?generation=1756873163829292&alt=media)\n\n## Result\n\nFor example, below is the result of ToF statistics before and after invariant transform. The statistics improved slightly better (MAE: 9.67 -> 7.75).\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F3382172f16fce862379f2c186497702e%2Finvariant_transform_ToF.png?generation=1756873115879969&alt=media)\n\n## Code snippet\n\nFor example, the transform of ToF data is like this:\n\n```python\ndef apply_tof_thermo_invariant_transform(\n    tof: np.ndarray,\n    thermo: np.ndarray,\n    subject: str,\n    handedness: int,\n) -> tuple[np.ndarray, np.ndarray]:\n    # rotate(-90) ToF 3 and 5\n    tof[:, 2] = np.rot90(tof[:, 2], k=-1, axes=(-2, -1))\n    tof[:, 4] = np.rot90(tof[:, 4], k=-1, axes=(-2, -1))\n\n    # correction of ToF/Thermo for subject waring watch upside-down\n    if subject in FLIPPED_SUBJECTS:\n        # Swap ToF 3 and 5\n        tmp = tof.copy()\n        tof[:, [2, 4], :, :] = tmp[:, [4, 2], :, :]\n        # SWAP ToF 2 and 4\n        tof[:, [1, 3], :, :] = tmp[:, [3, 1], :, :]\n\n        # rot180 ToF 1-5\n        tof = np.rot90(tof, k=-2, axes=(-2, -1))\n\n        # swap Thermo 3 and 5\n        tmp = thermo.copy()\n        thermo[:, [2, 4]] = tmp[:, [4, 2]]\n        thermo[:, [1, 3]] = tmp[:, [3, 1]]\n\n    elif handedness == 0:\n        # Flip L/R\n        tof = np.flip(tof, axis=-1)\n\n        # Swap ToF 3 and 5\n        tmp = tof.copy()\n        tof[:, [2, 4], :, :] = tmp[:, [4, 2], :, :]\n\n        # Swap Thermo 3 and 5\n        tmp = thermo.copy()\n        thermo[:, [2, 4]] = tmp[:, [4, 2]]\n\n    return tof, thermo\n\n```",
      "votes": 17
    },
    {
      "id": 3280726,
      "postDate": "2025-09-03T04:37:54.900Z",
      "content": "<p>We did the same thing,but there was nothing major since left handed people were too low in train and test (only 3 subj in test)</p>",
      "rawMarkdown": "We did the same thing,but there was nothing major since left handed people were too low in train and test (only 3 subj in test)",
      "votes": 1,
      "replies": [
        {
          "id": 3280728,
          "postDate": "2025-09-03T04:44:53.757Z",
          "content": "<p>Thought I didn't probe much, but 3 subjects means 3 * 18 * 4 *2 = 432 samples, which is ~12% of 3500 sequence.<br>\nI believe it should somehow affect LB, but if NaN value exists in demographic column, it should harm this approach (like it discussed below).</p>\n<p><a href=\"https://www.kaggle.com/competitions/cmi-detect-behavior-with-sensor-data/discussion/603543\" target=\"_blank\">https://www.kaggle.com/competitions/cmi-detect-behavior-with-sensor-data/discussion/603543</a></p>",
          "rawMarkdown": "Thought I didn't probe much, but 3 subjects means 3 * 18 * 4 *2 = 432 samples, which is ~12% of 3500 sequence.\nI believe it should somehow affect LB, but if NaN value exists in demographic column, it should harm this approach (like it discussed below).\n\nhttps://www.kaggle.com/competitions/cmi-detect-behavior-with-sensor-data/discussion/603543",
          "replies": [
            {
              "id": 3280736,
              "postDate": "2025-09-03T05:04:23.960Z",
              "content": "<p>yeah it yielded an improvement, but the idea what I meant It wasn't very significant</p>",
              "rawMarkdown": "yeah it yielded an improvement, but the idea what I meant It wasn't very significant"
            }
          ]
        }
      ]
    },
    {
      "id": 3280778,
      "postDate": "2025-09-03T06:26:00Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 3280726,
      "author_name": "Taha_Alshatiri",
      "author_url": "",
      "post_date": "2025-09-03T04:37:54.900000",
      "content": "<p>We did the same thing,but there was nothing major since left handed people were too low in train and test (only 3 subj in test)</p>",
      "votes": 1,
      "replies": [
        {
          "id": 3280728,
          "author_name": "Bilzard",
          "author_url": "",
          "post_date": "2025-09-03T04:44:53.757000",
          "content": "<p>Thought I didn't probe much, but 3 subjects means 3 * 18 * 4 *2 = 432 samples, which is ~12% of 3500 sequence.<br>\nI believe it should somehow affect LB, but if NaN value exists in demographic column, it should harm this approach (like it discussed below).</p>\n<p><a href=\"https://www.kaggle.com/competitions/cmi-detect-behavior-with-sensor-data/discussion/603543\" target=\"_blank\">https://www.kaggle.com/competitions/cmi-detect-behavior-with-sensor-data/discussion/603543</a></p>",
          "votes": 0,
          "replies": [
            {
              "id": 3280736,
              "author_name": "Taha_Alshatiri",
              "author_url": "",
              "post_date": "2025-09-03T05:04:23.960000",
              "content": "<p>yeah it yielded an improvement, but the idea what I meant It wasn't very significant</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 3280778,
      "author_name": "",
      "author_url": "",
      "post_date": "2025-09-03T06:26:00",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "3280723": "## Summary\n\nSince left handed data contains only ~10% of training data. So I hypothesized making left-handed sensor data **looks similar** to right-handed sensor data will improve the result.\n\n## Approach\n\nBelow is the hand note of my approach.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F6eda71e63604f81d8684b45636e9439b%2Fwhiteboard.png?generation=1756873163829292&alt=media)\n\n## Result\n\nFor example, below is the result of ToF statistics before and after invariant transform. The statistics improved slightly better (MAE: 9.67 -> 7.75).\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4910466%2F3382172f16fce862379f2c186497702e%2Finvariant_transform_ToF.png?generation=1756873115879969&alt=media)\n\n## Code snippet\n\nFor example, the transform of ToF data is like this:\n\n```python\ndef apply_tof_thermo_invariant_transform(\n    tof: np.ndarray,\n    thermo: np.ndarray,\n    subject: str,\n    handedness: int,\n) -> tuple[np.ndarray, np.ndarray]:\n    # rotate(-90) ToF 3 and 5\n    tof[:, 2] = np.rot90(tof[:, 2], k=-1, axes=(-2, -1))\n    tof[:, 4] = np.rot90(tof[:, 4], k=-1, axes=(-2, -1))\n\n    # correction of ToF/Thermo for subject waring watch upside-down\n    if subject in FLIPPED_SUBJECTS:\n        # Swap ToF 3 and 5\n        tmp = tof.copy()\n        tof[:, [2, 4], :, :] = tmp[:, [4, 2], :, :]\n        # SWAP ToF 2 and 4\n        tof[:, [1, 3], :, :] = tmp[:, [3, 1], :, :]\n\n        # rot180 ToF 1-5\n        tof = np.rot90(tof, k=-2, axes=(-2, -1))\n\n        # swap Thermo 3 and 5\n        tmp = thermo.copy()\n        thermo[:, [2, 4]] = tmp[:, [4, 2]]\n        thermo[:, [1, 3]] = tmp[:, [3, 1]]\n\n    elif handedness == 0:\n        # Flip L/R\n        tof = np.flip(tof, axis=-1)\n\n        # Swap ToF 3 and 5\n        tmp = tof.copy()\n        tof[:, [2, 4], :, :] = tmp[:, [4, 2], :, :]\n\n        # Swap Thermo 3 and 5\n        tmp = thermo.copy()\n        thermo[:, [2, 4]] = tmp[:, [4, 2]]\n\n    return tof, thermo\n\n```",
    "3280726": "We did the same thing,but there was nothing major since left handed people were too low in train and test (only 3 subj in test)",
    "3280778": ""
  }
}