[29] | 1 | /* |
---|
| 2 | * This program is free software; you can redistribute it and/or modify |
---|
| 3 | * it under the terms of the GNU General Public License as published by |
---|
| 4 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 5 | * (at your option) any later version. |
---|
| 6 | * |
---|
| 7 | * This program is distributed in the hope that it will be useful, |
---|
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 10 | * GNU General Public License for more details. |
---|
| 11 | * |
---|
| 12 | * You should have received a copy of the GNU General Public License |
---|
| 13 | * along with this program; if not, write to the Free Software |
---|
| 14 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | /* |
---|
| 18 | * Copyright (C) 2008 University of Waikato, Hamilton, New Zealand |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | package weka.classifiers.meta; |
---|
| 22 | |
---|
| 23 | import weka.classifiers.AbstractClassifierTest; |
---|
| 24 | import weka.classifiers.Classifier; |
---|
| 25 | |
---|
| 26 | import junit.framework.Test; |
---|
| 27 | import junit.framework.TestSuite; |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | * Tests OneClassClassifier. Run from the command line with:<p/> |
---|
| 31 | * java weka.classifiers.meta.OneClassClassifierTest |
---|
| 32 | * |
---|
| 33 | * @author FracPete (fracpete at waikato dot ac dot nz) |
---|
| 34 | * @version $Revision: 5795 $ |
---|
| 35 | */ |
---|
| 36 | public class OneClassClassifierTest |
---|
| 37 | extends AbstractClassifierTest { |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Initializes the test. |
---|
| 41 | * |
---|
| 42 | * @param name the name of the test |
---|
| 43 | */ |
---|
| 44 | public OneClassClassifierTest(String name) { |
---|
| 45 | super(name); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * Called by JUnit before each test method. This implementation creates |
---|
| 50 | * the default classifier to test and loads a test set of Instances. |
---|
| 51 | * |
---|
| 52 | * @exception Exception if an error occurs reading the example instances. |
---|
| 53 | */ |
---|
| 54 | protected void setUp() throws Exception { |
---|
| 55 | super.setUp(); |
---|
| 56 | |
---|
| 57 | m_Tester.setNumInstances(40); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * Creates a default OneClassClassifier. |
---|
| 62 | * |
---|
| 63 | * @return the default classifier |
---|
| 64 | */ |
---|
| 65 | public Classifier getClassifier() { |
---|
| 66 | OneClassClassifier result; |
---|
| 67 | |
---|
| 68 | result = new OneClassClassifier(); |
---|
| 69 | result.setTargetClassLabel("class1"); |
---|
| 70 | |
---|
| 71 | return result; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | * Returns a test suite. |
---|
| 76 | * |
---|
| 77 | * @return the test suite |
---|
| 78 | */ |
---|
| 79 | public static Test suite() { |
---|
| 80 | return new TestSuite(OneClassClassifierTest.class); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | /** |
---|
| 84 | * Runs the test from commandline. |
---|
| 85 | * |
---|
| 86 | * @param args ignored |
---|
| 87 | */ |
---|
| 88 | public static void main(String[] args){ |
---|
| 89 | junit.textui.TestRunner.run(suite()); |
---|
| 90 | } |
---|
| 91 | } |
---|