Ignore:
Timestamp:
09/24/15 10:59:05 (9 years ago)
Author:
sherbold
Message:
  • formatted code and added copyrights
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 
    115package de.ugoe.cs.cpdp.training; 
    216 
     
    1125/** 
    1226 * Programmatic WekaTraining 
    13  * 
    14  * first parameter is Trainer Name. 
    15  * second parameter is class name 
    1627 *  
    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 
    1932 *  
    2033 * XML Configurations for Weka Classifiers: 
     34 *  
    2135 * <pre> 
    2236 * {@code 
     
    3044public class WekaTraining extends WekaBaseTraining implements ITrainingStrategy { 
    3145 
    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    } 
    4763} 
Note: See TracChangeset for help on using the changeset viewer.