混淆矩阵的matlab代码实现:
actual:就是我们已知的label。
detected是我们通过模型预测得到的label
结合下面语句实现:
[pred,acc,preb] = svmpredict(double(testLabel), testData, model, '-b 1');
function confusion_matrix(actual,detected)
[mat,order] = confusionmat(actual,detected);
%mat = rand(10); %# A 5-by-5 matrix of random values from 0 to 1
% mat(3,3) = 0; %# To illustrate
% mat(5,2) = 0; %# To illustrate
imagesc(mat); %# Create a colored plot of the matrix values
colormap(flipud(gray)); %# Change the colormap to gray (so higher values are
%# black and lower values are white)
textStrings = num2str(mat(:),'%0.02f'); %# Create stri