-
Notifications
You must be signed in to change notification settings - Fork 0
/
PRF_CT.m
59 lines (52 loc) · 1.85 KB
/
PRF_CT.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
clear all;
load('PR.mat');
load('F1.mat');
load('PR_F_KM16.mat');
Human_test=csvread('color/test/Human.csv');
%X_test=cat(2,BG,CG,TG);
Y_test_KM=csvread('output/Ctree.csv');
%%Calculate Precision Recall
H=Human_test;
H(H~=0)=1;H(H==0)=0;
i=1;
for c=0.05:0.01:0.95
Y_p_LR=Y_test_KM;
Y_p_LR(Y_p_LR>=c)=1;Y_p_LR(Y_p_LR<c)=0;
C = confusionmat(H,Y_p_LR);
pr_CT(i)=C(2,2)/(C(1,2)+C(2,2));
re_CT(i)=C(2,2)/(C(2,1)+C(2,2));
F_CT(i) = 2*pr_CT(i)*re_CT(i)/(pr_CT(i)+re_CT(i));
i=i+1;
end;
colormap jet;
cmap=colormap;
figure;plot(re_LR,pr_LR,'Color',cmap(1,:),'LineWidth',1);hold on;
plot(re_KM_16,pr_KM_16,'Color',cmap(64,:),'LineWidth',1);
plot(re_CT,pr_CT,'Color',cmap(14,:),'LineWidth',3);
plot(re_BG,pr_BG,'Color',cmap(20,:),'LineWidth',1);
plot(re_CG,pr_CG,'Color',cmap(26,:),'LineWidth',1);
plot(re_TG,pr_TG,'Color',cmap(32,:),'LineWidth',1);
plot(re_ca,pr_ca,'Color',cmap(38,:),'LineWidth',1);
plot(re_MM,pr_MM,'Color',cmap(44,:),'LineWidth',1);
plot(re_MM2,pr_MM2,'Color',cmap(50,:),'LineWidth',1);
grid on;
title('Precision recall curve')
xlabel('Recall','FontSize',18);
ylabel('Precision','FontSize',18);
legend('LR','KM16','CT','BG','CG','TG','Canny','2MM','2MM2');
save('PRF_CT.mat','re_CT','pr_CT','F_CT');
c=0.05:0.01:0.95;
figure;plot(c,F_LR,'Color',cmap(1,:),'LineWidth',1);hold on;
plot(c,F_KM_16,'Color',cmap(64,:),'LineWidth',2);
plot(c,F_CT,'Color',cmap(14,:),'LineWidth',3);
plot(c,F_BG,'Color',cmap(20,:),'LineWidth',1);
plot(c,F_CG,'Color',cmap(26,:),'LineWidth',1);
plot(c,F_TG,'Color',cmap(32,:),'LineWidth',1);
plot(c,F_ca,'Color',cmap(38,:),'LineWidth',1);
plot(c,F_MM,'Color',cmap(44,:),'LineWidth',1);
plot(c,F_MM2,'Color',cmap(50,:),'LineWidth',1);
grid on;
title('F-Measure')
xlabel('Threshold Value','FontSize',18);
ylabel('F-Measure','FontSize',18);
legend('LR','KM16','CT','BG','CG','TG','Canny','2MM','2MM2');