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) 2006 University of Waikato, Hamilton, New Zealand |
---|
19 | */ |
---|
20 | |
---|
21 | package weka.classifiers.functions; |
---|
22 | |
---|
23 | import weka.classifiers.AbstractClassifierTest; |
---|
24 | import weka.classifiers.CheckClassifier; |
---|
25 | import weka.classifiers.Classifier; |
---|
26 | import weka.core.SelectedTag; |
---|
27 | import weka.filters.supervised.attribute.PLSFilter; |
---|
28 | |
---|
29 | import junit.framework.Test; |
---|
30 | import junit.framework.TestSuite; |
---|
31 | |
---|
32 | /** |
---|
33 | * Tests PLSClassifier. Run from the command line with:<p/> |
---|
34 | * java weka.classifiers.functions.PLSClassifierTest |
---|
35 | * |
---|
36 | * @author FracPete (fracpete at waikato dot ac dot nz) |
---|
37 | * @version $Revision: 1.2 $ |
---|
38 | */ |
---|
39 | public class PLSClassifierTest |
---|
40 | extends AbstractClassifierTest { |
---|
41 | |
---|
42 | /** the number of PLS components to generate */ |
---|
43 | public final static int NUM_COMPONENTS = 5; |
---|
44 | |
---|
45 | public PLSClassifierTest(String name) { |
---|
46 | super(name); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * configures the CheckClassifier instance used throughout the tests |
---|
51 | * |
---|
52 | * @return the fully configured CheckClassifier instance used for testing |
---|
53 | */ |
---|
54 | protected CheckClassifier getTester() { |
---|
55 | CheckClassifier result; |
---|
56 | |
---|
57 | result = super.getTester(); |
---|
58 | result.setNumNominal(NUM_COMPONENTS * 2); |
---|
59 | result.setNumNumeric(NUM_COMPONENTS * 2); |
---|
60 | result.setNumString(NUM_COMPONENTS * 2); |
---|
61 | result.setNumDate(NUM_COMPONENTS * 2); |
---|
62 | result.setNumRelational(NUM_COMPONENTS * 2); |
---|
63 | |
---|
64 | return result; |
---|
65 | } |
---|
66 | |
---|
67 | /** Creates a default PLSClassifier */ |
---|
68 | public Classifier getClassifier() { |
---|
69 | PLSClassifier classifier = new PLSClassifier(); |
---|
70 | |
---|
71 | PLSFilter filter = new PLSFilter(); |
---|
72 | filter.setReplaceMissing(true); |
---|
73 | filter.setPreprocessing(new SelectedTag(PLSFilter.PREPROCESSING_CENTER, PLSFilter.TAGS_PREPROCESSING)); |
---|
74 | filter.setNumComponents(NUM_COMPONENTS); |
---|
75 | filter.setAlgorithm(new SelectedTag(PLSFilter.ALGORITHM_SIMPLS, PLSFilter.TAGS_ALGORITHM)); |
---|
76 | try { |
---|
77 | classifier.setFilter(filter); |
---|
78 | } |
---|
79 | catch (Exception e) { |
---|
80 | e.printStackTrace(); |
---|
81 | } |
---|
82 | |
---|
83 | return classifier; |
---|
84 | } |
---|
85 | |
---|
86 | public static Test suite() { |
---|
87 | return new TestSuite(PLSClassifierTest.class); |
---|
88 | } |
---|
89 | |
---|
90 | public static void main(String[] args){ |
---|
91 | junit.textui.TestRunner.run(suite()); |
---|
92 | } |
---|
93 | } |
---|