{
  "id": 230457,
  "title": "Computing precision when predictions match multiple ground-truths",
  "url": "/competitions/coleridgeinitiative-show-us-the-data/discussion/230457",
  "author_name": "",
  "post_date": "2021-04-03T20:16:06.341237500Z",
  "votes": 3,
  "comment_count": 3,
  "views": 0,
  "content": "<p>I am trying to understand how Kaggle calculates true-positives and false-positives when predictions match multiple ground-truths.<br>\nE.g. Let's consider a hypothetical sample and its predictions:<br>\ny_true_str = 'l x n o p|n o p q'<br>\ny_pred_str = 'x n p b|n o p a'<br>\nHere each character (l, x, n, etc.) could represent some word. </p>\n<p>The Jaccard similarity matrix in this case would be:</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>n o p a</th>\n<th>x n p b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>l x n o p</td>\n<td>0.5</td>\n<td>0.5</td>\n</tr>\n<tr>\n<td>n o p q</td>\n<td>0.6</td>\n<td>0.33</td>\n</tr>\n</tbody>\n</table>\n<p>Here, since there is a tie in the scores of the two predictions for the first ground-truth, the first prediction would be chosen, and the resultant true-prediction matrix would be:</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>n o p a</th>\n<th>x n p b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>l x n o p</td>\n<td>1</td>\n<td>0</td>\n</tr>\n<tr>\n<td>n o p q</td>\n<td>1</td>\n<td>0</td>\n</tr>\n</tbody>\n</table>\n<p>Now, the first prediction matches two ground truth labels, and second does not match any.</p>\n<p>Based on the description on the evaluation page, my understanding is that Kaggle counts False-positive as 1 since the second prediction does not 'match' any ground truth. Is this understanding correct?</p>\n<p>And would the true-positive count be:</p>\n<ul>\n<li>2 (since two ground-truths are predicted correctly), or</li>\n<li>1 (since one predicted label has matched any of the ground truths)<br>\nMy guess is that it should be the first option. But I would like to confirm this assumption.</li>\n</ul>",
  "messages": [
    {
      "id": "1262123",
      "postDate": "04/03/2021 20:16:06",
      "content": "<p>I am trying to understand how Kaggle calculates true-positives and false-positives when predictions match multiple ground-truths.<br>\nE.g. Let's consider a hypothetical sample and its predictions:<br>\ny_true_str = 'l x n o p|n o p q'<br>\ny_pred_str = 'x n p b|n o p a'<br>\nHere each character (l, x, n, etc.) could represent some word. </p>\n<p>The Jaccard similarity matrix in this case would be:</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>n o p a</th>\n<th>x n p b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>l x n o p</td>\n<td>0.5</td>\n<td>0.5</td>\n</tr>\n<tr>\n<td>n o p q</td>\n<td>0.6</td>\n<td>0.33</td>\n</tr>\n</tbody>\n</table>\n<p>Here, since there is a tie in the scores of the two predictions for the first ground-truth, the first prediction would be chosen, and the resultant true-prediction matrix would be:</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>n o p a</th>\n<th>x n p b</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>l x n o p</td>\n<td>1</td>\n<td>0</td>\n</tr>\n<tr>\n<td>n o p q</td>\n<td>1</td>\n<td>0</td>\n</tr>\n</tbody>\n</table>\n<p>Now, the first prediction matches two ground truth labels, and second does not match any.</p>\n<p>Based on the description on the evaluation page, my understanding is that Kaggle counts False-positive as 1 since the second prediction does not 'match' any ground truth. Is this understanding correct?</p>\n<p>And would the true-positive count be:</p>\n<ul>\n<li>2 (since two ground-truths are predicted correctly), or</li>\n<li>1 (since one predicted label has matched any of the ground truths)<br>\nMy guess is that it should be the first option. But I would like to confirm this assumption.</li>\n</ul>",
      "rawMarkdown": "I am trying to understand how Kaggle calculates true-positives and false-positives when predictions match multiple ground-truths.\nE.g. Let's consider a hypothetical sample and its predictions:\ny_true_str = 'l x n o p|n o p q'\ny_pred_str = 'x n p b|n o p a'\nHere each character (l, x, n, etc.) could represent some word. \n\nThe Jaccard similarity matrix in this case would be:\n|  | n o p a | x n p b |\n|---|---|---|\n|l x n o p | 0.5 |0.5|\n|n o p q |0.6|0.33|\n\nHere, since there is a tie in the scores of the two predictions for the first ground-truth, the first prediction would be chosen, and the resultant true-prediction matrix would be:\n|  | n o p a | x n p b |\n|---|---|---|\n| l x n o p |1|0|\n|n o p q |1|0|\n\nNow, the first prediction matches two ground truth labels, and second does not match any.\n\nBased on the description on the evaluation page, my understanding is that Kaggle counts False-positive as 1 since the second prediction does not 'match' any ground truth. Is this understanding correct?\n\nAnd would the true-positive count be:\n- 2 (since two ground-truths are predicted correctly), or\n- 1 (since one predicted label has matched any of the ground truths)\nMy guess is that it should be the first option. But I would like to confirm this assumption.",
      "votes": null
    },
    {
      "id": "1262363",
      "postDate": "04/04/2021 06:48:12",
      "content": "<p>Hey,<br>\nFirst of all, for the ground truth <code>nopq</code> , the matched label would be <code>nopa</code> and not <code>mnpb</code>, because of the higher Jaccard score. In this case, there would be 2 True positives because they have a score above or equal to 0.5 . (I am not sure whether the threshold for TP includes 0.5 or not).</p>",
      "rawMarkdown": "Hey,\nFirst of all, for the ground truth `nopq` , the matched label would be `nopa` and not `mnpb`, because of the higher Jaccard score. In this case, there would be 2 True positives because they have a score above or equal to 0.5 . (I am not sure whether the threshold for TP includes 0.5 or not).",
      "votes": null
    },
    {
      "id": "1262370",
      "postDate": "04/04/2021 07:02:12",
      "content": "<p>Thanks, Ibtesam. Updated the post.</p>\n<p>Regarding inclusion of 0.5, the evaluation page says 'Any matched predictions where the Jaccard score <em>meets</em> or exceeds the threshold of 0.5 are counted as true positives (TP)', and therefore, 0.5 jaccard score predictions could be considered as TP's.</p>",
      "rawMarkdown": "Thanks, Ibtesam. Updated the post.\n\nRegarding inclusion of 0.5, the evaluation page says 'Any matched predictions where the Jaccard score *meets* or exceeds the threshold of 0.5 are counted as true positives (TP)', and therefore, 0.5 jaccard score predictions could be considered as TP's.",
      "votes": null
    },
    {
      "id": "1270159",
      "postDate": "04/11/2021 11:18:25",
      "content": "<p>Seems a relevant question to me<br>\nI would (also) say that the second prediction counts as a FP and the TP count should be 2.<br>\nBut I agree that the evaluation page is not (yet) clear about this and I couldn't find the answer in other posts but maybe I missed it.</p>\n<p><a href=\"https://www.kaggle.com/philculliton\" target=\"_blank\">@philculliton</a> could you please shed some light on this?</p>",
      "rawMarkdown": "Seems a relevant question to me\nI would (also) say that the second prediction counts as a FP and the TP count should be 2.\nBut I agree that the evaluation page is not (yet) clear about this and I couldn't find the answer in other posts but maybe I missed it.\n\n@philculliton could you please shed some light on this?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1262363,
      "author_name": "ibtesama",
      "author_url": "",
      "post_date": "04/04/2021 06:48:12",
      "content": "<p>Hey,<br>\nFirst of all, for the ground truth <code>nopq</code> , the matched label would be <code>nopa</code> and not <code>mnpb</code>, because of the higher Jaccard score. In this case, there would be 2 True positives because they have a score above or equal to 0.5 . (I am not sure whether the threshold for TP includes 0.5 or not).</p>",
      "votes": null,
      "replies": [
        {
          "id": 1262370,
          "author_name": "vishalsrinirao",
          "author_url": "",
          "post_date": "04/04/2021 07:02:12",
          "content": "<p>Thanks, Ibtesam. Updated the post.</p>\n<p>Regarding inclusion of 0.5, the evaluation page says 'Any matched predictions where the Jaccard score <em>meets</em> or exceeds the threshold of 0.5 are counted as true positives (TP)', and therefore, 0.5 jaccard score predictions could be considered as TP's.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1270159,
      "author_name": "julesvanligtenberg",
      "author_url": "",
      "post_date": "04/11/2021 11:18:25",
      "content": "<p>Seems a relevant question to me<br>\nI would (also) say that the second prediction counts as a FP and the TP count should be 2.<br>\nBut I agree that the evaluation page is not (yet) clear about this and I couldn't find the answer in other posts but maybe I missed it.</p>\n<p><a href=\"https://www.kaggle.com/philculliton\" target=\"_blank\">@philculliton</a> could you please shed some light on this?</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1262123": "I am trying to understand how Kaggle calculates true-positives and false-positives when predictions match multiple ground-truths.\nE.g. Let's consider a hypothetical sample and its predictions:\ny_true_str = 'l x n o p|n o p q'\ny_pred_str = 'x n p b|n o p a'\nHere each character (l, x, n, etc.) could represent some word. \n\nThe Jaccard similarity matrix in this case would be:\n|  | n o p a | x n p b |\n|---|---|---|\n|l x n o p | 0.5 |0.5|\n|n o p q |0.6|0.33|\n\nHere, since there is a tie in the scores of the two predictions for the first ground-truth, the first prediction would be chosen, and the resultant true-prediction matrix would be:\n|  | n o p a | x n p b |\n|---|---|---|\n| l x n o p |1|0|\n|n o p q |1|0|\n\nNow, the first prediction matches two ground truth labels, and second does not match any.\n\nBased on the description on the evaluation page, my understanding is that Kaggle counts False-positive as 1 since the second prediction does not 'match' any ground truth. Is this understanding correct?\n\nAnd would the true-positive count be:\n- 2 (since two ground-truths are predicted correctly), or\n- 1 (since one predicted label has matched any of the ground truths)\nMy guess is that it should be the first option. But I would like to confirm this assumption.",
    "1262363": "Hey,\nFirst of all, for the ground truth `nopq` , the matched label would be `nopa` and not `mnpb`, because of the higher Jaccard score. In this case, there would be 2 True positives because they have a score above or equal to 0.5 . (I am not sure whether the threshold for TP includes 0.5 or not).",
    "1262370": "Thanks, Ibtesam. Updated the post.\n\nRegarding inclusion of 0.5, the evaluation page says 'Any matched predictions where the Jaccard score *meets* or exceeds the threshold of 0.5 are counted as true positives (TP)', and therefore, 0.5 jaccard score predictions could be considered as TP's.",
    "1270159": "Seems a relevant question to me\nI would (also) say that the second prediction counts as a FP and the TP count should be 2.\nBut I agree that the evaluation page is not (yet) clear about this and I couldn't find the answer in other posts but maybe I missed it.\n\n@philculliton could you please shed some light on this?"
  },
  "source": "meta"
}