{
  "id": 486275,
  "title": "Way to create new features to 1-D model",
  "url": "/competitions/hms-harmful-brain-activity-classification/discussion/486275",
  "author_name": "RogerOcean",
  "post_date": "2024-03-24T09:06:40.996000",
  "votes": 8,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Dear kagglers:<br>\nI have been browsing past competition solutions to find new ideas, and I found many interesting ideas that can be borrowed from this competition. <br>\nFor example, in this solution <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/416248\" target=\"_blank\">12th place solution: Simple features and LSTM</a> of this game: <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/overview\" target=\"_blank\">Parkinson's Freezing of Gait Prediction</a> , we can create many features that can be used for 1D models. <strong>The essence of this function is to perform block aggregation on each channel based on the time dimension, which can generate many new features.</strong> <br>\nI used an open-source solution as a foundation and found that there is room for improvement in generating features sensibly. Everyone can give it a try.<br>\nLastly, a big thank you to the original author🥳</p>\n<pre><code> ():\n   ch = x.shape[] \n   input_size = x.shape[]\n   pad = target_size - input_size % target_size\n   factor = (input_size + pad) / input_size\n   x = np.array([ndi.zoom(xi, zoom=factor, mode=)  xi  x])\n   x = x.reshape((ch, target_size, -))\n   res = {} \n   res[] = np.mean(x, axis=).reshape(ch, -)\n   res[] = np.(x, axis=).reshape(ch, -)\n   res[] = np.(x, axis=).reshape(ch, -)\n   res[] = np.median(x, axis=).reshape(ch, -)\n   res[] = np.sqrt(np.var(x, axis=).reshape(ch, -))\n    use_percentile_feat:\n        p  [, , , , , ]:\n           res[] = np.percentile(x, [p], axis=).reshape(ch, -)\n    res\n</code></pre>",
  "messages": [
    {
      "id": 2713564,
      "postDate": "2024-03-24T09:06:40.997Z",
      "content": "<p>Dear kagglers:<br>\nI have been browsing past competition solutions to find new ideas, and I found many interesting ideas that can be borrowed from this competition. <br>\nFor example, in this solution <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/416248\" target=\"_blank\">12th place solution: Simple features and LSTM</a> of this game: <a href=\"https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/overview\" target=\"_blank\">Parkinson's Freezing of Gait Prediction</a> , we can create many features that can be used for 1D models. <strong>The essence of this function is to perform block aggregation on each channel based on the time dimension, which can generate many new features.</strong> <br>\nI used an open-source solution as a foundation and found that there is room for improvement in generating features sensibly. Everyone can give it a try.<br>\nLastly, a big thank you to the original author🥳</p>\n<pre><code> ():\n   ch = x.shape[] \n   input_size = x.shape[]\n   pad = target_size - input_size % target_size\n   factor = (input_size + pad) / input_size\n   x = np.array([ndi.zoom(xi, zoom=factor, mode=)  xi  x])\n   x = x.reshape((ch, target_size, -))\n   res = {} \n   res[] = np.mean(x, axis=).reshape(ch, -)\n   res[] = np.(x, axis=).reshape(ch, -)\n   res[] = np.(x, axis=).reshape(ch, -)\n   res[] = np.median(x, axis=).reshape(ch, -)\n   res[] = np.sqrt(np.var(x, axis=).reshape(ch, -))\n    use_percentile_feat:\n        p  [, , , , , ]:\n           res[] = np.percentile(x, [p], axis=).reshape(ch, -)\n    res\n</code></pre>",
      "rawMarkdown": "\nDear kagglers:\n\nI have been browsing past competition solutions to find new ideas, and I found many interesting ideas that can be borrowed from this competition. \n\nFor example, in this solution [12th place solution: Simple features and LSTM](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/416248) of this game: [Parkinson's Freezing of Gait Prediction](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/overview) , we can create many features that can be used for 1D models. **The essence of this function is to perform block aggregation on each channel based on the time dimension, which can generate many new features.** \n\nI used an open-source solution as a foundation and found that there is room for improvement in generating features sensibly. Everyone can give it a try.\n\nLastly, a big thank you to the original author🥳\n\n```python\n\ndef resize_func(x, target_size=2048, use_percentile_feat=False):\n    ch = x.shape[0] \n    input_size = x.shape[1]\n\n    pad = target_size - input_size % target_size\n    factor = (input_size + pad) / input_size\n\n    x = np.array([ndi.zoom(xi, zoom=factor, mode='reflect') for xi in x])\n    x = x.reshape((ch, target_size, -1))\n\n    res = {} \n    res['mean'] = np.mean(x, axis=2).reshape(ch, -1)\n    res['max'] = np.max(x, axis=2).reshape(ch, -1)\n    res['min'] = np.min(x, axis=2).reshape(ch, -1)\n    res['med'] = np.median(x, axis=2).reshape(ch, -1)\n    res['std'] = np.sqrt(np.var(x, axis=2).reshape(ch, -1))\n    if use_percentile_feat:\n        for p in [15, 30, 45, 60, 75, 90]:\n            res[f\"p{p}\"] = np.percentile(x, [p], axis=2).reshape(ch, -1)\n\n    return res\n\n```\n\n\n\n\n\n\n",
      "votes": 8
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2713564": "\nDear kagglers:\n\nI have been browsing past competition solutions to find new ideas, and I found many interesting ideas that can be borrowed from this competition. \n\nFor example, in this solution [12th place solution: Simple features and LSTM](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/discussion/416248) of this game: [Parkinson's Freezing of Gait Prediction](https://www.kaggle.com/competitions/tlvmc-parkinsons-freezing-gait-prediction/overview) , we can create many features that can be used for 1D models. **The essence of this function is to perform block aggregation on each channel based on the time dimension, which can generate many new features.** \n\nI used an open-source solution as a foundation and found that there is room for improvement in generating features sensibly. Everyone can give it a try.\n\nLastly, a big thank you to the original author🥳\n\n```python\n\ndef resize_func(x, target_size=2048, use_percentile_feat=False):\n    ch = x.shape[0] \n    input_size = x.shape[1]\n\n    pad = target_size - input_size % target_size\n    factor = (input_size + pad) / input_size\n\n    x = np.array([ndi.zoom(xi, zoom=factor, mode='reflect') for xi in x])\n    x = x.reshape((ch, target_size, -1))\n\n    res = {} \n    res['mean'] = np.mean(x, axis=2).reshape(ch, -1)\n    res['max'] = np.max(x, axis=2).reshape(ch, -1)\n    res['min'] = np.min(x, axis=2).reshape(ch, -1)\n    res['med'] = np.median(x, axis=2).reshape(ch, -1)\n    res['std'] = np.sqrt(np.var(x, axis=2).reshape(ch, -1))\n    if use_percentile_feat:\n        for p in [15, 30, 45, 60, 75, 90]:\n            res[f\"p{p}\"] = np.percentile(x, [p], axis=2).reshape(ch, -1)\n\n    return res\n\n```\n\n\n\n\n\n\n"
  }
}