goodboyanush / isme-bangalore-Oct-Nov-2019

Apache License 2.0
2 stars 17 forks source link

how to find percentage of false positive and false negative in confusion matrix #2

Open sudeeshsahu opened 4 years ago

sudeeshsahu commented 4 years ago

sir i i have 4 categories in my class variable hence the confusion matrix is a 4X4 matrix so how do i find the percentage of false negative and false positive

goodboyanush commented 4 years ago

@sudeeshsahu the answer here by makis explains the answer to your question beautifully with diagrams

https://stackoverflow.com/questions/50666091/true-positive-rate-and-false-positive-rate-tpr-fpr-for-multi-class-data-in-py

Do go through it and if you still have questions, I will be happy to answer.

sudeeshsahu commented 4 years ago

Thank you for the support sir, i will look into it . Have a good day sir. On Nov 12, 2019 11:49 AM, "Anush Sankaran" notifications@github.com wrote:

@sudeeshsahu https://github.com/sudeeshsahu the answer here by makis explains the answer to your question beautifully with diagrams

https://stackoverflow.com/questions/50666091/true-positive-rate-and-false- positive-rate-tpr-fpr-for-multi-class-data-in-py

Do go through it and if you still have questions, I will be happy to answer.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/goodboyanush/isme-bangalore-Oct-Nov-2019/issues/2?email_source=notifications&email_token=AMH5NA52AGL45W5X4T64AX3QTJDIFA5CNFSM4JLWL7FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDZFJNI#issuecomment-552752309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMH5NA7KDKTPZO7GAE45DDTQTJDIFANCNFSM4JLWL7FA .

sudeeshsahu commented 4 years ago

sir i actually found a method to convert a multi-class confusion matrix into a binary class confusion matrix. so can i use this way to find out the percentage of false positive and false negative. this is the code i used: import mlxtend from mlxtend.evaluate import confusion_matrix confusion_matrix(y_test,nn_pred,binary=True) can i move forward with this method?

goodboyanush commented 4 years ago

@sudeeshsahu That will not exactly work in this case. Consider the example:

y_actual=    [1, 1, 1, 0, 0, 2, 0, 3]
y_predicted = [1, 0, 1, 0, 0, 2, 1, 3]

where there are 4 possible class labels - [0,1,2,3]

The actual confusion matrix, will look something like:

image

However, when we want to convert them into binary class label based confusion matrix, we will do the following:

cm = confusion_matrix(y_target=y_actual, 
                      y_predicted=y_predicted, 
                      binary=True, 
                      positive_label=1)

where, along with the other inputs we should also give which is that one class label that we consider as positive class - positive_label=1. Thus, all the other three class labels become negative class and made as 0 . In the above example all the three classes [0,2,3] becomes 0.

We cannot do that because, all four class labels are correct. Thus, I strongly recommend that we go by the method as proposed in: https://stackoverflow.com/questions/50666091/true-positive-rate-and-false-positive-rate-tpr-fpr-for-multi-class-data-in-py