{
  "id": 97610,
  "title": "Competition Metric",
  "url": "/competitions/aptos2019-blindness-detection/discussion/97610",
  "author_name": "",
  "post_date": "2019-06-28T01:45:42.909401300Z",
  "votes": 37,
  "comment_count": 10,
  "views": 0,
  "content": "<ol>\n<li><p>Code for Python users (if you are not sure how exactly this metric is calculated this code is a good place to start): <a href=\"https://github.com/benhamner/Metrics/blob/master/Python/ml_metrics/quadratic_weighted_kappa.py\">https://github.com/benhamner/Metrics/blob/master/Python/ml_metrics/quadratic_weighted_kappa.py</a></p></li>\n<li><p>Here is an illustration of how this metric works broken into steps: <a href=\"https://www.kaggle.com/aroraaman/quadratic-kappa-metric-explained-in-5-simple-steps\">https://www.kaggle.com/aroraaman/quadratic-kappa-metric-explained-in-5-simple-steps</a></p></li>\n<li><p>Quadratic Kappa Metric is the same as cohen kappa metric in Sci-kit learn <code>sklearn.metrics.cohen_kappa_score</code> when <code>weights</code> are set to <code>'Quadratic'</code>. </p></li>\n<li><p>Good Wikipedia article on Coheh's kappa with illustrative examples: <a href=\"https://en.wikipedia.org/wiki/Cohen%27s_kappa\">https://en.wikipedia.org/wiki/Cohen%27s_kappa</a></p></li>\n</ol>",
  "messages": [
    {
      "id": "563173",
      "postDate": "06/28/2019 01:45:42",
      "content": "<ol>\n<li><p>Code for Python users (if you are not sure how exactly this metric is calculated this code is a good place to start): <a href=\"https://github.com/benhamner/Metrics/blob/master/Python/ml_metrics/quadratic_weighted_kappa.py\">https://github.com/benhamner/Metrics/blob/master/Python/ml_metrics/quadratic_weighted_kappa.py</a></p></li>\n<li><p>Here is an illustration of how this metric works broken into steps: <a href=\"https://www.kaggle.com/aroraaman/quadratic-kappa-metric-explained-in-5-simple-steps\">https://www.kaggle.com/aroraaman/quadratic-kappa-metric-explained-in-5-simple-steps</a></p></li>\n<li><p>Quadratic Kappa Metric is the same as cohen kappa metric in Sci-kit learn <code>sklearn.metrics.cohen_kappa_score</code> when <code>weights</code> are set to <code>'Quadratic'</code>. </p></li>\n<li><p>Good Wikipedia article on Coheh's kappa with illustrative examples: <a href=\"https://en.wikipedia.org/wiki/Cohen%27s_kappa\">https://en.wikipedia.org/wiki/Cohen%27s_kappa</a></p></li>\n</ol>",
      "rawMarkdown": "1. Code for Python users (if you are not sure how exactly this metric is calculated this code is a good place to start): https://github.com/benhamner/Metrics/blob/master/Python/ml_metrics/quadratic_weighted_kappa.py\n\n2. Here is an illustration of how this metric works broken into steps: https://www.kaggle.com/aroraaman/quadratic-kappa-metric-explained-in-5-simple-steps\n\n3. Quadratic Kappa Metric is the same as cohen kappa metric in Sci-kit learn `sklearn.metrics.cohen_kappa_score` when `weights` are set to `'Quadratic'`. \n\n4. Good Wikipedia article on Coheh's kappa with illustrative examples: https://en.wikipedia.org/wiki/Cohen%27s_kappa",
      "votes": null
    },
    {
      "id": "563180",
      "postDate": "06/28/2019 02:03:53",
      "content": "<p>This metric was used in <a href=\"https://www.kaggle.com/c/petfinder-adoption-prediction\">PetFinder.my Adoption Prediction</a> held until March 2019. There are some discussions for the metric.</p>",
      "rawMarkdown": "This metric was used in [PetFinder.my Adoption Prediction](https://www.kaggle.com/c/petfinder-adoption-prediction) held until March 2019. There are some discussions for the metric.",
      "votes": null
    },
    {
      "id": "563244",
      "postDate": "06/28/2019 04:01:46",
      "content": "<p>For a while ,i was curious how competition submission score are generated, never thought that to be a 6 steps complicated procedure at play to generate my final submission score , Thanks for sharing.</p>",
      "rawMarkdown": "For a while ,i was curious how competition submission score are generated, never thought that to be a 6 steps complicated procedure at play to generate my final submission score , Thanks for sharing.",
      "votes": null
    },
    {
      "id": "563246",
      "postDate": "06/28/2019 04:04:26",
      "content": "<p>It depends on competition. For this one the metric is quite involved -- it make sense to go through the code available at the first link above just to make sure that you understand how it works.</p>",
      "rawMarkdown": "It depends on competition. For this one the metric is quite involved -- it make sense to go through the code available at the first link above just to make sure that you understand how it works.",
      "votes": null
    },
    {
      "id": "563728",
      "postDate": "06/28/2019 15:59:19",
      "content": "<p>fast.ai have in-built support for kappa metric. Choose quadratic weight type.</p>",
      "rawMarkdown": "fast.ai have in-built support for kappa metric. Choose quadratic weight type.",
      "votes": null
    },
    {
      "id": "565194",
      "postDate": "06/30/2019 15:04:26",
      "content": "<p>Very useful, thanks!</p>",
      "rawMarkdown": "Very useful, thanks!",
      "votes": null
    },
    {
      "id": "565363",
      "postDate": "06/30/2019 20:20:24",
      "content": "<p>Thank you very much! </p>",
      "rawMarkdown": "Thank you very much!",
      "votes": null
    },
    {
      "id": "568849",
      "postDate": "07/05/2019 14:40:22",
      "content": "<p>Thank you</p>",
      "rawMarkdown": "Thank you",
      "votes": null
    },
    {
      "id": "577129",
      "postDate": "07/16/2019 11:48:34",
      "content": "<p>I am using the code that is provided here in 1 and I get kappa scores like 0.67 etc on my validation data. However, when I submit my response on the competition, the score is calculated to be 0.0000.\nDoes that make sense? could I be making a rookie mistake?</p>",
      "rawMarkdown": "I am using the code that is provided here in 1 and I get kappa scores like 0.67 etc on my validation data. However, when I submit my response on the competition, the score is calculated to be 0.0000.\nDoes that make sense? could I be making a rookie mistake?",
      "votes": null
    },
    {
      "id": "579681",
      "postDate": "07/19/2019 05:32:29",
      "content": "<p>I use <code>sklearn.metrics.cohen_kappa_score</code> .</p>\n\n<p>But I have a question. When you train the model and compute cohenkappascore, have you ever met the situation of follows:</p>\n\n<p>RuntimeWarning: invalid value encountered in true_divide k = np.sum(w_mat * confusion) / np.sum(w_mat * expected)</p>\n\n<p>I used same code as yours:</p>\n\n<p>a = target.data.cpu().numpy() b = output.detach().cpu().numpy() train_ck_score.append(cohen_k_score(a, b))</p>\n\n<p>Do not understand why there is nan in the denominator. Any suggestions?</p>",
      "rawMarkdown": "I use `sklearn.metrics.cohen_kappa_score` .\n\nBut I have a question. When you train the model and compute cohenkappascore, have you ever met the situation of follows:\n\nRuntimeWarning: invalid value encountered in true_divide k = np.sum(w_mat * confusion) / np.sum(w_mat * expected)\n\nI used same code as yours:\n\na = target.data.cpu().numpy() b = output.detach().cpu().numpy() train_ck_score.append(cohen_k_score(a, b))\n\nDo not understand why there is nan in the denominator. Any suggestions?",
      "votes": null
    },
    {
      "id": "891386",
      "postDate": "06/18/2020 06:35:23",
      "content": "<p><a href=\"/xiaojiu1414\">@xiaojiu1414</a>  have you figured out what was wrong, i am also getting same error.</p>",
      "rawMarkdown": "xiaojiu1414  have you figured out what was wrong, i am also getting same error.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 563180,
      "author_name": "sishihara",
      "author_url": "",
      "post_date": "06/28/2019 02:03:53",
      "content": "<p>This metric was used in <a href=\"https://www.kaggle.com/c/petfinder-adoption-prediction\">PetFinder.my Adoption Prediction</a> held until March 2019. There are some discussions for the metric.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 563244,
      "author_name": "gunishj",
      "author_url": "",
      "post_date": "06/28/2019 04:01:46",
      "content": "<p>For a while ,i was curious how competition submission score are generated, never thought that to be a 6 steps complicated procedure at play to generate my final submission score , Thanks for sharing.</p>",
      "votes": null,
      "replies": [
        {
          "id": 563246,
          "author_name": "graf10a",
          "author_url": "",
          "post_date": "06/28/2019 04:04:26",
          "content": "<p>It depends on competition. For this one the metric is quite involved -- it make sense to go through the code available at the first link above just to make sure that you understand how it works.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 563728,
      "author_name": "mktripathi456",
      "author_url": "",
      "post_date": "06/28/2019 15:59:19",
      "content": "<p>fast.ai have in-built support for kappa metric. Choose quadratic weight type.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 565194,
      "author_name": "dimitreoliveira",
      "author_url": "",
      "post_date": "06/30/2019 15:04:26",
      "content": "<p>Very useful, thanks!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 565363,
      "author_name": "andreylitvinchuk",
      "author_url": "",
      "post_date": "06/30/2019 20:20:24",
      "content": "<p>Thank you very much! </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 568849,
      "author_name": "jyshin",
      "author_url": "",
      "post_date": "07/05/2019 14:40:22",
      "content": "<p>Thank you</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 577129,
      "author_name": "mittalneha",
      "author_url": "",
      "post_date": "07/16/2019 11:48:34",
      "content": "<p>I am using the code that is provided here in 1 and I get kappa scores like 0.67 etc on my validation data. However, when I submit my response on the competition, the score is calculated to be 0.0000.\nDoes that make sense? could I be making a rookie mistake?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 579681,
      "author_name": "xiaojiu1414",
      "author_url": "",
      "post_date": "07/19/2019 05:32:29",
      "content": "<p>I use <code>sklearn.metrics.cohen_kappa_score</code> .</p>\n\n<p>But I have a question. When you train the model and compute cohenkappascore, have you ever met the situation of follows:</p>\n\n<p>RuntimeWarning: invalid value encountered in true_divide k = np.sum(w_mat * confusion) / np.sum(w_mat * expected)</p>\n\n<p>I used same code as yours:</p>\n\n<p>a = target.data.cpu().numpy() b = output.detach().cpu().numpy() train_ck_score.append(cohen_k_score(a, b))</p>\n\n<p>Do not understand why there is nan in the denominator. Any suggestions?</p>",
      "votes": null,
      "replies": [
        {
          "id": 891386,
          "author_name": "rohitsingh9990",
          "author_url": "",
          "post_date": "06/18/2020 06:35:23",
          "content": "<p><a href=\"/xiaojiu1414\">@xiaojiu1414</a>  have you figured out what was wrong, i am also getting same error.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "563173": "1. Code for Python users (if you are not sure how exactly this metric is calculated this code is a good place to start): https://github.com/benhamner/Metrics/blob/master/Python/ml_metrics/quadratic_weighted_kappa.py\n\n2. Here is an illustration of how this metric works broken into steps: https://www.kaggle.com/aroraaman/quadratic-kappa-metric-explained-in-5-simple-steps\n\n3. Quadratic Kappa Metric is the same as cohen kappa metric in Sci-kit learn `sklearn.metrics.cohen_kappa_score` when `weights` are set to `'Quadratic'`. \n\n4. Good Wikipedia article on Coheh's kappa with illustrative examples: https://en.wikipedia.org/wiki/Cohen%27s_kappa",
    "563180": "This metric was used in [PetFinder.my Adoption Prediction](https://www.kaggle.com/c/petfinder-adoption-prediction) held until March 2019. There are some discussions for the metric.",
    "563244": "For a while ,i was curious how competition submission score are generated, never thought that to be a 6 steps complicated procedure at play to generate my final submission score , Thanks for sharing.",
    "563246": "It depends on competition. For this one the metric is quite involved -- it make sense to go through the code available at the first link above just to make sure that you understand how it works.",
    "563728": "fast.ai have in-built support for kappa metric. Choose quadratic weight type.",
    "565194": "Very useful, thanks!",
    "565363": "Thank you very much!",
    "568849": "Thank you",
    "577129": "I am using the code that is provided here in 1 and I get kappa scores like 0.67 etc on my validation data. However, when I submit my response on the competition, the score is calculated to be 0.0000.\nDoes that make sense? could I be making a rookie mistake?",
    "579681": "I use `sklearn.metrics.cohen_kappa_score` .\n\nBut I have a question. When you train the model and compute cohenkappascore, have you ever met the situation of follows:\n\nRuntimeWarning: invalid value encountered in true_divide k = np.sum(w_mat * confusion) / np.sum(w_mat * expected)\n\nI used same code as yours:\n\na = target.data.cpu().numpy() b = output.detach().cpu().numpy() train_ck_score.append(cohen_k_score(a, b))\n\nDo not understand why there is nan in the denominator. Any suggestions?",
    "891386": "xiaojiu1414  have you figured out what was wrong, i am also getting same error."
  },
  "source": "meta"
}