MATLAB Answers

How to calculate confusion matrix , accuracy and precision

297 views (last 30 days)
Abdussalam Elhanashi
Abdussalam Elhanashi on 10 Dec 2020
Answered: Srivardhan Gadila on 17 Dec 2020
Hi
I have two logical tables 100 x 100 for each that contain 0 & 1 values . one table for original values and other table is for predicted values
i want to know how can i make confusion matrix and calculate accuracy and precision for predicted values in comparision to original values
Here the tables:-
original values
predicted values

Answers (1)

Srivardhan Gadila
Srivardhan Gadila on 17 Dec 2020
You can refer to the following functions available in MATLAB to compute confusion matrix: Functions for computing "confusion matrix".
accuracy = sum(OrigValues == PredValues,'all')/numel(PredValues)
Make sure that the above computations are performed properly w.r.t the number of samples dimension and necessary changes are to be made based on it (i.e., Dimension of number of samples can be number of rows or number of columns or the number of tables itself in your case as it is not mentioned anywhere in the question).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by