How to calculate confusion matrix , accuracy and precision

398 views (last 30 days)
Abdussalam Elhanashi
Abdussalam Elhanashi on 10 Dec 2020
Answered: Ayokunmi Opaniyi on 22 May 2022
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 (2)

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).

Ayokunmi Opaniyi
Ayokunmi Opaniyi on 22 May 2022
I will like to calculate the accuracy, precision and recall of my dataset in matlab.
can anyone please help me how to go about it with the sample code.
Thank you in advance.

Community Treasure Hunt

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

Start Hunting!

Translated by