- Timestamp:
- 09/24/15 10:59:05 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining.java
r25 r41 1 // Copyright 2015 Georg-August-Universität Göttingen, Germany 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 1 15 package de.ugoe.cs.cpdp.training; 2 16 … … 11 25 /** 12 26 * Programmatic WekaTraining 13 *14 * first parameter is Trainer Name.15 * second parameter is class name16 27 * 17 * all subsequent parameters are configuration params (for example for trees) 18 * Cross Validation params always come last and are prepended with -CVPARAM 28 * first parameter is Trainer Name. second parameter is class name 29 * 30 * all subsequent parameters are configuration params (for example for trees) Cross Validation 31 * params always come last and are prepended with -CVPARAM 19 32 * 20 33 * XML Configurations for Weka Classifiers: 34 * 21 35 * <pre> 22 36 * {@code … … 30 44 public class WekaTraining extends WekaBaseTraining implements ITrainingStrategy { 31 45 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 } 46 @Override 47 public void apply(Instances traindata) { 48 PrintStream errStr = System.err; 49 System.setErr(new PrintStream(new NullOutputStream())); 50 try { 51 if (classifier == null) { 52 Console.traceln(Level.WARNING, String.format("classifier null!")); 53 } 54 classifier.buildClassifier(traindata); 55 } 56 catch (Exception e) { 57 throw new RuntimeException(e); 58 } 59 finally { 60 System.setErr(errStr); 61 } 62 } 47 63 }
Note: See TracChangeset
for help on using the changeset viewer.