File Exchange

image thumbnail

Multi Class Confusion Matrix

version 2.1.0.0 (7.76 KB) by Abbas Manthiri S
Calclating kappa, acuuracy,error,Sensitivity ,Specificity , Precision,False positive rate etc.

104 Downloads

Updated 21 Jul 2017

View License

This code is designed for two or more classes instance confusion matrix formation and Calclating
1acuuracy
2.error
3.Sensitivity (Recall or True positive rate)
4.Specificity
5.Precision
6.FPR-False positive rate
7.F_score
8.MCC-Matthews correlation coefficient
9.kappa-Cohen's kappa
Run demo.m for proof and demo
Developer Er.Abbas Manthiri S
Date 25-12-2016
Mail Id: abbasmanthiribe@gmail.com
Coding is based on attached reference

Comments and Ratings (27)

SY

SY (view profile)

This is awesome, thanks Abbas

ali albayati

Wander full, Save lots of time to compute each stat, Thank you

Richa

Richa (view profile)

Hi,

To make this work for mutliclass in case Class List is not same .. i commented the error condition "error('Class List is not same in given inputs')" and "error('Class List in given inputs are different')". Also, tweaked the code on line 81 as
if length(un_actual) >= length(un_predict)
n_class=length(un_actual);
else
n_class=length(un_predict);
end

Richa

Richa (view profile)

I get error as "Class List is not same in given inputs" while running it on my data. Please help

Zoe

Zoe (view profile)

Richa

Richa (view profile)

When i call classify() it returns the Predicted_labels in "categorical" format, whivh while passing it to geMatrix gives an error that it does not support catgorical values. How to resolve this

Anamika jain

i got the results for Precision and recall but the graph i am plotting is not giving the desired plot what to do now.?? what mistake i am making anyone please help.

Natsu dragon

Sabri Kr

LEE ZISHENG

This is a useful submission. It would be great if the class name was different, as it overloads the MATLAB confusion function:
https://www.mathworks.com/help/nnet/ref/confusion.html

Thanks Abbas, great code, saved me quite some time!

I update the file
Thanks for feedback

@this line
i put mistake please change
Result.Error=1-sum(Error);
as
Result.Error=sum(Error);

i will update that code
on sunday
thank for giving feed back

Thank you abbas for making corrections.Excellent contribution from your side.
If you want to improve it more.Make this code capable for dealing with multi-class with binary (0,1) values only
having multiple rows/col.Just like this example.https://www.mathworks.com/help/nnet/examples/wine-classification.html.Your code gives error on this example dataset.This code only deals with single rows and single col as input/output.

@Machine Learning Enthusiast

File updated
Thanks for feed back

@Machine Learning Enthusiast
I Checked my coding for you
i calculate the single class accuracy rate so change the formula
to in line 192
And formula available only to calculate Accuracy for two class only
we dont have formula for single class accuracy over multiclass

thanks for your feedback

Secondly can you please check.It calculates the True Negative correctly?.In my case it calculates wrong

excellent code.I am dealing with 3 class problem.I have just one question in codeline 192, when calculating the accuracy for each class. It gives the wrong accuracy for each class?.Any insight on this from your side will be greatly appreciated.

@Carlos Lopez Vydrin because multi-class confusion matrix changes formula compare to two class confusion matrix

Thank you for this wonderful code. I have just one question in codeline 192, when calculating the accuracy for each class. Why have you put an "Case/otherwise"-statement and why is the "accuracy"-calculations different in codeline 192 and 187?

Many thanks

@ Kh. Islam Thank you

Kh. Islam

Thank you for your efforts.

Updates

2.1.0.0

small typo changed
error now give correct value

2.0.0.0

Bugs removed
Added sub Accuracy for each by in total and alone

1.601.0.0

nothing changed

1.6.0.0

code improved

1.52.0.0

Name changed

1.51.0.0

publish view improved
to view click on demo

1.5.0.0

Coding converted to class method

1.31.0.0

Clear Publish view

1.3.0.0

html view

1.2.0.0

bugs removed

1.1.0.0

extra datum given to output

1.0.0.0

bugs removed

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor

confusion matrix/

confusion matrix/html/