-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSKAEvaluator.java
More file actions
88 lines (81 loc) · 2.68 KB
/
SKAEvaluator.java
File metadata and controls
88 lines (81 loc) · 2.68 KB
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
package cs475;
import java.util.List;
import java.util.HashMap;
public class SKAEvaluator extends Evaluator {
private double evaluatorValue = 0.0;
private String preName = "ska";
public double evaluate(List<Instance> instances, Predictor predictor){
// HashMap<Integer,Integer> countA = new HashMap<Integer, Integer>();
// HashMap<Integer,Integer> countB = new HashMap<Integer, Integer>();
// HashMap<Integer,HashMap<Integer,Integer>> countAB = new HashMap<Integer, HashMap<Integer,Integer>>();
// HashMap<Integer,Double> PA = new HashMap<Integer, Double>();
// HashMap<Integer,Double> PB = new HashMap<Integer, Double>();
// double ha = 0.0;
// double hb = 0.0;
// double mi = 0.0;
SKA ska = (SKA)predictor;
for(int i = 0; i< instances.size();i++){
// System.out.println("--------------------instance " + i);
Instance tmp = instances.get(i);
// ClassificationLabel reallabel = (ClassificationLabel)tmp.getLabel();
ClassificationLabel predictlabel = ska.predict(tmp);
// if(reallabel == null){
// return 0.0;
// }
// int a = reallabel.getLabelValue();
// int b = predictlabel.getLabelValue();
// if(!countA.containsKey(a)){
// countA.put(a, 0);
// }
// if(!countB.containsKey(b)){
// countB.put(b, 0);
// }
// HashMap<Integer,Integer> tmphash = new HashMap<Integer,Integer>();
// if(!countAB.containsKey(a)){
// countAB.put(a, tmphash);
// }
// if(!countAB.get(a).containsKey(b)){
// countAB.get(a).put(b, 0);
// }
// int countavalue = countA.get(a) + 1;
// countA.put(a,countavalue);
// int countbvalue = countB.get(b) + 1;
// countB.put(b,countbvalue);
// int countabvalue = countAB.get(a).get(b) + 1;
// countAB.get(a).put(b, countabvalue);
}
// out.close();
// for(Integer key : countA.keySet()){
// double tmp = ((double) countA.get(key))/instances.size();
// PA.put(key, tmp);
// if(tmp>0){
// ha = ha - tmp*Math.log(tmp);
// }
// }
//
// for(Integer key : countB.keySet()){
// double tmp = ((double) countB.get(key))/instances.size();
// PB.put(key, tmp);
// if(tmp>0){
// hb = hb - tmp*Math.log(tmp);
// }
// }
// for(Integer keya : countA.keySet()){
// for(Integer keyb: countB.keySet()){
// if(!countAB.get(keya).containsKey(keyb)){
// countAB.get(keya).put(keyb, 0);
// }
// double tmp = ((double)countAB.get(keya).get(keyb))/instances.size();
// if(tmp>0){
// mi = mi+ tmp*Math.log(tmp/PA.get(keya)*PB.get(keyb));
// }
// }
// }
// evaluatorValue = ha + hb - 2.0*mi;
// System.out.println(evaluatorValue);
return evaluatorValue;
}
public String getpreName(){
return this.preName;
}
}