How to calculate true positive, true negative, false positive and false negative?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone!
I created artificial neural network to compute answers for my diagnosis. Now, I would like to compare the amount of true positive, true negative, false positive and false negative. I was thinking about creating a loop and count every values.
Thank you for your help.
0 Kommentare
Antworten (3)
Shreeya
am 13 Jan. 2024
To calculate the TP, TN, FP, FN, you can refer to the code down below.
% An example considering 1 & 2 as positive and 3 as negative:
real = [1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3];
predicted = [2 2 3 2 1 2 3 2 3 3 3 3 3 3 3 3 3 3 3 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3];
realPos = (real==1) | (real == 2);
realNeg = ~realPos;
predictedPos = (predicted==1) | (predicted == 2);
predictedNeg = ~predictedPos;
TP = sum(predictedPos & realPos) % 6
FP = sum(predictedPos & realNeg) % 1
TN = sum(predictedNeg & realNeg) % 27
FN = sum(predictedNeg & realPos) % 6
This code has been sourced from the MATLAB answer linked here: https://www.mathworks.com/matlabcentral/answers/1997058-how-can-i-calculate-true-positive-false-positive-true-negative-and-false-negative-of-real-and-pred
You can refer to the discussion for more details.
0 Kommentare
Shawbo
am 7 Jan. 2025
Bearbeitet: Walter Roberson
am 7 Jan. 2025
clc
syms x
a=input('a=');
b=input('b=');
er=input('er=');
f=input('the function is f(x)=');
g=inline(f);
if(g(a)*g(b)<0
b=c;
else
a=c;
end
disps([a b c abc(a-b)]
end
else
disp('the root does not exist in this interval')
end
1 Kommentar
Walter Roberson
am 7 Jan. 2025
Please explain in more detail how this answers the question of calculating true positives and so on?
Shawbo
am 7 Jan. 2025
Bearbeitet: Shawbo
am 7 Jan. 2025
A=[13 2 3 2,4 3 2 5,6 8 9 10]
1 Kommentar
Walter Roberson
am 7 Jan. 2025
Please explain in more detail how this answers the question of calculating true positives and so on?
Siehe auch
Kategorien
Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!