source: branches/MetisMQI/src/test/java/weka/classifiers/meta/GridSearchTest.java

Last change on this file was 29, checked in by gnappo, 14 years ago

Taggata versione per la demo e aggiunto branch.

File size: 2.8 KB
Line 
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
21package weka.classifiers.meta;
22
23import weka.classifiers.AbstractClassifierTest;
24import weka.classifiers.CheckClassifier;
25import weka.classifiers.Classifier;
26import weka.core.SelectedTag;
27
28import junit.framework.Test;
29import junit.framework.TestSuite;
30
31/**
32 * Tests GridSearch. Run from the command line with:<p/>
33 * java weka.classifiers.meta.GridSearchTest
34 *
35 * @author FracPete (fracpete at waikato dot ac dot nz)
36 * @version $Revision: 1.1 $
37 */
38public class GridSearchTest 
39  extends AbstractClassifierTest {
40
41  public GridSearchTest(String name) { 
42    super(name); 
43  }
44
45  /**
46   * Creates a GridSearch with J48 + unsup. Discretize filter sinze the random
47   * test dataset always results in singular matrix in LU decomposition of
48   * the PLSFilter.
49   *
50   * @return            the configured classifier
51   */
52  public Classifier getClassifier() {
53    GridSearch          result;
54   
55    result = new GridSearch();
56   
57    result.setEvaluation(new SelectedTag(GridSearch.EVALUATION_ACC, GridSearch.TAGS_EVALUATION));
58   
59    // classifier
60    result.setClassifier(new weka.classifiers.trees.J48());
61    result.setYProperty("classifier.confidenceFactor");
62    result.setYMin(0.2);
63    result.setYMax(0.4);
64    result.setYStep(0.1);
65    result.setYExpression("I");
66   
67    // filter
68    result.setFilter(new weka.filters.unsupervised.attribute.Discretize());
69    result.setXProperty("filter.bins");
70    result.setXMin(2);
71    result.setXMax(10);
72    result.setXStep(2);
73    result.setXExpression("I");
74   
75    return result;
76  }
77 
78  /**
79   * configures the CheckClassifier instance used throughout the tests
80   *
81   * @return    the fully configured CheckClassifier instance used for testing
82   */
83  protected CheckClassifier getTester() {
84    CheckClassifier     result;
85   
86    result = super.getTester();
87    result.setNumNumeric(7);
88    result.setNumInstances(100);
89   
90    return result;
91  }
92
93  public static Test suite() {
94    return new TestSuite(GridSearchTest.class);
95  }
96
97  public static void main(String[] args){
98    junit.textui.TestRunner.run(suite());
99  }
100}
Note: See TracBrowser for help on using the repository browser.