# How to plot Confusion Matrix with tolerence limit ?

조회 수: 2 (최근 30일)
RAJEEV 2023년 5월 2일
댓글: RAJEEV 2023년 5월 10일
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 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:
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
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
RAJEEV 2023년 5월 10일
Thank You.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by