{
  "id": 247736,
  "title": "how to calculate mAP in classification",
  "url": "/competitions/siim-covid19-detection/discussion/247736",
  "author_name": "",
  "post_date": "2021-06-21T02:04:20.226720900Z",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>As topic concerned, how to calculate mAP in python. who can share some of the codes?</p>",
  "messages": [
    {
      "id": "1359002",
      "postDate": "06/21/2021 02:04:20",
      "content": "<p>As topic concerned, how to calculate mAP in python. who can share some of the codes?</p>",
      "rawMarkdown": "As topic concerned, how to calculate mAP in python. who can share some of the codes?",
      "votes": null
    },
    {
      "id": "1359267",
      "postDate": "06/21/2021 07:23:56",
      "content": "<p>You can use sklearn's <code>average_precision_score</code> metric documented <a href=\"https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html\" target=\"_blank\">here</a>. You may have to use <code>average='samples'</code> or <code>average='macro'</code> depending on your use case. Code example copied directly from their documentation:</p>\n<pre><code>&gt;&gt;&gt; import numpy as np\n&gt;&gt;&gt; from sklearn.metrics import average_precision_score\n&gt;&gt;&gt; y_true = np.array([0, 0, 1, 1])\n&gt;&gt;&gt; y_scores = np.array([0.1, 0.4, 0.35, 0.8])\n&gt;&gt;&gt; average_precision_score(y_true, y_scores)\n</code></pre>",
      "rawMarkdown": "You can use sklearn's `average_precision_score` metric documented [here](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html). You may have to use `average='samples'` or `average='macro'` depending on your use case. Code example copied directly from their documentation:\n```\n>>> import numpy as np\n>>> from sklearn.metrics import average_precision_score\n>>> y_true = np.array([0, 0, 1, 1])\n>>> y_scores = np.array([0.1, 0.4, 0.35, 0.8])\n>>> average_precision_score(y_true, y_scores)\n```",
      "votes": null
    },
    {
      "id": "1359448",
      "postDate": "06/21/2021 09:53:21",
      "content": "<p>I'm having the same question, I've seen implementation of the mAP using sklearn (great for pytorch), but I have not found a way to compute it using tensorflow. Someone has an idea ? </p>",
      "rawMarkdown": "I'm having the same question, I've seen implementation of the mAP using sklearn (great for pytorch), but I have not found a way to compute it using tensorflow. Someone has an idea ?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1359267,
      "author_name": "nousernameforme",
      "author_url": "",
      "post_date": "06/21/2021 07:23:56",
      "content": "<p>You can use sklearn's <code>average_precision_score</code> metric documented <a href=\"https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html\" target=\"_blank\">here</a>. You may have to use <code>average='samples'</code> or <code>average='macro'</code> depending on your use case. Code example copied directly from their documentation:</p>\n<pre><code>&gt;&gt;&gt; import numpy as np\n&gt;&gt;&gt; from sklearn.metrics import average_precision_score\n&gt;&gt;&gt; y_true = np.array([0, 0, 1, 1])\n&gt;&gt;&gt; y_scores = np.array([0.1, 0.4, 0.35, 0.8])\n&gt;&gt;&gt; average_precision_score(y_true, y_scores)\n</code></pre>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1359448,
      "author_name": "tomdarmon",
      "author_url": "",
      "post_date": "06/21/2021 09:53:21",
      "content": "<p>I'm having the same question, I've seen implementation of the mAP using sklearn (great for pytorch), but I have not found a way to compute it using tensorflow. Someone has an idea ? </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1359002": "As topic concerned, how to calculate mAP in python. who can share some of the codes?",
    "1359267": "You can use sklearn's `average_precision_score` metric documented [here](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html). You may have to use `average='samples'` or `average='macro'` depending on your use case. Code example copied directly from their documentation:\n```\n>>> import numpy as np\n>>> from sklearn.metrics import average_precision_score\n>>> y_true = np.array([0, 0, 1, 1])\n>>> y_scores = np.array([0.1, 0.4, 0.35, 0.8])\n>>> average_precision_score(y_true, y_scores)\n```",
    "1359448": "I'm having the same question, I've seen implementation of the mAP using sklearn (great for pytorch), but I have not found a way to compute it using tensorflow. Someone has an idea ?"
  },
  "source": "meta"
}