source: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining2.java @ 20

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

Mehr kommentiert.

  • Property svn:mime-type set to text/plain
File size: 1.2 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 *
19 * XML Configurations for Weka Classifiers:
20 * <pre>
21 * {@code
22 * <!-- examples -->
23 * <trainer name="WekaTraining2" param="NaiveBayes weka.classifiers.bayes.NaiveBayes" />
24 * <trainer name="WekaTraining2" param="Logistic weka.classifiers.functions.Logistic -R 1.0E-8 -M -1" />
25 * }
26 * </pre>
27 *
28 */
29public class WekaTraining2 extends WekaBaseTraining2 implements ITrainingStrategy {
30
31        @Override
32        public void apply(Instances traindata) {
33                PrintStream errStr      = System.err;
34                System.setErr(new PrintStream(new NullOutputStream()));
35                try {
36                        if(classifier == null) {
37                                Console.traceln(Level.WARNING, String.format("classifier null!"));
38                        }
39                        classifier.buildClassifier(traindata);
40                } catch (Exception e) {
41                        throw new RuntimeException(e);
42                } finally {
43                        System.setErr(errStr);
44                }
45        }
46}
Note: See TracBrowser for help on using the repository browser.