Last change
on this file since 13 was
2,
checked in by sherbold, 10 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.2 KB
|
Line | |
---|
1 | package de.ugoe.cs.cpdp.training;
|
---|
2 |
|
---|
3 | import java.io.PrintStream;
|
---|
4 | import java.util.logging.Level;
|
---|
5 |
|
---|
6 | import org.apache.commons.io.output.NullOutputStream;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.util.console.Console;
|
---|
9 | import weka.core.Instances;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Programmatic WekaBaggingTraining
|
---|
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 | */
|
---|
29 | public 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.