dispconf.m
来自「一个关于数据聚类和模式识别的程序,在生物化学,化学中因该都可以用到.希望对大家有」· M 代码 · 共 46 行
M
46 行
function confusion = dispconf(computed, desired, string)
%DISPCONF Display (and return) the confusion count matrix
% CONFUSION = DISPCONF(COMPUTED, ACTUAL, STRING)
% CONFUSION: confusion count matrix
% COMPUTED: computed label
% ACTUAL: actual label
% STRING: string to be displayed below the confusion plot
% Roger Jang, June-28-1997
if nargin < 3, string = ''; end
computed = computed(:);
desired = desired(:);
classLabel = countele(desired);
classNum = length(classLabel);
% compute the confusion count matrix
confusion = zeros(classNum);
for i = 1:classNum,
for j = 1:classNum,
confusion(i,j) = sum((desired==classLabel(i)).* ...
(computed==classLabel(j)));
end
end
colordef black;
figure('name', 'Confusion plots', 'numberTitle', 'off');
subplot(2,2,1);
pltmat(confusion, 'Confusion matrix', 'c', 10);
prob = confusion./(sum(confusion')'*ones(1, size(confusion,1)));
overall = sum(diag(confusion))/sum(sum(confusion));
new_prob = fix(prob*1000)/10;
new_overall = fix(overall*1000)/10;
subplot(2,2,2);
pltmat(new_prob, ['Overall recognition rate = ', num2str(new_overall), '%'], 'c', 9);
% Add the percentage sign
textH = findobj(gca, 'type', 'text');
for i=1:length(textH),
str = get(textH(i), 'string');
set(textH(i), 'string', [str, '%']);
end
xlabel(string)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?