⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 confusionmatrix.m

📁 ICA is used to classify text in extension to the latent semantic indexing framework. ICA show to ali
💻 M
字号:
function [cM,cMrel,nrInClasses]=confusionMatrix(Targets,Estimats)
% confusionMatrix.m     : Calculate the confusion matrix where cols are the target 
%                         classes and rows are the estimats.
%
%                         [cM,cMrel,nrInClasses]=confusionMatrix(Targets,Estimats)
%
%                         In:
%                         Targets  : Vector of target classes
%                         Estimats : Vector of estimatet classes
%
%                         Out:
%                         cM : confusion matrix.
%                         cMrel : confusion matrix that sum to 100 procent in the cols.
%                         nrInClasses : Vector with number of results for each class
%
% (29.4.99 TK)

nrClasses=max(Targets);
nrEstimats=max(Estimats);

%cM=zeros(nrClasses,nrClasses);
for tc=1:nrClasses,
  Tindex=find(Targets==tc);
  for ec=1:nrEstimats,
    Eindex=find(Estimats(Tindex)==ec);
    cM(ec,tc)=length(Eindex);
  end
end

% Cols sum to 100 procent
cMrel=cM*diag(1./(sum(cM)))*100;

% sort rows
%p = zeros(1,nrClasses);
%c=cM;
%for i=1:nrClasses
%  [coeff,p(i)] = max(c(i,:));
%  c(:,p(i))=zeros(nrClasses,1)-1;
%end

%cMrel = cMrel(:,p);
%cM = cM(:,p);

nrInClasses=sum(cM);

⌨️ 快捷键说明

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