{
  "id": 370722,
  "title": "Evaluated on Matthews Correlation Coefficient Python [code]",
  "url": "/competitions/nfl-player-contact-detection/discussion/370722",
  "author_name": "Wongi Park",
  "post_date": "2022-12-06T06:06:42.442000",
  "votes": 12,
  "comment_count": 0,
  "views": 0,
  "content": "<p>Matthews correlation coefficient (MCC) is a metric we can use to assess the performace of a classification model.</p>\n<p>The following example shows how to calculate MCC for this exact scenario using the matthews_corrcoef() function from the sklearn library in Python.</p>\n<p><a href=\"https://www.kaggle.com/competitions/nfl-player-contact-detection/discussion/370723\" target=\"_blank\">Matthews correlation coefficient (MCC) Loss function code</a></p>\n<pre><code>import numpy as np\nfrom sklearn.metrics import matthews_corrcoef\n\n#define actual classes\nactual = np.repeat([1, 0], repeats=[20, 380])\n\n#define predicted classes\npred = np.repeat([1, 0, 1, 0], repeats=[15, 5, 5, 375])\n\n#calculate Matthews correlation coefficient (MCC)\nmatthews_corrcoef(actual, pred)\n</code></pre>",
  "messages": [
    {
      "id": 2056451,
      "postDate": "2022-12-06T06:06:42.443Z",
      "content": "<p>Matthews correlation coefficient (MCC) is a metric we can use to assess the performace of a classification model.</p>\n<p>The following example shows how to calculate MCC for this exact scenario using the matthews_corrcoef() function from the sklearn library in Python.</p>\n<p><a href=\"https://www.kaggle.com/competitions/nfl-player-contact-detection/discussion/370723\" target=\"_blank\">Matthews correlation coefficient (MCC) Loss function code</a></p>\n<pre><code>import numpy as np\nfrom sklearn.metrics import matthews_corrcoef\n\n#define actual classes\nactual = np.repeat([1, 0], repeats=[20, 380])\n\n#define predicted classes\npred = np.repeat([1, 0, 1, 0], repeats=[15, 5, 5, 375])\n\n#calculate Matthews correlation coefficient (MCC)\nmatthews_corrcoef(actual, pred)\n</code></pre>",
      "rawMarkdown": "Matthews correlation coefficient (MCC) is a metric we can use to assess the performace of a classification model.\n\nThe following example shows how to calculate MCC for this exact scenario using the matthews_corrcoef() function from the sklearn library in Python.\n\n[Matthews correlation coefficient (MCC) Loss function code](https://www.kaggle.com/competitions/nfl-player-contact-detection/discussion/370723)\n\n```\nimport numpy as np\nfrom sklearn.metrics import matthews_corrcoef\n\n#define actual classes\nactual = np.repeat([1, 0], repeats=[20, 380])\n\n#define predicted classes\npred = np.repeat([1, 0, 1, 0], repeats=[15, 5, 5, 375])\n\n#calculate Matthews correlation coefficient (MCC)\nmatthews_corrcoef(actual, pred)\n```\n",
      "votes": 12
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "2056451": "Matthews correlation coefficient (MCC) is a metric we can use to assess the performace of a classification model.\n\nThe following example shows how to calculate MCC for this exact scenario using the matthews_corrcoef() function from the sklearn library in Python.\n\n[Matthews correlation coefficient (MCC) Loss function code](https://www.kaggle.com/competitions/nfl-player-contact-detection/discussion/370723)\n\n```\nimport numpy as np\nfrom sklearn.metrics import matthews_corrcoef\n\n#define actual classes\nactual = np.repeat([1, 0], repeats=[20, 380])\n\n#define predicted classes\npred = np.repeat([1, 0, 1, 0], repeats=[15, 5, 5, 375])\n\n#calculate Matthews correlation coefficient (MCC)\nmatthews_corrcoef(actual, pred)\n```\n"
  }
}