{
  "id": 75593,
  "title": "How Do I Find Matthews correlation coefficient? ",
  "url": "/competitions/vsb-power-line-fault-detection/discussion/75593",
  "author_name": "",
  "post_date": "2018-12-23T19:37:38.870852Z",
  "votes": null,
  "comment_count": 5,
  "views": 0,
  "content": "<p>i want to find Matthews correlation coefficient</p>",
  "messages": [
    {
      "id": "444320",
      "postDate": "12/23/2018 19:37:38",
      "content": "<p>i want to find Matthews correlation coefficient</p>",
      "rawMarkdown": "i want to find Matthews correlation coefficient",
      "votes": null
    },
    {
      "id": "444345",
      "postDate": "12/23/2018 20:42:55",
      "content": "<p>You can use Matthews correlation coefficient from <a href=\"https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html#sklearn.metrics.matthews_corrcoef\">sklearn</a>.</p>",
      "rawMarkdown": "You can use Matthews correlation coefficient from [sklearn][1].\n\n[1]: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html#sklearn.metrics.matthews_corrcoef",
      "votes": null
    },
    {
      "id": "444350",
      "postDate": "12/23/2018 20:46:57",
      "content": "<p>```\nimport numpy as np\nimport pandas as pd\ntrain_meta_df = pd.read_csv(\"metadata_train.csv\")\ntrue_labels = np.copy(train_meta_df['target'].values)\npred_labels = np.copy(train_meta_df['target'].values)\nprint len(pred_labels)\nprint sum(pred_labels)\nprint sum(true_labels)\npred_labels[int(len(pred_labels)/2):] = 0#np.ones(len(train_meta_df['target'].values))[int(len(pred_labels)/8):]\nprint sum(pred_labels)\nprint sum(true_labels)</p>\n\n<h1>True Positive (TP): we predict a label of 1 (positive), and the true label is 1.</h1>\n\n<p>TP = np.sum(np.logical_and(pred_labels == 1, true_labels == 1))</p>\n\n<h1>True Negative (TN): we predict a label of 0 (negative), and the true label is 0.</h1>\n\n<p>TN = np.sum(np.logical_and(pred_labels == 0, true_labels == 0))</p>\n\n<h1>False Positive (FP): we predict a label of 1 (positive), but the true label is 0.</h1>\n\n<p>FP = np.sum(np.logical_and(pred_labels == 1, true_labels == 0))</p>\n\n<h1>False Negative (FN): we predict a label of 0 (negative), but the true label is 1.</h1>\n\n<p>FN = np.sum(np.logical_and(pred_labels == 0, true_labels == 1))\nprint 'TP: %i, FP: %i, TN: %i, FN: %i' % (TP, FP, TN, FN)\nmmc = (TP*TN - FP*FN)/np.sqrt((TP+FP)<em>(TP+FN)</em>(TN+FP)*(TN+FN)+0.01)\nprint mmc\n```</p>\n\n<p>Is this what you mean?</p>",
      "rawMarkdown": "```\nimport numpy as np\nimport pandas as pd\ntrain_meta_df = pd.read_csv(\"metadata_train.csv\")\ntrue_labels = np.copy(train_meta_df['target'].values)\npred_labels = np.copy(train_meta_df['target'].values)\nprint len(pred_labels)\nprint sum(pred_labels)\nprint sum(true_labels)\npred_labels[int(len(pred_labels)/2):] = 0#np.ones(len(train_meta_df['target'].values))[int(len(pred_labels)/8):]\nprint sum(pred_labels)\nprint sum(true_labels)\n# True Positive (TP): we predict a label of 1 (positive), and the true label is 1.\nTP = np.sum(np.logical_and(pred_labels == 1, true_labels == 1))\n# True Negative (TN): we predict a label of 0 (negative), and the true label is 0.\nTN = np.sum(np.logical_and(pred_labels == 0, true_labels == 0))\n# False Positive (FP): we predict a label of 1 (positive), but the true label is 0.\nFP = np.sum(np.logical_and(pred_labels == 1, true_labels == 0))\n# False Negative (FN): we predict a label of 0 (negative), but the true label is 1.\nFN = np.sum(np.logical_and(pred_labels == 0, true_labels == 1))\nprint 'TP: %i, FP: %i, TN: %i, FN: %i' % (TP, FP, TN, FN)\nmmc = (TP*TN - FP*FN)/np.sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)+0.01)\nprint mmc\n```\n\nIs this what you mean?",
      "votes": null
    },
    {
      "id": "444529",
      "postDate": "12/24/2018 07:34:37",
      "content": "<p>yes thank you.</p>",
      "rawMarkdown": "yes thank you.",
      "votes": null
    },
    {
      "id": "444530",
      "postDate": "12/24/2018 07:35:06",
      "content": "<p>ok thanks for your answer.</p>",
      "rawMarkdown": "ok thanks for your answer.",
      "votes": null
    },
    {
      "id": "453100",
      "postDate": "01/09/2019 17:03:38",
      "content": "<p>You can use this one as well:\n<a href=\"https://www.kaggle.com/c/vsb-power-line-fault-detection/discussion/76682\">https://www.kaggle.com/c/vsb-power-line-fault-detection/discussion/76682</a></p>",
      "rawMarkdown": "You can use this one as well:\nhttps://www.kaggle.com/c/vsb-power-line-fault-detection/discussion/76682",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 444345,
      "author_name": "ddanevskyi",
      "author_url": "",
      "post_date": "12/23/2018 20:42:55",
      "content": "<p>You can use Matthews correlation coefficient from <a href=\"https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html#sklearn.metrics.matthews_corrcoef\">sklearn</a>.</p>",
      "votes": null,
      "replies": [
        {
          "id": 444530,
          "author_name": "jayesh4520",
          "author_url": "",
          "post_date": "12/24/2018 07:35:06",
          "content": "<p>ok thanks for your answer.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 444350,
      "author_name": "corner200",
      "author_url": "",
      "post_date": "12/23/2018 20:46:57",
      "content": "<p>```\nimport numpy as np\nimport pandas as pd\ntrain_meta_df = pd.read_csv(\"metadata_train.csv\")\ntrue_labels = np.copy(train_meta_df['target'].values)\npred_labels = np.copy(train_meta_df['target'].values)\nprint len(pred_labels)\nprint sum(pred_labels)\nprint sum(true_labels)\npred_labels[int(len(pred_labels)/2):] = 0#np.ones(len(train_meta_df['target'].values))[int(len(pred_labels)/8):]\nprint sum(pred_labels)\nprint sum(true_labels)</p>\n\n<h1>True Positive (TP): we predict a label of 1 (positive), and the true label is 1.</h1>\n\n<p>TP = np.sum(np.logical_and(pred_labels == 1, true_labels == 1))</p>\n\n<h1>True Negative (TN): we predict a label of 0 (negative), and the true label is 0.</h1>\n\n<p>TN = np.sum(np.logical_and(pred_labels == 0, true_labels == 0))</p>\n\n<h1>False Positive (FP): we predict a label of 1 (positive), but the true label is 0.</h1>\n\n<p>FP = np.sum(np.logical_and(pred_labels == 1, true_labels == 0))</p>\n\n<h1>False Negative (FN): we predict a label of 0 (negative), but the true label is 1.</h1>\n\n<p>FN = np.sum(np.logical_and(pred_labels == 0, true_labels == 1))\nprint 'TP: %i, FP: %i, TN: %i, FN: %i' % (TP, FP, TN, FN)\nmmc = (TP*TN - FP*FN)/np.sqrt((TP+FP)<em>(TP+FN)</em>(TN+FP)*(TN+FN)+0.01)\nprint mmc\n```</p>\n\n<p>Is this what you mean?</p>",
      "votes": null,
      "replies": [
        {
          "id": 444529,
          "author_name": "jayesh4520",
          "author_url": "",
          "post_date": "12/24/2018 07:34:37",
          "content": "<p>yes thank you.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 453100,
      "author_name": "harshit92",
      "author_url": "",
      "post_date": "01/09/2019 17:03:38",
      "content": "<p>You can use this one as well:\n<a href=\"https://www.kaggle.com/c/vsb-power-line-fault-detection/discussion/76682\">https://www.kaggle.com/c/vsb-power-line-fault-detection/discussion/76682</a></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "444320": "i want to find Matthews correlation coefficient",
    "444345": "You can use Matthews correlation coefficient from [sklearn][1].\n\n[1]: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html#sklearn.metrics.matthews_corrcoef",
    "444350": "```\nimport numpy as np\nimport pandas as pd\ntrain_meta_df = pd.read_csv(\"metadata_train.csv\")\ntrue_labels = np.copy(train_meta_df['target'].values)\npred_labels = np.copy(train_meta_df['target'].values)\nprint len(pred_labels)\nprint sum(pred_labels)\nprint sum(true_labels)\npred_labels[int(len(pred_labels)/2):] = 0#np.ones(len(train_meta_df['target'].values))[int(len(pred_labels)/8):]\nprint sum(pred_labels)\nprint sum(true_labels)\n# True Positive (TP): we predict a label of 1 (positive), and the true label is 1.\nTP = np.sum(np.logical_and(pred_labels == 1, true_labels == 1))\n# True Negative (TN): we predict a label of 0 (negative), and the true label is 0.\nTN = np.sum(np.logical_and(pred_labels == 0, true_labels == 0))\n# False Positive (FP): we predict a label of 1 (positive), but the true label is 0.\nFP = np.sum(np.logical_and(pred_labels == 1, true_labels == 0))\n# False Negative (FN): we predict a label of 0 (negative), but the true label is 1.\nFN = np.sum(np.logical_and(pred_labels == 0, true_labels == 1))\nprint 'TP: %i, FP: %i, TN: %i, FN: %i' % (TP, FP, TN, FN)\nmmc = (TP*TN - FP*FN)/np.sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)+0.01)\nprint mmc\n```\n\nIs this what you mean?",
    "444529": "yes thank you.",
    "444530": "ok thanks for your answer.",
    "453100": "You can use this one as well:\nhttps://www.kaggle.com/c/vsb-power-line-fault-detection/discussion/76682"
  },
  "source": "meta"
}