-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvaluator.java
More file actions
33 lines (31 loc) · 806 Bytes
/
Copy pathEvaluator.java
File metadata and controls
33 lines (31 loc) · 806 Bytes
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
public class Evaluator {
Classifier classifier;
TrainTestSets tts;
Evaluator(Classifier c, TrainTestSets tts)
{
this.classifier = c;
this.tts = tts;
}
Performance holdOut() throws Exception
{
classifier.train(tts.train);
Performance p = classifier.classify(tts.test);
System.out.println("Accuracy: "+p.getStringAccuracy());
return p;
}
Performance kFold(int k) throws Exception
{
Performance all = new Performance(k);
for(int i=0;i<k;i++)
{
TrainTestSets temp = tts.train.getCVSets(i,k);
classifier.train(temp.train);
//System.out.println(temp.test.examples);
Performance p = classifier.classify(temp.test);
all.addAccuracy(p.getDoubleAccuracy());
}
System.out.println("Accuracy: "+all.getStringMeanAccuracy());
System.out.println("Variance: "+all.getVariace());
return all;
}
}