1
1
package org .experiments ;
2
2
3
+ import org .apache .commons .math3 .stat .correlation .PearsonsCorrelation ;
3
4
import org .apache .lucene .search .TopDocs ;
4
5
import org .apache .lucene .search .similarities .LMDirichletSimilarity ;
5
6
import org .apache .lucene .search .similarities .Similarity ;
10
11
import org .qpp .NQCCalibratedSpecificity ;
11
12
import org .qpp .NQCSpecificity ;
12
13
import org .qpp .QPPMethod ;
14
+ import org .qpp .WIGSpecificity ;
13
15
import org .trec .TRECQuery ;
14
16
15
17
import java .util .HashMap ;
@@ -35,6 +37,7 @@ public static void main(String[] args) {
35
37
//NQCCalibratedSpecificity qppMethod = new NQCCalibratedSpecificity(loader.getSearcher());
36
38
//qppMethod.setParameters(2, 2, 0.5f);
37
39
NQCSpecificity qppMethod = new NQCSpecificity (Settings .getSearcher ());
40
+ //WIGSpecificity qppMethod = new WIGSpecificity(Settings.getSearcher());
38
41
Similarity sim = new LMDirichletSimilarity (1000 );
39
42
40
43
final int nwanted = Settings .getNumWanted ();
@@ -60,8 +63,25 @@ public static void main(String[] args) {
60
63
System .out .println (String .format ("%s: AP = %.4f, QPP = %.4f" , query .id , evaluatedMetricValues [i ], qppEstimates [i ]));
61
64
i ++;
62
65
}
63
- double corr = new KendalCorrelation ().correlation (evaluatedMetricValues , qppEstimates );
64
- System .out .println (String .format ("Kendall's = %.4f" , corr ));
66
+ double pearsons = new PearsonsCorrelation ().correlation (evaluatedMetricValues , qppEstimates );
67
+ double kendals = new KendalCorrelation ().correlation (evaluatedMetricValues , qppEstimates );
68
+
69
+ boolean ref , pred ;
70
+ int correct = 0 ;
71
+ int numpairs = 0 ;
72
+ for (int j =0 ; j < evaluatedMetricValues .length -1 ; j ++) {
73
+ for (int k =j +1 ; k < evaluatedMetricValues .length ; k ++) {
74
+ ref = evaluatedMetricValues [j ] < evaluatedMetricValues [k ];
75
+ pred = qppEstimates [j ] < qppEstimates [k ];
76
+ correct += ref && pred ? 1 : 0 ;
77
+ numpairs ++;
78
+ }
79
+ }
80
+ System .out .println (numpairs );
81
+ System .out .println (String .format ("acc = %.4f, r = %.4f, tau = %.4f" ,
82
+ correct /(float )(numpairs ),
83
+ pearsons , kendals ));
84
+
65
85
} catch (Exception ex ) {
66
86
ex .printStackTrace ();
67
87
}
0 commit comments