source: src/main/java/weka/gui/beans/TrainingSetEvent.java @ 24

Last change on this file since 24 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 *    TrainingSetEvent.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 training set
31 *
32 * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a>
33 * @version $Revision: 4761 $
34 */
35public class TrainingSetEvent
36  extends EventObject {
37
38  /** for serialization */
39  private static final long serialVersionUID = 5872343811810872662L;
40 
41  /**
42   * The training instances
43   */
44  protected Instances m_trainingSet;
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 training 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>TrainingSetEvent</code>
70   *
71   * @param source the source of the event
72   * @param trainSet the training instances
73   */
74  public TrainingSetEvent(Object source, Instances trainSet) {
75    super(source);
76    m_trainingSet = trainSet;
77    if (m_trainingSet != null && m_trainingSet.numInstances() == 0) {
78      m_structureOnly = true;
79    }
80  }
81
82  /**
83   * Creates a new <code>TrainingSetEvent</code>
84   *
85   * @param source the source of the event
86   * @param trainSet the training instances
87   * @param setNum the number of the training set
88   * @param maxSetNum the maximum number of sets
89   */
90  public TrainingSetEvent(Object source, Instances trainSet, int setNum, int maxSetNum) {
91    this(source, trainSet);
92    m_setNumber = setNum;
93    m_maxSetNumber = maxSetNum;
94  }
95 
96  /**
97   * Creates a new <code>TrainingSetEvent</code>
98   *
99   * @param source the source of the event
100   * @param trainSet the training instances
101   * @param runNum the run number that the training set belongs to
102   * @param maxRunNum the maximum run number
103   * @param setNum the number of the training set
104   * @param maxSetNum the maximum number of sets
105   */
106  public TrainingSetEvent(Object source, Instances trainSet, int runNum,
107      int maxRunNum, int setNum, int maxSetNum) {
108    this(source, trainSet, setNum, maxSetNum);
109   
110    m_runNumber = runNum;
111    m_maxRunNumber = maxRunNum; 
112  }
113
114  /**
115   * Get the training instances
116   *
117   * @return an <code>Instances</code> value
118   */
119  public Instances getTrainingSet() {
120    return m_trainingSet;
121  }
122 
123  /**
124   * Get the run number that this training set belongs to.
125   *
126   * @return the run number for this training set.
127   */
128  public int getRunNumber() {
129    return m_runNumber;
130  }
131 
132  /**
133   * Get the maximum number of runs.
134   *
135   * @return return the maximum number of runs.
136   */
137  public int getMaxRunNumber() {
138    return m_maxRunNumber;
139  }
140
141  /**
142   * Get the set number (eg. fold 2 of a 10 fold split)
143   *
144   * @return an <code>int</code> value
145   */
146  public int getSetNumber() {
147    return m_setNumber;
148  }
149
150  /**
151   * Get the maximum set number
152   *
153   * @return an <code>int</code> value
154   */
155  public int getMaxSetNumber() {
156    return m_maxSetNumber;
157  }
158
159  /**
160   * Returns true if the encapsulated instances
161   * contain just header information
162   *
163   * @return true if only header information is
164   * available in this DataSetEvent
165   */
166  public boolean isStructureOnly() {
167    return m_structureOnly;
168  }
169}
Note: See TracBrowser for help on using the repository browser.