source: branches/MetisMQI/src/test/java/weka/filters/supervised/instance/StratifiedRemoveFoldsTest.java

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

Taggata versione per la demo e aggiunto branch.

File size: 2.3 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) 2002 University of Waikato
19 */
20
21package weka.filters.supervised.instance;
22
23import weka.core.Instances;
24import weka.filters.AbstractFilterTest;
25import weka.filters.Filter;
26
27import junit.framework.Test;
28import junit.framework.TestSuite;
29
30/**
31 * Tests StratifiedRemoveFolds. Run from the command line with:<p>
32 * java weka.filters.supervised.instance.StratifiedRemoveFoldsTest
33 *
34 * @author <a href="mailto:len@reeltwo.com">Len Trigg</a>
35 * @version $Revision: 1.3 $
36 */
37public class StratifiedRemoveFoldsTest extends AbstractFilterTest {
38 
39  public StratifiedRemoveFoldsTest(String name) { super(name);  }
40
41  /** Creates a default StratifiedRemoveFolds */
42  public Filter getFilter() {
43    StratifiedRemoveFolds f = new StratifiedRemoveFolds();
44    return f;
45  }
46
47  /** Remove string attributes from default fixture instances */
48  protected void setUp() throws Exception {
49
50    super.setUp();
51    m_Instances.setClassIndex(1);
52  }
53
54  public void testAllFolds() {
55   
56    int totInstances = 0;
57    for (int i = 0; i < 10; i++) {
58      ((StratifiedRemoveFolds)m_Filter).setFold(i + 1);
59      Instances result = useFilter();
60      assertEquals(m_Instances.numAttributes(), result.numAttributes());
61      totInstances += result.numInstances();
62    }
63    assertEquals("Expecting output number of instances to match",
64                 m_Instances.numInstances(),  totInstances);
65  }
66
67  public static Test suite() {
68    return new TestSuite(StratifiedRemoveFoldsTest.class);
69  }
70
71  public static void main(String[] args){
72    junit.textui.TestRunner.run(suite());
73  }
74
75}
Note: See TracBrowser for help on using the repository browser.