{
  "id": 470655,
  "title": "Threshold choice ",
  "url": "/competitions/blood-vessel-segmentation/discussion/470655",
  "author_name": "",
  "post_date": "2024-01-25T00:10:54.853078900Z",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hi Everyone,</p>\n<p>It seems there's a lot of emphasis on the threshold in this competition. I'm very new to segmentation problems, so I'm wondering how people have been choosing theirs.</p>\n<p>The strategy I have taken is to always set the mask with &gt;= 0.5 as positive (1) and &lt; 0.5 as negative (0). Intuitively this makes sense to me because the output of my final layer is sigmoidal, so the center point of that function seems like a reasonable set point. Is the idea to change the threshold to something else based on the thought that if your model is prone to false negatives, you want relax the constraints on the model and if your model is prone to false positives, you want to be more restrictive?</p>\n<p>How have you approached determining robust thresholds?</p>",
  "messages": [
    {
      "id": "2618726",
      "postDate": "01/25/2024 00:10:54",
      "content": "<p>Hi Everyone,</p>\n<p>It seems there's a lot of emphasis on the threshold in this competition. I'm very new to segmentation problems, so I'm wondering how people have been choosing theirs.</p>\n<p>The strategy I have taken is to always set the mask with &gt;= 0.5 as positive (1) and &lt; 0.5 as negative (0). Intuitively this makes sense to me because the output of my final layer is sigmoidal, so the center point of that function seems like a reasonable set point. Is the idea to change the threshold to something else based on the thought that if your model is prone to false negatives, you want relax the constraints on the model and if your model is prone to false positives, you want to be more restrictive?</p>\n<p>How have you approached determining robust thresholds?</p>",
      "rawMarkdown": "Hi Everyone,\n\nIt seems there's a lot of emphasis on the threshold in this competition. I'm very new to segmentation problems, so I'm wondering how people have been choosing theirs.\n\nThe strategy I have taken is to always set the mask with >= 0.5 as positive (1) and < 0.5 as negative (0). Intuitively this makes sense to me because the output of my final layer is sigmoidal, so the center point of that function seems like a reasonable set point. Is the idea to change the threshold to something else based on the thought that if your model is prone to false negatives, you want relax the constraints on the model and if your model is prone to false positives, you want to be more restrictive?\n\nHow have you approached determining robust thresholds?",
      "votes": null
    },
    {
      "id": "2618949",
      "postDate": "01/25/2024 05:42:43",
      "content": "<p>If you believe in lb, you can choose the same threshold as lb, or you can filter by proportion like this notebook <br>\n<code>TH=[x.flatten().numpy() for x in output]\nTH=np.concatenate(TH)\nindex = -int(len(TH) * CFG.th_percentile)\nTH:int = np.partition(TH, index)[index]</code><br>\n<a href=\"url\" target=\"_blank\">https://www.kaggle.com/code/misakimatsutomo/inference-1024-should-have-a-percentile-of-0-00149.</a></p>\n<p>My method has similar proportions of threshold in public test and private test. <br>\nIf you believe in cv, you can choose the same threshold as cv.<br>\nCertainly, there is also an element of chance in play as well. Wishing you the best of luck.😀</p>",
      "rawMarkdown": "If you believe in lb, you can choose the same threshold as lb, or you can filter by proportion like this notebook \n`TH=[x.flatten().numpy() for x in output]\nTH=np.concatenate(TH)\nindex = -int(len(TH) * CFG.th_percentile)\nTH:int = np.partition(TH, index)[index]`\n[https://www.kaggle.com/code/misakimatsutomo/inference-1024-should-have-a-percentile-of-0-00149.](url)\n\nMy method has similar proportions of threshold in public test and private test. \nIf you believe in cv, you can choose the same threshold as cv.\nCertainly, there is also an element of chance in play as well. Wishing you the best of luck.😀",
      "votes": null
    },
    {
      "id": "2619440",
      "postDate": "01/25/2024 12:57:01",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/tanxxx\" target=\"_blank\">@tanxxx</a> :) best of luck to you too! Looks like you have a good chance of placing well if there isn't too much shakeup.</p>\n<p>Ah, so it's a matter of \"which so you trust\". That makes sense, thanks for the advice!</p>\n<p>I don't think I completely understand how the thresholding code above works. I'll have to read it more closely this afternoon.</p>",
      "rawMarkdown": "Thanks @tanxxx :) best of luck to you too! Looks like you have a good chance of placing well if there isn't too much shakeup.\n\nAh, so it's a matter of \"which so you trust\". That makes sense, thanks for the advice!\n\nI don't think I completely understand how the thresholding code above works. I'll have to read it more closely this afternoon.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2618949,
      "author_name": "tanxxx",
      "author_url": "",
      "post_date": "01/25/2024 05:42:43",
      "content": "<p>If you believe in lb, you can choose the same threshold as lb, or you can filter by proportion like this notebook <br>\n<code>TH=[x.flatten().numpy() for x in output]\nTH=np.concatenate(TH)\nindex = -int(len(TH) * CFG.th_percentile)\nTH:int = np.partition(TH, index)[index]</code><br>\n<a href=\"url\" target=\"_blank\">https://www.kaggle.com/code/misakimatsutomo/inference-1024-should-have-a-percentile-of-0-00149.</a></p>\n<p>My method has similar proportions of threshold in public test and private test. <br>\nIf you believe in cv, you can choose the same threshold as cv.<br>\nCertainly, there is also an element of chance in play as well. Wishing you the best of luck.😀</p>",
      "votes": null,
      "replies": [
        {
          "id": 2619440,
          "author_name": "chemdatafarmer",
          "author_url": "",
          "post_date": "01/25/2024 12:57:01",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/tanxxx\" target=\"_blank\">@tanxxx</a> :) best of luck to you too! Looks like you have a good chance of placing well if there isn't too much shakeup.</p>\n<p>Ah, so it's a matter of \"which so you trust\". That makes sense, thanks for the advice!</p>\n<p>I don't think I completely understand how the thresholding code above works. I'll have to read it more closely this afternoon.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2618726": "Hi Everyone,\n\nIt seems there's a lot of emphasis on the threshold in this competition. I'm very new to segmentation problems, so I'm wondering how people have been choosing theirs.\n\nThe strategy I have taken is to always set the mask with >= 0.5 as positive (1) and < 0.5 as negative (0). Intuitively this makes sense to me because the output of my final layer is sigmoidal, so the center point of that function seems like a reasonable set point. Is the idea to change the threshold to something else based on the thought that if your model is prone to false negatives, you want relax the constraints on the model and if your model is prone to false positives, you want to be more restrictive?\n\nHow have you approached determining robust thresholds?",
    "2618949": "If you believe in lb, you can choose the same threshold as lb, or you can filter by proportion like this notebook \n`TH=[x.flatten().numpy() for x in output]\nTH=np.concatenate(TH)\nindex = -int(len(TH) * CFG.th_percentile)\nTH:int = np.partition(TH, index)[index]`\n[https://www.kaggle.com/code/misakimatsutomo/inference-1024-should-have-a-percentile-of-0-00149.](url)\n\nMy method has similar proportions of threshold in public test and private test. \nIf you believe in cv, you can choose the same threshold as cv.\nCertainly, there is also an element of chance in play as well. Wishing you the best of luck.😀",
    "2619440": "Thanks @tanxxx :) best of luck to you too! Looks like you have a good chance of placing well if there isn't too much shakeup.\n\nAh, so it's a matter of \"which so you trust\". That makes sense, thanks for the advice!\n\nI don't think I completely understand how the thresholding code above works. I'll have to read it more closely this afternoon."
  },
  "source": "meta"
}