How to plot Confusion Matrix with tolerence limit ?

1 次查看(过去 30 天)
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.

采纳的回答

MarKf
MarKf 2023-5-2
编辑:MarKf 2023-5-2
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by