📄 sampletest.java
字号:
/*
* YALE - Yet Another Learning Environment
* Copyright (C) 2001-2004
* Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,
* Katharina Morik, Oliver Ritthoff
* Artificial Intelligence Unit
* Computer Science Department
* University of Dortmund
* 44221 Dortmund, Germany
* email: yale-team@lists.sourceforge.net
* web: http://yale.cs.uni-dortmund.de/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
package edu.udo.cs.yale.test;
import edu.udo.cs.yale.Yale;
import edu.udo.cs.yale.operator.IOContainer;
import edu.udo.cs.yale.operator.MissingIOObjectException;
import edu.udo.cs.yale.tools.LogService;
import edu.udo.cs.yale.tools.ParameterService;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
/** Extends the JUnit test case by a method for checking the output of an experiment.
*
* @version $Id: SampleTest.java,v 2.18 2004/09/12 11:09:52 ingomierswa Exp $
*/
public abstract class SampleTest extends TestCase {
private String file;
public SampleTest(String file) {
super("sampleTest");
this.file = file;
}
public String getName() {
return "Sample '"+file+"'";
}
public void setUp() throws Exception {
super.setUp();
LogService.setVerbosityLevel(LogService.WARNING);
Yale.init();
LogService.setVerbosityLevel(LogService.WARNING);
}
public void sampleTest() throws Exception {
File experimentFile = new File(ParameterService.getYaleHome(), "sample"+File.separator+file);
Yale.readExperimentFile(experimentFile);
LogService.init(Yale.getExperiment());
LogService.setVerbosityLevel(LogService.WARNING);
Yale.getExperiment().prepareRun();
IOContainer output = Yale.getExperiment().run();
checkOutput(output);
}
public abstract void checkOutput(IOContainer output) throws MissingIOObjectException;
public static Test suite() {
TestSuite suite = new TestSuite("Sample test");
suite.addTest(new SimpleSampleTest("Empty.xml"));
suite.addTest(new ExampleSetSampleTest("Input.xml", 14, 4));
suite.addTest(new ExampleSetSampleTest("ArffTest.xml", 150, 4));
suite.addTest(new IOObjectSampleTest("C45ExampleSource.xml", new Class[] { edu.udo.cs.yale.operator.learner.Model.class }));
suite.addTest(new ExampleSetSampleTest("Sparse.xml", 4, 30));
suite.addTest(new IOObjectSampleTest("DecisionTree.xml", new Class[] { edu.udo.cs.yale.operator.learner.Model.class }));
suite.addTest(new PerformanceSampleTest("Weka.xml",
new String[] { "accuracy", "precision", "recall" },
new double[] { 0.642857, 0.700000, 0.777778 }));
suite.addTest(new IOObjectSampleTest("Bagging.xml", new Class[] { edu.udo.cs.yale.operator.learner.Model.class }));
suite.addTest(new IOObjectSampleTest("WekaMetaLearning.xml", new Class[] { edu.udo.cs.yale.operator.learner.Model.class }));
suite.addTest(new IOObjectSampleTest("ModelWriter.xml", new Class[] { edu.udo.cs.yale.operator.learner.Model.class }));
suite.addTest(new ExampleSetSampleTest("ModelLoader.xml", 14, 4,
new String[] { edu.udo.cs.yale.example.ExampleSet.PREDICTION_NAME }));
suite.addTest(new PerformanceSampleTest("XValidation.xml",
new String[] { "absolute", "scaled", "squared", "relative" },
new double[] { 5.155480, 0.008305, 51.974253, 0.3653 }));
suite.addTest(new PerformanceSampleTest("MultiClass.xml",
new String[] { "accuracy", "classification_error" },
new double[] { 0.755555555, 0.244444444 }));
suite.addTest(new PerformanceSampleTest("EnsembleLearning.xml",
new String[] { "absolute", "scaled" },
new double[] { 22.321238, 0.012639 }));
suite.addTest(new SimpleSampleTest("LearningCurve.xml"));
suite.addTest(new ExampleSetSampleTest("MissingValueReplenishment.xml", 40, 16));
suite.addTest(new ExampleSetSampleTest("Noise.xml", 200, 8));
suite.addTest(new PerformanceSampleTest("ForwardSelection.xml",
new String[] { "relative" },
new double[] { 0.39618193 }));
suite.addTest(new ExampleSetSampleTest("FeatureGeneration.xml", 200, 8));
suite.addTest(new PerformanceSampleTest("FeatureWeighting.xml",
new String[] { "accuracy", "precision", "recall" },
new double[] { 0.910000, 0.91416309, 0.894957 }));
suite.addTest(new PerformanceSampleTest("YAGGA.xml",
new String[] { "relative" },
new double[] { 0.386400 }));
suite.addTest(new ExampleSetSampleTest("YAGGAResultAttributeSetting.xml", 200, 8));
suite.addTest(new ExampleSetSampleTest("PrincipalComponents.xml", 150, 2));
suite.addTest(new ExampleSetSampleTest("Obfuscation.xml", 14, 4));
suite.addTest(new IOObjectSampleTest("WekaAttributeWeighting.xml",
new Class[] {
edu.udo.cs.yale.example.ExampleSet.class,
edu.udo.cs.yale.example.AttributeWeights.class
}));
suite.addTest(new PerformanceSampleTest("ParameterOptimization.xml",
new String[] { "absolute", "scaled", "squared" },
new double[] { 8.377710, 0.016019, 169.584314 }));
suite.addTest(new SimpleSampleTest("ParameterSetter.xml"));
return suite;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -