-
Notifications
You must be signed in to change notification settings - Fork 34
/
run_plot_curves.m
141 lines (107 loc) · 5.39 KB
/
run_plot_curves.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
% ----------------------------------------------------------------------- %
%
% Plot curves
% Created by T. Zhou
% E-mail: [email protected]
%
% ----------------------------------------------------------------------- %
clc;clear;close all;
disp('***************** ---------------------------------------------------')
disp('Note that the mean evaluation results of each dataset are saved in <per_metric.mat> ')
disp('***************** ---------------------------------------------------')
plotDrawStyle24={ struct('color',[1,0,0],'lineStyle','-'),...
struct('color',[0,1,0],'lineStyle','-'),...
struct('color',[0,0,1],'lineStyle','-'),...
struct('color',[0,0,0],'lineStyle','-'),...% struct('color',[1,1,0],'lineStyle','-'),...%yellow
struct('color',[1,0,1],'lineStyle','-'),...%pink
struct('color',[1,1,0],'lineStyle','-'),...%
struct('color',[0,1,1],'lineStyle','-'),...
struct('color',[0.5,0.5,0.5],'lineStyle','-'),...%gray-25%
struct('color',[136,0,21]/255,'lineStyle','-'),...%dark red
struct('color',[255,127,39]/255,'lineStyle','-'),...%orange
struct('color',[0,162,232]/255,'lineStyle','-'),...%Turquoise
struct('color',[163,73,164]/255,'lineStyle','-'),...%purple %%%%%%%%%%%%%%%%%%%%
struct('color',[1,0,0],'lineStyle','-.'),...
struct('color',[0,1,0],'lineStyle','-.'),...
struct('color',[0,0,1],'lineStyle','-.'),...
struct('color',[0,0,0],'lineStyle','-.'),...% struct('color',[1,1,0],'lineStyle',':'),...%yellow
struct('color',[1,0,1],'lineStyle','-.'),...%pink
struct('color',[1,1,0],'lineStyle','-.'),...%
struct('color',[0,1,1],'lineStyle','-.'),...
struct('color',[0.5,0.5,0.5],'lineStyle','-.'),...%gray-25%
struct('color',[136,0,21]/255,'lineStyle','-.'),...%dark red
struct('color',[255,127,39]/255,'lineStyle','-.'),...%orange
struct('color',[0,162,232]/255,'lineStyle','-.'),...%Turquoise
struct('color',[163,73,164]/255,'lineStyle','-.'),...%purple
};
% ----------------------------------------------------------------------- %
metric_path = 'results/Sal_Det_Results_24_Models/';
methods = {'LHM','ACSD','DESM','GP','LBE','DCMC','SE','CDCP','CDB','DF','PCF','CTMF','CPFP','TANet','AFNet','MMCI','DMRA','D3Net','SSF','A2dele','S2MA','ICNet','JL-DCF','UCNet'};
data_title = {'STERE', 'GIT', 'DES', 'NLPR', 'LFSD', 'NJUD', 'SSD', 'SIP'};
% -------------------------------------- %
zeros_tem = zeros(1,256);
for ind_data = 1:length(data_title)
plotMetrics_Recall = [];
plotMetrics_Pre = [];
Fmeasure_Curve = [];
% ------------------------------------------------------------------- %
for ind_model = 1:length(methods)
cur_model = methods{ind_model};
disp(['process:' cur_model]);
% --------------------------------------------------------------- %
cur_data = data_title{ind_data};
cur_metric_path = [metric_path,cur_model,'/'];
if exist([cur_metric_path,cur_data,'_metrics.mat']) == 0
plotMetrics_Recall = [plotMetrics_Recall; zeros_tem];
plotMetrics_Pre = [plotMetrics_Pre; zeros_tem];
Fmeasure_Curve = [Fmeasure_Curve; zeros_tem];
else
load([cur_metric_path,cur_data,'_metrics.mat']);
plotMetrics_Recall = [plotMetrics_Recall; per_metric.Recall];
plotMetrics_Pre = [plotMetrics_Pre; per_metric.Pre];
Fmeasure_Curve = [Fmeasure_Curve;per_metric.Fmeasure_Curve];
end
end
% ------------------------------------------------------------------- %
% **************** plot the PR curves ******************************* %
% ------------------------------------------------------------------- %
figure(ind_data*2-1);
hold on;
grid on;
axis([0 1 0 1]);
set(gca,'FontSize',16);
xlabel('Recall','fontsize',24); ylabel('Precision','fontsize',24);
width = 4;
for i = 1:size(plotMetrics_Pre,1)
if plotMetrics_Recall(i,1) == 0
continue;
end
h1(i)=plot(plotMetrics_Recall(i,:), plotMetrics_Pre(i,:), 'color',plotDrawStyle24{25-i}.color, 'lineStyle', plotDrawStyle24{25-i}.lineStyle,'lineWidth', width);
end
title(cur_data)
set(gca,'linewidth',2);
% ------------------------------------------------------------------- %
% **************** plot the Fmeasure curves ************************* %
% ------------------------------------------------------------------- %
figure(ind_data*2);
hold on;
grid on;
axis([0 255 0 1]);
set(gca,'FontSize',16);
xlabel('Threshold','fontsize',24);
ylabel('F-measure','fontsize',24);
x = [255:-1:0]';
width = 4;
for i = 1:size(Fmeasure_Curve,1)
if Fmeasure_Curve(i,1) == 0
continue;
end
h2(i)=plot(x, Fmeasure_Curve(i,:), 'color',plotDrawStyle24{25-i}.color, 'lineStyle', plotDrawStyle24{25-i}.lineStyle,'lineWidth', width);
end
title(cur_data)
set(gca,'linewidth',2);
% -------------------------------------- legend
% lgd1 = legend(h2(1:12),{'LHM','ACSD','DESM','GP','LBE','DCMC','SE','CDCP','CDB','DF','PCF','CTMF'});
% ah = axes('position',get(gca,'position'),'visible','off');
% lgd2 = legend(ah,h2(13:24),{'CPFP','TANet','AFNet','MMCI','DMRA','D3Net','SSF','A2dele','S2MA','ICNet','JL-DCF','UCNet'},'location','west');
end