-
Notifications
You must be signed in to change notification settings - Fork 1
/
Metrics_performance.m
161 lines (127 loc) · 5.03 KB
/
Metrics_performance.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
function [results] = Metrics_performance(objScoDif, signif, doPlot)
% INPUT: objScoDif : differences of objective scores [M,N]
% M : number of metrics
% N : number of pairs
% signif : statistical outcome of paired comparison [1,N]
% 0 : no difference
% -1 : first stimulus is worse
% 1 : first stimulus is better
% doPlot : boolean indicating if graphs should be plotted
%
% OUTPUT: results - structure with following fields
%
% AUC_DS : Area Under the Curve for Different/Similar ROC
% analysis
% pDS_DL : p-values for AUC_DS from DeLong test
% pDS_HM : p-values for AUC_DS from Hanley and McNeil test
% AUC_BW : Area Under the Curve for Better/Worse ROC
% analysis
% pBW_DL : p-values for AUC_BW from DeLong test
% pBW_HM : p-values for AUC_BW from Hanley and McNeil test
% CC_0 : Correct Classification @ DeltaOM = 0 for
% Better/Worse ROC analysis
% pCC0_b : p-values for CC_0 from binomial test
% pCC0_F : p-values for CC_0 from Fisher's exact test
% THR : threshold for 95% probability that the stimuli
% are different
%
% REFERENCES
%
% The method is described in the paper:
% L. Krasula, K. Fliegel, P. Le Callet, M.Klima, "On the accuracy of
% objective image and video quality models: New methodology for
% performance evaluation", QoMEX 2016.
%
% When you use our method in your research, please, cite the above stated
% paper.
%
% Copyright (c) 2016
% Lukas Krasula <l.krasula@gmail.com>
% Permission to use, copy, modify, and/or distribute this software for any
% purpose with or without fee is hereby granted, provided that the above
% copyright notice and this permission notice appear in all copies.
%
% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
%
% This sotware also uses the code described in:
% X. Sun and W. Xu, "Fast Implementation of DeLong's Algorithm for
% Comparing the Areas Under Correlated Receiver Operating Characteristic
% Curves," IEEE Signal Processing Letters, vol. 21, no. 11, pp. 1389-1393,
% 2014.
%
% and
%
% P. Hanhart, L. Krasula, P. Le Callet, T. Ebrahimi, "How to benchmark
% objective quality metrics from pair comparison data", QoMEX 2016.
addpath('util');
M = size(objScoDif,1);
D = abs(objScoDif(:,signif ~= 0));
S = abs(objScoDif(:,signif == 0));
samples.spsizes = [size(D,2),size(S,2)];
samples.ratings = [D,S];
% calculate AUCs
[AUC_DS,C] = fastDeLong(samples);
% significance calculation
pDS_DL = ones(M);
for i=1:M-1
for j=i+1:M
pDS_DL(i,j) = calpvalue(AUC_DS([i,j]), C([i,j],[i,j]));
pDS_DL(j,i) = pDS_DL(i,j);
end
end
[pDS_HM,CI_DS] = significanceHM(S, D, AUC_DS);
THR = prctile(S',95);
%%%%%%%%%%%%%%%%%%%%%%% Better / Worse %%%%%%%%%%%%%%%%%%%%%%%%%%%
B = [objScoDif(:,signif == 1),-objScoDif(:,signif == -1)];
W = -B;
samples.ratings = [B,W];
samples.spsizes = [size(B,2),size(W,2)];
% calculate AUCs
[AUC_BW,C] = fastDeLong(samples);
% calculate correct classification for DeltaOM = 0
L = size(B,2) + size(W,2);
CC_0 = zeros(M,1);
for m=1:M
CC_0(m) = (sum(B(m,:)>0) + sum(W(m,:)<0)) / L;
end
% significance calculation
pBW_DL = ones(M);
pCC0_b = ones(M);
pCC0_F = ones(M);
for i=1:M-1
for j=i+1:M
pBW_DL(i,j) = calpvalue(AUC_BW([i,j]), C([i,j],[i,j]));
pBW_DL(j,i) = pBW_DL(i,j);
pCC0_b(i,j) = significanceBinomial(CC_0(i), CC_0(j), L);
pCC0_b(j,i) = pCC0_b(i,j);
pCC0_F(i,j) = fexact(CC_0(i)*L, 2*L, CC_0(i)*L + CC_0(j)*L, L, 'tail', 'b')/2;
pCC0_F(j,i) = pCC0_F(i,j);
end
end
[pBW_HM,CI_BW] = significanceHM(B, W, AUC_BW);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adding outputs to the structure
results.AUC_DS = AUC_DS;
results.pDS_DL = pDS_DL;
results.pDS_HM = pDS_HM;
results.AUC_BW = AUC_BW;
results.pBW_DL = pBW_DL;
results.pBW_HM = pBW_HM;
results.CC_0 = CC_0;
results.pCC0_b = pCC0_b;
results.pCC0_F = pCC0_F;
results.THR = THR;
%%%%%%%%%%%%%%%%%%%%%%%% Plot Results %%%%%%%%%%%%%%%%%%%%%%%%%%%
if(doPlot == 1)
% Using Benjamini-Hochberg procedure for multiple comparisons in plots
% (note: correlation between groups has to be positive)
plot_auc(results.pDS_HM,results.AUC_DS, CI_DS, 'AUC (-)','Different/Similar')
plot_cc(results.pCC0_F,results.CC_0,'C_0 (%)','Better/Worse')
plot_auc(results.pBW_HM,results.AUC_BW, CI_BW, 'AUC (-)','Better/Worse')
end