10000 Adding Fall-out, Miss rate, specificity as metrics · Issue #5516 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Adding Fall-out, Miss rate, specificity as metrics #5516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
languitar opened this issue Oct 21, 2015 · 39 comments · May be fixed by #19556
Open

Adding Fall-out, Miss rate, specificity as metrics #5516

languitar opened this issue Oct 21, 2015 · 39 comments · May be fixed by #19556

Comments

@languitar
Copy link

It would be nice if these rates would be included in the metrics module:

  • False positive rate (Fall-out)
  • False negative rate (Miss rate)
  • True negative rate (specificity)
@amueller
Copy link
Member

there is confusion_matrix

@languitar
Copy link
Author

Right, I used this to implement on of these rates that I needed. But still, why shouldn't everyone be able to calculate these rates di 8000 rectly? Pulling the data from the unlabled confusion matrix is also error-prone.

@jnothman
Copy link
Member

Would an example of getting these from the diagonal and marginals of the
confusion matrix suffice?

On 22 October 2015 at 07:40, Johannes Wienke notifications@github.com
wrote:

Right, I used this to implement on of these rates that I needed. But
still, why shouldn't everyone be able to calculate these rates directly?
Pulling the data from the unlabled confusion matrix is also error-prone.


Reply to this email directly or view it on GitHub
#5516 (comment)
.

@languitar
Copy link
Author

Why not just add them as new metrics or loss functions?

@amueller
Copy link
Member

usually you want to compute all four, right? Or do you want to use only a single one and select a model using FPR? That would seem a bit odd to me.

@languitar
Copy link
Author

Right now I only need them for debugging purposes, so I don't select models at all using this. I wouldn't care much if there are 4 different methods or just a single one. However, the current metrics interface usually just computes a single score. So having four separate methods would be more consistent to my mind.

@amueller
Copy link
Member

precision_recall_fscore_support computes three ;) Well we can add four new methods, or we could add a normalize option to the confusion matrix.

@languitar
Copy link
Author

I would be against having to pull the numbers from the confusion matrix as their are no named entries in this matrix and it is easy to mix up the indices. So you end up with a metric you didn't intend to compute.

@arjoly arjoly changed the title Please add FP, TN, FN rates as metrics Adding Fall-out, Miss rate, specificity rates as metrics Oct 24, 2015
@arjoly arjoly changed the title Adding Fall-out, Miss rate, specificity rates as metrics Adding Fall-out, Miss rate, specificity as metrics Oct 24, 2015
@arjoly
Copy link
Member
arjoly commented Oct 24, 2015

Why not, those metrics could be added if there are good explanation on what they bring compare to what we already have.

@languitar
Copy link
Author

For me there is a paper which used one of these rates and I want to compare against that.

@josephdviviano
Copy link

I agree with @languitar -- especially when trying to replicate old results that are reported. This sort of thing can be field-specific (e.g., I'm in neuroscience, where machine learning expertise is low compared to computer scientists, and many are forced to follow methods blindly to be consistent with previous work by reviewers).

@dourouc05
Copy link

Trying to exploit a confusion matrix, I find this "old" issue. The problem with the confusion matrix is that finding your way through the indices is a nightmare, hence problems with the definitions of rates mentioned earlier.

I am dreaming of a useable interface for this matrix, something like:

confusion_matrix(actual, predicted).get(actual_class=2, predicted_class=3)

Then, it could be extended to define other metrics if necessary, for example in binary classification:

confusion_matrix(actual, predicted).specificity()

The major problem I see is that confusion_matrix returns a matrix, which means that there is very little room to expand the interface without breaking retrocompatibility. That means that some new syntax is needed (or is there a way to add methods to a matrix or to return an object that would automatically be casted as a matrix when needed?).

Of course, I propose myself as a contributor for this.

@jnothman
Copy link
Member 8000
jnothman commented Apr 2, 2017 via email

@dourouc05
Copy link

Indeed, that does help a bit, but not much more than this. (As a side note, it seems that there is a small syntax error in the documentation file, as that part of the documentation shows everything as a single line; a missing empty line before line 240?)

The main problem is that the syntax does not really make sense, there is nothing intuitive behind ravel: if you switch tp and tn, there is no way you can see something is wrong (unless you compare your code to the documentation or work out the code line by line with a debugger on a small example — supposing you know there is something wrong!).

On the other hand, if you write this:

true_negatives = confusion_matrix(actual, predicted).false_positives()
true_negatives = confusion_matrix(actual, predicted).get(actual_class=0, predicted_class=2)

then you can see quite directly that there is something wrong there. What is more, this kind of syntax could be easily extrapolated to multiclass metrics (for example, following this review article: http://rali.iro.umontreal.ca/rali/sites/default/files/publis/SokolovaLapalme-JIPM09.pdf).

@jnothman
Copy link
Member
jnothman commented Apr 2, 2017 via email

@glemaitre
Copy link
Member

To be honest, I did not see the issue before. Since it has been tagged and if this is still of interest to have an implementation of those metrics, we have implemented a sensitivity_specificity_support function in imblearn as well as the score functions.

I completely agree with @josephdviviano .
They are the standard metrics --- in conjunction with the AUC of the ROC --- that I saw in cancer prostate detection and melanoma detection. In these fields, the precision-recall are not used.

However, I am not sure that this is a good enough argument to implement them.

@arjoly
Copy link
Member
arjoly commented Apr 13, 2017

I think they would make good additions. However special cares need to be taken in the documentation to highlight what they bring to the error measurement process.

@erolrecep
Copy link
erolrecep commented Jun 5, 2017

I just realize that there is a relationship between specificity and sensitivity scores of two classes.
Classification report :
precision recall f1-score support

      0       1.00      0.95      0.97        57
      1       0.97      1.00      0.98        86

avg / total 0.98 0.98 0.98 143

Confusion matrix :
[[54 3]
[ 0 86]]

Confusion Matrix
[[TP FN
FP TN]]

Precision is (TP)/(TP + FP)
Sensitivity (Recall) is (TP)/(TP+FN)
Specificity is (TN)/(TN+FP)

If we think of

Precision for class 0 is 54 / 54 + 0 which is 1.
Precision for class 1 is it's reverse which is 86.0 / 86 + 3 equal to 0.97 -> (TN)/(TN+FN).

Specificity for class 0 is 86.0 / 86 + 0 which is 1.
Specificity for class 1 is 54.0 / 54 + 3 which is 0.95.

Sensitivity (Recall) for class 0 is 54.0 / 54+3 which is 0.95 -> the same as Specificity for class 1.
Sensitivity (Recall) for class 1 is 86.0 / 86 + 0 which is 1. -> (TN)/(TN+FP) which is the same of Specificity for class 0.

So, the classification report already gives us the Specificity scores for both classes which are reverse of each class's Recall values.

@amueller
Copy link
Member
amueller commented Jun 6, 2017

I'm happy to add additional metrics, but I don't think we should add alias functions for say, sensitivity.

A reasonable implementation of
confusion_matrix(actual, predicted).get(actual_class=0, predicted_class=2)
would be
get_confusion(confusion_matrix(actual, predicted), actual_class=0, predicted_class=2)
but I'm not sure that adds enough value. It's basically naming the axis of the matrix.

I'm not sure what confusion_matrix(actual, predicted).false_positives() is supposed to do.
We could add false_positive_rate with a parameter for the positive class, which would be OvR, but is that standard? We could also have these functions but restrict them to the binary case?

@jnothman jnothman added good first issue Easy with clear instructions to resolve and removed Sprint labels Jan 29, 2018
@jnothman
Copy link
Member
jnothman commented Jan 29, 2018

I think it's worth defining functions for each of these, or at least scorers. That would be the simplest API-consistent way to do it, I think, and users do benefit from being able to find these names, certainly now that we support multiple scorers for CV/gridsearch.

@haochunchang
Copy link
Contributor

take

@madprogramer
Copy link
madprogramer commented Sep 5, 2020

Is this still an issue, or is the updated more verbose output for confusion_matrixs satisfactory now? If so could someone please close this issue?

@glemaitre
Copy link
Member

No this is still an opened issue. I see that we did not got any bandwidth to review #17265

@vaibhavmehrotraml
Copy link

I want to take this up.
Going to start reviewing #17265

@BatMrE
Copy link
BatMrE commented Aug 25, 2021

Hi, if its still open, and something specific need to be done can I work on it by creating a new PR??

@Bhavya1705
Copy link
Bhavya1705 commented Aug 28, 2021

Hello, I have started working on this.

@Bhavya1705
Copy link
Bhavya1705 commented Aug 31, 2021

Please if see the above pull request is satisfactory to your needs - I have added separate functions for Miss rate, fall out, Specificity and sensitivity.

@LawJarp-A
Copy link

Hello, is this issue still open to work on?

@haochunchang haochunchang removed their assignment Dec 14, 2021
@thomasjpfan thomasjpfan removed the good first issue Easy with clear instructions to resolve label Jan 6, 2022
@josephdviviano
Copy link

Looks like this feature is awaiting approval here: #19556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0