Advertisement

混淆矩阵在Matlab中的实现

阅读量:

【混淆矩阵的MATLAB代码实现方式如下:

actual代表的是已知的真实标签数据。

detected则是利用模型进行预测后所获得的标签结果。

可通过以下代码语句进行实现:

[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

全部评论 (0)

还没有任何评论哟~