source: src/main/java/weka/gui/beans/TestSetEvent.java @ 9

Last change on this file since 9 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 4.1 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 *    TestSetEvent.java
19 *    Copyright (C) 2002 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.gui.beans;
24
25import weka.core.Instances;
26
27import java.util.EventObject;
28
29/**
30 * Event encapsulating a test set
31 *
32 * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a>
33 * @version $Revision: 4761 $
34 */
35public class TestSetEvent
36  extends EventObject {
37
38  /** for serialization */
39  private static final long serialVersionUID = 8780718708498854231L;
40 
41  /**
42   * The test set instances
43   */
44  protected Instances m_testSet;
45  private boolean m_structureOnly;
46 
47  /**
48   * What run number is this training set from.
49   */
50  protected int m_runNumber = 1;
51 
52 
53  /**
54   * Maximum number of runs.
55   */
56  protected int m_maxRunNumber = 1;
57
58  /**
59   * what number is this test set (ie fold 2 of 10 folds)
60   */
61  protected int m_setNumber;
62
63  /**
64   * Maximum number of sets (ie 10 in a 10 fold)
65   */
66  protected int m_maxSetNumber;
67
68  /**
69   * Creates a new <code>TestSetEvent</code>
70   *
71   * @param source the source of the event
72   * @param testSet the test instances
73   */
74  public TestSetEvent(Object source, Instances testSet) {
75    super(source);
76    m_testSet = testSet;
77    if (m_testSet != null && m_testSet.numInstances() == 0) {
78      m_structureOnly = true;
79    }
80  }
81
82  /**
83   * Creates a new <code>TestSetEvent</code>
84   *
85   * @param source the source of the event
86   * @param testSet the test instances
87   * @param setNum the number of the test set
88   * @param maxSetNum the maximum number of sets
89   */
90  public TestSetEvent(Object source, Instances testSet, 
91                      int setNum, int maxSetNum) {
92    this(source, testSet);
93    m_setNumber = setNum;
94    m_maxSetNumber = maxSetNum;
95  }
96 
97  /**
98   * Creates a new <code>TestSetEvent</code>
99   *
100   * @param source the source of the event
101   * @param testSet the test instances
102   * @param runNum the run number that the test set belongs to
103   * @param maxRunNum the maximum run number
104   * @param setNum the number of the test set
105   * @param maxSetNum the maximum number of sets
106   */
107  public TestSetEvent(Object source, Instances testSet,
108      int runNum, int maxRunNum, int setNum, int maxSetNum) {
109    this(source, testSet, setNum, maxSetNum);
110   
111    m_runNumber = runNum;
112    m_maxRunNumber = maxRunNum;
113  }
114
115  /**
116   * Get the test set instances
117   *
118   * @return an <code>Instances</code> value
119   */
120  public Instances getTestSet() {
121    return m_testSet;
122  }
123 
124  /**
125   * Get the run number that this training set belongs to.
126   *
127   * @return the run number for this training set.
128   */
129  public int getRunNumber() {
130    return m_runNumber;
131  }
132 
133  /**
134   * Get the maximum number of runs.
135   *
136   * @return return the maximum number of runs.
137   */
138  public int getMaxRunNumber() {
139    return m_maxRunNumber;
140  }
141
142  /**
143   * Get the test set number (eg. fold 2 of a 10 fold split)
144   *
145   * @return an <code>int</code> value
146   */
147  public int getSetNumber() {
148    return m_setNumber;
149  }
150
151  /**
152   * Get the maximum set number
153   *
154   * @return an <code>int</code> value
155   */
156  public int getMaxSetNumber() {
157    return m_maxSetNumber;
158  }
159
160  /**
161   * Returns true if the encapsulated instances
162   * contain just header information
163   *
164   * @return true if only header information is
165   * available in this DataSetEvent
166   */
167  public boolean isStructureOnly() {
168    return m_structureOnly;
169  }
170}
Note: See TracBrowser for help on using the repository browser.