MATLAB中的混淆矩阵的实现
来源:互联网 发布:美国黑人政治正确知乎 编辑:程序博客网 时间:2024/06/07 10:07
混淆矩阵的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 illustrateimagesc(mat); %# Create a colored plot of the matrix valuescolormap(flipud(gray)); %# Change the colormap to gray (so higher values are %# black and lower values are white)textStrings = num2str(mat(:),'%0.02f'); %# Create strings from the matrix valuestextStrings = strtrim(cellstr(textStrings)); %# Remove any space padding%% ## New code: ###%idx = find(strcmp(textStrings(:), '0.00'));%textStrings(idx) = {' '};%% ################[x,y] = meshgrid(1:5); %# Create x and y coordinates for the stringshStrings = text(x(:),y(:),textStrings(:),... %# Plot the strings 'HorizontalAlignment','center');midValue = mean(get(gca,'CLim')); %# Get the middle value of the color rangetextColors = repmat(mat(:) > midValue,1,3); %# Choose white or black for the %# text color of the strings so %# they can be easily seen over %# the background colorset(hStrings,{'Color'},num2cell(textColors,2)); %# Change the text colorsset(gca,'XTick',1:5,... %# Change the axes tick marks 'XTickLabel',{'Bob','Hyt','Maple','Study','Zm'},... %# and tick labels 'YTick',1:5,... 'YTickLabel',{'Bob','Hyt','Maple','Study','Zm'},... 'TickLength',[0 0]);
0 0
- MATLAB中的混淆矩阵的实现
- 混淆矩阵的MATLAB实现
- 混淆矩阵 Using Matlab
- Matlab画混淆矩阵
- 【混淆矩阵】matlab画混淆矩阵
- MATLAB中的矩阵的操作
- weka中的混淆矩阵
- 分类器评价与在R中的实现:混淆矩阵
- 分类器评价与在R中的实现:混淆矩阵
- 影像分类中的混淆矩阵
- 常见测量矩阵的MATLAB实现
- 常见测量矩阵的MATLAB实现
- 2.matlab实现矩阵的基本运算
- matlab中的矩阵
- matlab中的矩阵
- matlab中的矩阵操作
- Matlab中的矩阵
- matlab中的矩阵用法
- 欢迎使用CSDN-markdown编辑器
- 笔记:返回值根据返回参数代码判断对应中文意思
- java 中 ==和equals 的区别
- 基于maven的spring+mybatis+springMVC框架搭建
- jsonp解决跨域请求问题
- MATLAB中的混淆矩阵的实现
- 陈独秀的秀才造反和他们的流氓革命
- 关于加载图片造成oom问题
- 内核对象 互斥体 CreateMutex 跨进程边界共享内核对象 命名对象 程序单实例
- 签名boot.img及system.img和verity_key的生成
- angular中ng-include失效的原因
- ECOS事务处理实例
- HDU 1506 Largest Rectangle in a Histogram
- Android-基础-content provider