[4] | 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 | * BatchClassifierEvent.java |
---|
| 19 | * Copyright (C) 2002 University of Waikato, Hamilton, New Zealand |
---|
| 20 | * |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | package weka.gui.beans; |
---|
| 24 | |
---|
| 25 | import weka.classifiers.Classifier; |
---|
| 26 | import weka.classifiers.AbstractClassifier; |
---|
| 27 | |
---|
| 28 | import java.util.EventObject; |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | * Class encapsulating a built classifier and a batch of instances to |
---|
| 32 | * test on. |
---|
| 33 | * |
---|
| 34 | * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a> |
---|
| 35 | * @version $Revision: 5928 $ |
---|
| 36 | * @since 1.0 |
---|
| 37 | * @see EventObject |
---|
| 38 | */ |
---|
| 39 | public class BatchClassifierEvent |
---|
| 40 | extends EventObject { |
---|
| 41 | |
---|
| 42 | /** for serialization */ |
---|
| 43 | private static final long serialVersionUID = 878097199815991084L; |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * The classifier |
---|
| 47 | */ |
---|
| 48 | protected Classifier m_classifier; |
---|
| 49 | // protected Instances m_trainingSet; |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * Instances that can be used for testing the classifier |
---|
| 53 | */ |
---|
| 54 | // protected Instances m_testSet; |
---|
| 55 | protected DataSetEvent m_testSet; |
---|
| 56 | |
---|
| 57 | /** |
---|
| 58 | * Instances that were used to train the classifier (may be null if not available) |
---|
| 59 | */ |
---|
| 60 | protected DataSetEvent m_trainSet; |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | * The run number that this classifier was generated for |
---|
| 64 | */ |
---|
| 65 | protected int m_runNumber = 1; |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * The maximum number of runs |
---|
| 69 | */ |
---|
| 70 | protected int m_maxRunNumber = 1; |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * The set number for the test set |
---|
| 74 | */ |
---|
| 75 | protected int m_setNumber; |
---|
| 76 | |
---|
| 77 | /** |
---|
| 78 | * The last set number for this series |
---|
| 79 | */ |
---|
| 80 | protected int m_maxSetNumber; |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * An identifier that can be used to group all related runs/sets |
---|
| 84 | * together. |
---|
| 85 | */ |
---|
| 86 | protected long m_groupIdentifier = Long.MAX_VALUE; |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * Creates a new <code>BatchClassifierEvent</code> instance. |
---|
| 90 | * |
---|
| 91 | * @param source the source object |
---|
| 92 | * @param scheme a Classifier |
---|
| 93 | * @param trsI the training instances used to train the classifier |
---|
| 94 | * @param tstI the test instances |
---|
| 95 | * @param setNum the set number of the test instances |
---|
| 96 | * @param maxSetNum the last set number in the series |
---|
| 97 | */ |
---|
| 98 | public BatchClassifierEvent(Object source, Classifier scheme, |
---|
| 99 | DataSetEvent trsI, DataSetEvent tstI, int setNum, |
---|
| 100 | int maxSetNum) { |
---|
| 101 | super(source); |
---|
| 102 | // m_trainingSet = trnI; |
---|
| 103 | m_classifier = scheme; |
---|
| 104 | m_testSet = tstI; |
---|
| 105 | m_trainSet = trsI; |
---|
| 106 | m_setNumber = setNum; |
---|
| 107 | m_maxSetNumber = maxSetNum; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | /** |
---|
| 111 | * Creates a new <code>BatchClassifierEvent</code> instance. |
---|
| 112 | * |
---|
| 113 | * @param source the source object |
---|
| 114 | * @param scheme a Classifier |
---|
| 115 | * @param trsI the training instances used to train the classifier |
---|
| 116 | * @param tstI the test instances |
---|
| 117 | * @param runNum the run number |
---|
| 118 | * @param maxRunNum the maximum run number |
---|
| 119 | * @param setNum the set number of the test instances |
---|
| 120 | * @param maxSetNum the last set number in the series |
---|
| 121 | */ |
---|
| 122 | public BatchClassifierEvent(Object source, Classifier scheme, |
---|
| 123 | DataSetEvent trsI, DataSetEvent tstI, int runNum, int maxRunNum, |
---|
| 124 | int setNum, int maxSetNum) { |
---|
| 125 | |
---|
| 126 | this(source, scheme, trsI, tstI, setNum, maxSetNum); |
---|
| 127 | |
---|
| 128 | m_runNumber = runNum; |
---|
| 129 | m_maxRunNumber = maxRunNum; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | // /** |
---|
| 133 | // * Get the training instances |
---|
| 134 | // * |
---|
| 135 | // * @return the training instances |
---|
| 136 | // */ |
---|
| 137 | // public Instances getTrainingSet() { |
---|
| 138 | // return m_trainingSet; |
---|
| 139 | // } |
---|
| 140 | |
---|
| 141 | /** |
---|
| 142 | * Get the classifier |
---|
| 143 | * |
---|
| 144 | * @return the classifier |
---|
| 145 | */ |
---|
| 146 | public Classifier getClassifier() { |
---|
| 147 | return m_classifier; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | /** |
---|
| 151 | * Set the classifier |
---|
| 152 | * |
---|
| 153 | * @param classifier the classifier |
---|
| 154 | */ |
---|
| 155 | public void setClassifier(Classifier classifier) { |
---|
| 156 | m_classifier = classifier; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | /** |
---|
| 160 | * Set the test set |
---|
| 161 | * |
---|
| 162 | * @param tse the test set |
---|
| 163 | */ |
---|
| 164 | public void setTestSet(DataSetEvent tse) { |
---|
| 165 | m_testSet = tse; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | /** |
---|
| 169 | * Get the test set |
---|
| 170 | * |
---|
| 171 | * @return the test set |
---|
| 172 | */ |
---|
| 173 | public DataSetEvent getTestSet() { |
---|
| 174 | return m_testSet; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | /** |
---|
| 178 | * Set the training set |
---|
| 179 | * |
---|
| 180 | * @param tse the training set |
---|
| 181 | */ |
---|
| 182 | public void setTrainSet(DataSetEvent tse) { |
---|
| 183 | m_trainSet = tse; |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | /** |
---|
| 187 | * Get the train set |
---|
| 188 | * |
---|
| 189 | * @return the training set |
---|
| 190 | */ |
---|
| 191 | public DataSetEvent getTrainSet() { |
---|
| 192 | return m_trainSet; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | /** |
---|
| 196 | * Get the run number. |
---|
| 197 | * |
---|
| 198 | * @return the run number |
---|
| 199 | */ |
---|
| 200 | public int getRunNumber() { |
---|
| 201 | return m_runNumber; |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | /** |
---|
| 205 | * Get the maximum run number |
---|
| 206 | * |
---|
| 207 | * @return the maximum run number |
---|
| 208 | */ |
---|
| 209 | public int getMaxRunNumber() { |
---|
| 210 | return m_maxRunNumber; |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | /** |
---|
| 214 | * Get the set number (ie which fold this is) |
---|
| 215 | * |
---|
| 216 | * @return the set number for the training and testing data sets |
---|
| 217 | * encapsulated in this event |
---|
| 218 | */ |
---|
| 219 | public int getSetNumber() { |
---|
| 220 | return m_setNumber; |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | /** |
---|
| 224 | * Get the maximum set number (ie the total number of training |
---|
| 225 | * and testing sets in the series). |
---|
| 226 | * |
---|
| 227 | * @return the maximum set number |
---|
| 228 | */ |
---|
| 229 | public int getMaxSetNumber() { |
---|
| 230 | return m_maxSetNumber; |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | public void setGroupIdentifier(long identifier) { |
---|
| 234 | m_groupIdentifier = identifier; |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | public long getGroupIdentifier() { |
---|
| 238 | return m_groupIdentifier; |
---|
| 239 | } |
---|
| 240 | } |
---|
| 241 | |
---|