source: trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/CVWekaEvaluation.java @ 10

Last change on this file since 10 was 2, checked in by sherbold, 10 years ago
  • initial commit
  • Property svn:mime-type set to text/plain
File size: 1.0 KB
Line 
1package de.ugoe.cs.cpdp.eval;
2
3import java.io.PrintStream;
4import java.util.Random;
5
6import org.apache.commons.io.output.NullOutputStream;
7
8import weka.classifiers.Classifier;
9import weka.classifiers.Evaluation;
10import weka.core.Instances;
11
12/**
13 * Implements the {@link AbstractWekaEvaluation} for 10-fold cross validation.
14 * @author Steffen Herbold
15 */
16public 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.