question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Additional metrics in `sklearn.metrics.classification_report`

See original GitHub issue

Describe the workflow you want to enable

Metrics are Extremely Important for benchmarking models’ performance. But in scikit-learn, it is not easy to extract these metrics from a multiclass classification model. In the past, I had to combine different pieces of functions within the sklearn.metrics module in order to derive my own. But it is counterproductive, so I end up staying away from scikit-learn, and using other libraries such as pycm, mlxtend, yellowbrick, … etc to get the job done. It is not perfect and still requires some customization, but they are more complete, and much easier to use than scikit-learn. So it would be great if scikit-learn can improve a little more in this area, so that we can focus more on modeling than customizing the code.

Describe your proposed solution

metrics.classification_report is a good start. The current metrics.classification_report return

  • Precision (Positive Predictive Value)
  • Recall (True Positive Rate)
  • F1
  • Support

It is great, but far from complete. The following 2 are very important as well

  • Negative Predictive Value (NPV)
  • Specificity (True Negative Rate, or TNR)

Once we can cover these 4 metrics for the multiclass classification

  • Precision (Positive Predictive Value) --> requires (TP, FP)
  • Recall (True Positive Rate) --> requires (TP, FN)
  • Negative Predictive Value (NPV) --> requires (TN, FN)
  • Specificity (True Negative Rate) --> requires (TN, FP)

we can pretty much derive the rest of the metrics, such as

  • FNR (False Negative Rate = 1 - TPR)
  • FPR (False Positive Rate = 1 - TNR)
  • FDR (False Discovery Rate = 1 - PPV)
  • FOR (False Omission Rate = 1 - NPV)
  • ACC (Accuracy)
  • MCC (Mathews Correlation Coefficient)
  • Prevalence Threshold
  • …etc

These 2 are quite important as well, but it can be tricky to get for multiclass classification

  • AUROC (Area under ROC)
  • AUPR (Area under Precision-Recall curve)

The pycm library is quite comprehensive. Perhaps you may consider integrating some of their goodies into scikit-learn.

Describe alternatives you’ve considered, if relevant

No response

Additional context

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
adrinjalalicommented, Sep 14, 2021

@glemaitre would you mind creating an issue which would cover all-ish the open issues we have and have your proposed APIs there, so that the rest of us can have a look and take the API discussion from there?

1reaction
glemaitrecommented, Sep 14, 2021

I would advise not to start working on this issue since that there are no feedbacks from @scikit-learn/core-devs regarding the API

Read more comments on GitHub >

github_iconTop Results From Across the Web

sklearn.metrics.classification_report — scikit-learn 1.2.0 ...
sklearn.metrics .classification_report¶ ; precision_recall_fscore_support. Compute precision, recall, F-measure and support for each class. ; confusion_matrix.
Read more >
How to Interpret the Classification Report in sklearn (With ...
1. Precision: Percentage of correct positive predictions relative to total positive predictions. · 2. Recall: Percentage of correct positive ...
Read more >
Understanding the Classification report through sklearn
The report shows the main classification metrics precision, recall and f1-score on a per-class basis. The metrics are calculated by using true ...
Read more >
scikit learn output metrics.classification_report into CSV/tab ...
As of scikit-learn v0.20, the easiest way to convert a classification report to a pandas Dataframe is by simply having the report returned...
Read more >
Generate classification report and confusion matrix in Python
For this we need to compute there scores by classification report and ... sklearn.metrics import classification_report, confusion_matrix.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found