confusion_matrix.m

来自「调用过程 CM = Confusion_matrix(train_predict」· M 代码 · 共 24 行

M
24
字号
function CM = Confusion_matrix(train_predicts, train_targets)

% solve the confusion matrix of classifiers

% Inputs:
%   predicts    - the predicting class by single classifiers
%   targets     - the real class of each pattern 
% Outputs:
%   CM          -  confusion matrix
%
% Notice: available for only two classes

[nClassifiers, nPatterns] = size(train_predicts);
nClasses = max(train_targets) + 1;

CM = zeros(nClasses, nClasses, nClassifiers);

for i = 1: nClassifiers
    for j = 1: nPatterns
        CM(train_targets(j)+1, train_predicts(i,j)+1, i) = CM(train_targets(j) + 1, train_predicts(i,j) + 1, i) + 1;
    end
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?