source: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining.java @ 40

Last change on this file since 40 was 25, checked in by atrautsch, 10 years ago

comment fixes

  • Property svn:mime-type set to text/plain
File size: 1.3 KB
Line 
1package de.ugoe.cs.cpdp.training;
2
3import java.io.PrintStream;
4import java.util.logging.Level;
5
6import org.apache.commons.io.output.NullOutputStream;
7
8import de.ugoe.cs.util.console.Console;
9import weka.core.Instances;
10
11/**
12 * Programmatic WekaTraining
13 *
14 * first parameter is Trainer Name.
15 * second parameter is class name
16 *
17 * all subsequent parameters are configuration params (for example for trees)
18 * Cross Validation params always come last and are prepended with -CVPARAM
19 *
20 * XML Configurations for Weka Classifiers:
21 * <pre>
22 * {@code
23 * <!-- examples -->
24 * <trainer name="WekaTraining" param="NaiveBayes weka.classifiers.bayes.NaiveBayes" />
25 * <trainer name="WekaTraining" param="Logistic weka.classifiers.functions.Logistic -R 1.0E-8 -M -1" />
26 * }
27 * </pre>
28 *
29 */
30public class WekaTraining extends WekaBaseTraining implements ITrainingStrategy {
31
32        @Override
33        public void apply(Instances traindata) {
34                PrintStream errStr      = System.err;
35                System.setErr(new PrintStream(new NullOutputStream()));
36                try {
37                        if(classifier == null) {
38                                Console.traceln(Level.WARNING, String.format("classifier null!"));
39                        }
40                        classifier.buildClassifier(traindata);
41                } catch (Exception e) {
42                        throw new RuntimeException(e);
43                } finally {
44                        System.setErr(errStr);
45                }
46        }
47}
Note: See TracBrowser for help on using the repository browser.