【轉】混淆矩陣和ROC曲線
阿新 • • 發佈:2020-07-08
1.https://www.baidu.com/link?url=LvM7AdalbXSaDUmsELY0gPTErLvNbvAxlMpRJN0D3AX_xaIVv6sLI4M_3yVUx060NQQzYm-2d7t0s2bGEde1j1rgTr8OSpIikrTY8t42ZYe&wd=&eqid=9b791b9f00018c2d000000065f0295f8
2.https://zhuanlan.zhihu.com/p/101315247
clc; clear; close all;
fuse_matrix=rand(5)#產生矩陣
imagesc(fuse_matrix)
set(gca,'xtick',1:5)
set(gca,'xticklabel',{'one ','two','three','four','five'},'XTickLabelRotation',45)#設定橫軸和橫軸標籤大小
set(gca,'ytick',1:5)
set(gca,'yticklabel',{'one','two','three','four','five'})#設定縱軸
set(gca,'FontSize',14,'Fontname', 'Times New Roman');#設定座標系的數字大小 colorbar#產生colorbar
ROC曲線
clc; clear; close all; FPR = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.050,0.15,0.15,0.15,0.20,0.20,0.20,0.20,0.20,0.20,0.20,0.25,0.25,0.30,0.35,0.40,0.45,0.45,0.55,0.60,0.65,0.65,0.70,0.70,0.70,0.70,0.70,0.70,0.75,0.75,0.80,0.85,0.90,0.90,0.90,0.95,0.95,0.95,1]; TPR = [0,0,0.050,0.050,0.050,0.050,0.10,0.15,0.15,0.15,0.15,0.15,0.15,0.20,0.25,0.30,0.35,0.35,0.40,0.45,0.45,0.50,0.55,0.60,0.60,0.60,0.60,0.60,0.60,0.65,0.70,0.80,0.85,0.85,0.85,0.95,0.95,0.95,0.95,0.95,0.95,0.95,0.95,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; acurve=trapz(FPR,TPR);%計算AUC x_dig=0:0.01:1; y_dig=x_dig; color1=[0.9300 0.4700 0.5000];%紅色 color2=[86 180 232]./255; color3=[229 159 1]./255; color4=[107,105,102]./255; h=figure; set(h,'units','normalized','position',[0.1 0.1 0.48 0.8]);%設定繪圖視窗的大小 set(h,'color','w');%設定繪圖視窗的背景為白色 h1=plot(FPR, TPR,'Color',color2,'LineWidth',3,'MarkerSize',3);hold on; plot(x_dig,y_dig,'--','Color',color4,'LineWidth',1.5);%畫中間的虛線 xlabel('False Positive Ratio (1-specificity)','fontsize',2,'FontWeight','bold');%x軸 ylabel('True Positive Ratio (Sensitivity)','fontsize',2,'FontWeight','bold');%y軸 set(gca,'YLim',[0,1.02]); set(gca,'XLim',[-0.01,1.01]); set(gca,'FontSize',24,'LineWidth',1.6) set(get(gca,'YLabel'),'FontSize',24); set(get(gca,'XLabel'),'FontSize',24); set(gca,'YTick',[0:0.2:1]) grid on ROCtitle_1=['AI AUC = ',num2str(roundn(acurve,-3))]; hh=legend([h1],ROCtitle_1)%,'Location','southeast'); set(hh,'edgecolor','white')