- Timestamp:
- 09/24/15 10:59:05 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/CVWekaEvaluation.java
r2 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.eval; 2 16 … … 12 26 /** 13 27 * Implements the {@link AbstractWekaEvaluation} for 10-fold cross validation. 28 * 14 29 * @author Steffen Herbold 15 30 */ 16 31 public class CVWekaEvaluation extends AbstractWekaEvaluation { 17 18 /** 19 * @see de.ugoe.cs.cpdp.eval.AbstractWekaEvaluation#createEvaluator(weka.core.Instances, weka.classifiers.Classifier) 20 */ 21 @Override 22 protected Evaluation createEvaluator(Instances testdata, Classifier classifier) { 23 PrintStream errStr = System.err; 24 System.setErr(new PrintStream(new NullOutputStream())); 25 try { 26 final Evaluation eval = new Evaluation(testdata); 27 eval.crossValidateModel(classifier, testdata, 10, new Random(1)); 28 return eval; 29 } catch (Exception e) { 30 throw new RuntimeException(e); 31 } finally { 32 System.setErr(errStr); 33 } 34 } 32 33 /** 34 * @see de.ugoe.cs.cpdp.eval.AbstractWekaEvaluation#createEvaluator(weka.core.Instances, 35 * weka.classifiers.Classifier) 36 */ 37 @Override 38 protected Evaluation createEvaluator(Instances testdata, Classifier classifier) { 39 PrintStream errStr = System.err; 40 System.setErr(new PrintStream(new NullOutputStream())); 41 try { 42 final Evaluation eval = new Evaluation(testdata); 43 eval.crossValidateModel(classifier, testdata, 10, new Random(1)); 44 return eval; 45 } 46 catch (Exception e) { 47 throw new RuntimeException(e); 48 } 49 finally { 50 System.setErr(errStr); 51 } 52 } 35 53 36 54 }
Note: See TracChangeset
for help on using the changeset viewer.