How to plot Confusion Matrix with tolerence limit ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
RAJEEV
el 2 de Mayo de 2023
Comentada: RAJEEV
el 10 de Mayo de 2023
I have Measured Output and Predicted output. I want to create a confusion matrix with 10% tolerance limit. How can I plot ?
Predicted Value = P_out
Target Value = T_out
max = 1.1*T_out
min = 0.9*T_out
True Positive: (P_out >= T_out) and (P_out<= max)
True Negative: (P_out <= T_out) and (P_out>=min)
False Positive: (P_out > max)
False Positive: (P_out < max)
I have attached the values for your reference.
0 comentarios
Respuesta aceptada
MarKf
el 2 de Mayo de 2023
Editada: MarKf
el 2 de Mayo de 2023
So you just want to translate the pseudo code above into working code and choose how to best plot it. The pseudo code probably does not do what you want, seeing the result, and needs some troubleshooting (see comments in code). In any case, it wouldn't be a confusion matrix if elements are allowed in more than one cell and the sum is more than the total. But here it is:
confdat = xlsread(websave('rd', "https://nl.mathworks.com/matlabcentral/answers/uploaded_files/1372189/Confusion.xlsx"));
T_out = confdat(:,1); % I had assumed Predicted Value to be the first column since that's how you ordered them
P_out = confdat(:,2); % then I actually checked the xls file
maxTou = 1.1.*T_out;
minTou = 0.9.*T_out;
Tr_Pos = (P_out >= T_out) & (P_out <= maxTou);
Tr_Neg = (P_out <= T_out) & (P_out >= minTou); % all 0s (try switching maxTou/minTou here and line above)
Fa_Pos = (P_out > maxTou); % all 1s here, that's what I meant with "probably does not do what you want"
Fa_Neg = (P_out < maxTou); % see above, I'll assume you meant False Negative here (maybe minTou)
conmat = [sum(Tr_Pos) sum(Fa_Pos); sum(Fa_Neg) sum(Tr_Neg)];
cm = confusionchart(conmat); %this is one way to plot, convenient
cm.Title = 'Confusion ± 10% tolerance';
cm.RowSummary = 'row-normalized'; %adds percentage rows (or % cm.ColumnSummary = 'column-normalized'; columns),% you can omit this
Más respuestas (0)
Ver también
Categorías
Más información sobre Bar Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!