{
  "id": 576465,
  "title": "How to ensemble YOLO predictions",
  "url": "/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/576465",
  "author_name": "",
  "post_date": "2025-05-05T10:57:22.484119700Z",
  "votes": 9,
  "comment_count": 3,
  "views": 0,
  "content": "<p>I know that many of you are getting good results with single models, but we all know that in Kaggle competitions, ensembling predictions from multiple models often leads to better scores. However, in this competition, I'm not sure whether ensembling makes sense since I've not been able to beat my single model scores, or it could just be that I'm doing it incorrectly. This is my first object detection competition, so I wouldn't be surprised if that's the case.</p>\n<p>So far, I've tried:</p>\n<ul>\n<li>Making predictions using all 5 of my models, then selecting the most confident prediction</li>\n<li>Averaging the 5 most confident predictions</li>\n<li>Averaging predictions for each slice, then selecting the most confident one</li>\n</ul>\n<p>I'm not sure if these are the correct approaches to ensembling in object detection, but they're what I've tried so far. I would greatly appreciate it if you could share your ensembling experience and maybe point me in the right direction.</p>",
  "messages": [
    {
      "id": "3194032",
      "postDate": "05/05/2025 10:57:22",
      "content": "<p>I know that many of you are getting good results with single models, but we all know that in Kaggle competitions, ensembling predictions from multiple models often leads to better scores. However, in this competition, I'm not sure whether ensembling makes sense since I've not been able to beat my single model scores, or it could just be that I'm doing it incorrectly. This is my first object detection competition, so I wouldn't be surprised if that's the case.</p>\n<p>So far, I've tried:</p>\n<ul>\n<li>Making predictions using all 5 of my models, then selecting the most confident prediction</li>\n<li>Averaging the 5 most confident predictions</li>\n<li>Averaging predictions for each slice, then selecting the most confident one</li>\n</ul>\n<p>I'm not sure if these are the correct approaches to ensembling in object detection, but they're what I've tried so far. I would greatly appreciate it if you could share your ensembling experience and maybe point me in the right direction.</p>",
      "rawMarkdown": "I know that many of you are getting good results with single models, but we all know that in Kaggle competitions, ensembling predictions from multiple models often leads to better scores. However, in this competition, I'm not sure whether ensembling makes sense since I've not been able to beat my single model scores, or it could just be that I'm doing it incorrectly. This is my first object detection competition, so I wouldn't be surprised if that's the case.\n\nSo far, I've tried:\n- Making predictions using all 5 of my models, then selecting the most confident prediction\n- Averaging the 5 most confident predictions\n- Averaging predictions for each slice, then selecting the most confident one\n\nI'm not sure if these are the correct approaches to ensembling in object detection, but they're what I've tried so far. I would greatly appreciate it if you could share your ensembling experience and maybe point me in the right direction.",
      "votes": null
    },
    {
      "id": "3194169",
      "postDate": "05/05/2025 13:36:45",
      "content": "<p><a href=\"https://www.kaggle.com/ravaghi\" target=\"_blank\">@ravaghi</a> Here I list two good options: </p>\n<pre><code> bayesian_fusion(pred1, pred2, sigma1, sigma2):\n     = (sigma1** * pred1 + sigma2** * pred2) / (sigma1** + sigma2**)\n     score\n\n weighted_sum(pred1, pred2, weight1=., weight2=.):\n     weight1 * pred1 + weight2 * pred2\n</code></pre>",
      "rawMarkdown": "ravaghi Here I list two good options: \n\n```\ndef bayesian_fusion(pred1, pred2, sigma1, sigma2):\n    score = (sigma1**2 * pred1 + sigma2**2 * pred2) / (sigma1**2 + sigma2**2)\n    return score\n\ndef weighted_sum(pred1, pred2, weight1=0.5, weight2=0.5):\n    return weight1 * pred1 + weight2 * pred2\n```",
      "votes": null
    },
    {
      "id": "3194202",
      "postDate": "05/05/2025 14:25:09",
      "content": "<p>Thanks, <a href=\"https://www.kaggle.com/tom99763\" target=\"_blank\">@tom99763</a>. Which one did you find more effective? Would you mind sharing some of your results?</p>\n<p>I tried something similar to your weighted_sum, but it didn’t work.</p>",
      "rawMarkdown": "Thanks, @tom99763. Which one did you find more effective? Would you mind sharing some of your results?\n\nI tried something similar to your weighted_sum, but it didn’t work.",
      "votes": null
    },
    {
      "id": "3194560",
      "postDate": "05/06/2025 03:54:09",
      "content": "<p><a href=\"https://www.kaggle.com/ravaghi\" target=\"_blank\">@ravaghi</a> </p>\n<p>Simple weighted is not good for object localization task cuz it might suppresses some possible points which is bad for f-beta score evaluation. Instead, you should follow the process below:</p>\n<ul>\n<li>Setting low confidence threshold</li>\n<li>Setting low confidence threshold and involving all the prediction points from the models</li>\n<li>Clustering using <code>HDBSCAN</code> since it can process arbitrary cluster shapes.</li>\n<li>Using the center of cluster as the prediction</li>\n</ul>\n<p>Further development:</p>\n<ul>\n<li>Using the prediction score from yolo as the distance measure in minimum spanning tree in <code>HDBSCAN</code></li>\n<li>Using weighted mean to determine the center</li>\n<li>Deeply analysis the perceptions of the yolo models, every model have different understandings on the motor existences.</li>\n</ul>\n<p>You can refer my <a href=\"https://www.kaggle.com/code/tom99763/tomv3-gnn-submission-byu\" target=\"_blank\">public submission notebook </a> to understand basic usages of <code>HDBSCAN</code>. <br>\nOr the highest <a href=\"https://www.kaggle.com/code/pondelion/byu-deim-single-model-inference\" target=\"_blank\">public-score notebook</a>.</p>",
      "rawMarkdown": "ravaghi \n\nSimple weighted is not good for object localization task cuz it might suppresses some possible points which is bad for f-beta score evaluation. Instead, you should follow the process below:\n\n* Setting low confidence threshold\n* Setting low confidence threshold and involving all the prediction points from the models\n* Clustering using `HDBSCAN` since it can process arbitrary cluster shapes.\n* Using the center of cluster as the prediction\n\nFurther development:\n* Using the prediction score from yolo as the distance measure in minimum spanning tree in `HDBSCAN`\n* Using weighted mean to determine the center\n* Deeply analysis the perceptions of the yolo models, every model have different understandings on the motor existences.\n\nYou can refer my [public submission notebook ](https://www.kaggle.com/code/tom99763/tomv3-gnn-submission-byu) to understand basic usages of `HDBSCAN`. \nOr the highest [public-score notebook](https://www.kaggle.com/code/pondelion/byu-deim-single-model-inference).",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3194169,
      "author_name": "tom99763",
      "author_url": "",
      "post_date": "05/05/2025 13:36:45",
      "content": "<p><a href=\"https://www.kaggle.com/ravaghi\" target=\"_blank\">@ravaghi</a> Here I list two good options: </p>\n<pre><code> bayesian_fusion(pred1, pred2, sigma1, sigma2):\n     = (sigma1** * pred1 + sigma2** * pred2) / (sigma1** + sigma2**)\n     score\n\n weighted_sum(pred1, pred2, weight1=., weight2=.):\n     weight1 * pred1 + weight2 * pred2\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 3194202,
          "author_name": "ravaghi",
          "author_url": "",
          "post_date": "05/05/2025 14:25:09",
          "content": "<p>Thanks, <a href=\"https://www.kaggle.com/tom99763\" target=\"_blank\">@tom99763</a>. Which one did you find more effective? Would you mind sharing some of your results?</p>\n<p>I tried something similar to your weighted_sum, but it didn’t work.</p>",
          "votes": null,
          "replies": [
            {
              "id": 3194560,
              "author_name": "tom99763",
              "author_url": "",
              "post_date": "05/06/2025 03:54:09",
              "content": "<p><a href=\"https://www.kaggle.com/ravaghi\" target=\"_blank\">@ravaghi</a> </p>\n<p>Simple weighted is not good for object localization task cuz it might suppresses some possible points which is bad for f-beta score evaluation. Instead, you should follow the process below:</p>\n<ul>\n<li>Setting low confidence threshold</li>\n<li>Setting low confidence threshold and involving all the prediction points from the models</li>\n<li>Clustering using <code>HDBSCAN</code> since it can process arbitrary cluster shapes.</li>\n<li>Using the center of cluster as the prediction</li>\n</ul>\n<p>Further development:</p>\n<ul>\n<li>Using the prediction score from yolo as the distance measure in minimum spanning tree in <code>HDBSCAN</code></li>\n<li>Using weighted mean to determine the center</li>\n<li>Deeply analysis the perceptions of the yolo models, every model have different understandings on the motor existences.</li>\n</ul>\n<p>You can refer my <a href=\"https://www.kaggle.com/code/tom99763/tomv3-gnn-submission-byu\" target=\"_blank\">public submission notebook </a> to understand basic usages of <code>HDBSCAN</code>. <br>\nOr the highest <a href=\"https://www.kaggle.com/code/pondelion/byu-deim-single-model-inference\" target=\"_blank\">public-score notebook</a>.</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "3194032": "I know that many of you are getting good results with single models, but we all know that in Kaggle competitions, ensembling predictions from multiple models often leads to better scores. However, in this competition, I'm not sure whether ensembling makes sense since I've not been able to beat my single model scores, or it could just be that I'm doing it incorrectly. This is my first object detection competition, so I wouldn't be surprised if that's the case.\n\nSo far, I've tried:\n- Making predictions using all 5 of my models, then selecting the most confident prediction\n- Averaging the 5 most confident predictions\n- Averaging predictions for each slice, then selecting the most confident one\n\nI'm not sure if these are the correct approaches to ensembling in object detection, but they're what I've tried so far. I would greatly appreciate it if you could share your ensembling experience and maybe point me in the right direction.",
    "3194169": "ravaghi Here I list two good options: \n\n```\ndef bayesian_fusion(pred1, pred2, sigma1, sigma2):\n    score = (sigma1**2 * pred1 + sigma2**2 * pred2) / (sigma1**2 + sigma2**2)\n    return score\n\ndef weighted_sum(pred1, pred2, weight1=0.5, weight2=0.5):\n    return weight1 * pred1 + weight2 * pred2\n```",
    "3194202": "Thanks, @tom99763. Which one did you find more effective? Would you mind sharing some of your results?\n\nI tried something similar to your weighted_sum, but it didn’t work.",
    "3194560": "ravaghi \n\nSimple weighted is not good for object localization task cuz it might suppresses some possible points which is bad for f-beta score evaluation. Instead, you should follow the process below:\n\n* Setting low confidence threshold\n* Setting low confidence threshold and involving all the prediction points from the models\n* Clustering using `HDBSCAN` since it can process arbitrary cluster shapes.\n* Using the center of cluster as the prediction\n\nFurther development:\n* Using the prediction score from yolo as the distance measure in minimum spanning tree in `HDBSCAN`\n* Using weighted mean to determine the center\n* Deeply analysis the perceptions of the yolo models, every model have different understandings on the motor existences.\n\nYou can refer my [public submission notebook ](https://www.kaggle.com/code/tom99763/tomv3-gnn-submission-byu) to understand basic usages of `HDBSCAN`. \nOr the highest [public-score notebook](https://www.kaggle.com/code/pondelion/byu-deim-single-model-inference)."
  },
  "source": "meta"
}