Last change
on this file since 35 was
2,
checked in by sherbold, 10 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.0 KB
|
Line | |
---|
1 | package de.ugoe.cs.cpdp.eval;
|
---|
2 |
|
---|
3 | import java.io.PrintStream;
|
---|
4 | import java.util.Random;
|
---|
5 |
|
---|
6 | import org.apache.commons.io.output.NullOutputStream;
|
---|
7 |
|
---|
8 | import weka.classifiers.Classifier;
|
---|
9 | import weka.classifiers.Evaluation;
|
---|
10 | import weka.core.Instances;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Implements the {@link AbstractWekaEvaluation} for 10-fold cross validation.
|
---|
14 | * @author Steffen Herbold
|
---|
15 | */
|
---|
16 | public class CVWekaEvaluation extends AbstractWekaEvaluation {
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * @see de.ugoe.cs.cpdp.eval.AbstractWekaEvaluation#createEvaluator(weka.core.Instances, weka.classifiers.Classifier)
|
---|
20 | */
|
---|
21 | @Override
|
---|
22 | protected Evaluation createEvaluator(Instances testdata, Classifier classifier) {
|
---|
23 | PrintStream errStr = System.err;
|
---|
24 | System.setErr(new PrintStream(new NullOutputStream()));
|
---|
25 | try {
|
---|
26 | final Evaluation eval = new Evaluation(testdata);
|
---|
27 | eval.crossValidateModel(classifier, testdata, 10, new Random(1));
|
---|
28 | return eval;
|
---|
29 | } catch (Exception e) {
|
---|
30 | throw new RuntimeException(e);
|
---|
31 | } finally {
|
---|
32 | System.setErr(errStr);
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.