Changeset 67 for trunk/CrossPare/src/de/ugoe
- Timestamp:
- 05/03/16 10:09:56 (9 years ago)
- Location:
- trunk/CrossPare/src/de/ugoe/cs/cpdp/execution
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/CrossProjectExperiment.java
r65 r67 15 15 package de.ugoe.cs.cpdp.execution; 16 16 17 import java.io.File;18 import java.util.Collections;19 import java.util.LinkedList;20 import java.util.List;21 import java.util.logging.Level;22 23 import org.apache.commons.collections4.list.SetUniqueList;24 25 import weka.core.Instances;26 17 import de.ugoe.cs.cpdp.ExperimentConfiguration; 27 import de.ugoe.cs.cpdp.dataprocessing.IProcessesingStrategy;28 import de.ugoe.cs.cpdp.dataprocessing.ISetWiseProcessingStrategy;29 import de.ugoe.cs.cpdp.dataselection.IPointWiseDataselectionStrategy;30 import de.ugoe.cs.cpdp.dataselection.ISetWiseDataselectionStrategy;31 import de.ugoe.cs.cpdp.eval.IEvaluationStrategy;32 import de.ugoe.cs.cpdp.loader.IVersionLoader;33 import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy;34 import de.ugoe.cs.cpdp.training.ISetWiseTrainingStrategy;35 import de.ugoe.cs.cpdp.training.ITestAwareTrainingStrategy;36 import de.ugoe.cs.cpdp.training.ITrainer;37 import de.ugoe.cs.cpdp.training.ITrainingStrategy;38 import de.ugoe.cs.cpdp.versions.IVersionFilter;39 18 import de.ugoe.cs.cpdp.versions.SoftwareVersion; 40 import de.ugoe.cs.util.console.Console;41 19 42 20 /** 43 * Class responsible for executing an experiment according to an {@link ExperimentConfiguration}. 44 * The steps of an experiment are as follows: 45 * <ul> 46 * <li>load the data from the provided data path</li> 47 * <li>filter the data sets according to the provided version filters</li> 48 * <li>execute the following steps for each data sets as test data that is not ignored through the 49 * test version filter: 50 * <ul> 51 * <li>filter the data sets to setup the candidate training data: 52 * <ul> 53 * <li>remove all data sets from the same project</li> 54 * <li>filter all data sets according to the training data filter 55 * </ul> 56 * </li> 57 * <li>apply the setwise preprocessors</li> 58 * <li>apply the setwise data selection algorithms</li> 59 * <li>apply the setwise postprocessors</li> 60 * <li>train the setwise training classifiers</li> 61 * <li>unify all remaining training data into one data set</li> 62 * <li>apply the preprocessors</li> 63 * <li>apply the pointwise data selection algorithms</li> 64 * <li>apply the postprocessors</li> 65 * <li>train the normal classifiers</li> 66 * <li>evaluate the results for all trained classifiers on the training data</li> 67 * </ul> 68 * </li> 69 * </ul> 70 * 71 * Note that this class implements {@link Runnable}, i.e., each experiment can be started in its own 72 * thread. 21 * <p> 22 * Implements a cross project experiment where all versions not from the same project are used. 23 * </p> 73 24 * 74 25 * @author Steffen Herbold 75 26 */ 76 public class CrossProjectExperiment implements IExecutionStrategy { 77 78 /** 79 * configuration of the experiment 80 */ 81 private final ExperimentConfiguration config; 27 public class CrossProjectExperiment extends AbstractCrossProjectExperiment { 82 28 83 29 /** … … 88 34 */ 89 35 public CrossProjectExperiment(ExperimentConfiguration config) { 90 this.config = config;36 super(config); 91 37 } 92 38 93 /* *94 * Executes the experiment with the steps as described in the class comment.39 /* 40 * (non-Javadoc) 95 41 * 96 * @see Runnable#run() 42 * @see 43 * de.ugoe.cs.cpdp.execution.AbstractCrossProjectExperiment#isTrainingVersion(de.ugoe.cs.cpdp. 44 * versions.SoftwareVersion, de.ugoe.cs.cpdp.versions.SoftwareVersion) 97 45 */ 98 46 @Override 99 public void run() { 100 final List<SoftwareVersion> versions = new LinkedList<>(); 101 102 for (IVersionLoader loader : config.getLoaders()) { 103 versions.addAll(loader.load()); 104 } 105 106 for (IVersionFilter filter : config.getVersionFilters()) { 107 filter.apply(versions); 108 } 109 boolean writeHeader = true; 110 int versionCount = 1; 111 int testVersionCount = 0; 112 113 for (SoftwareVersion testVersion : versions) { 114 if (isVersion(testVersion, config.getTestVersionFilters())) { 115 testVersionCount++; 116 } 117 } 118 119 // sort versions 120 Collections.sort(versions); 121 122 for (SoftwareVersion testVersion : versions) { 123 if (isVersion(testVersion, config.getTestVersionFilters())) { 124 Console.traceln(Level.INFO, String.format("[%s] [%02d/%02d] %s: starting", 125 config.getExperimentName(), versionCount, 126 testVersionCount, 127 testVersion.getVersion())); 128 129 // Setup testdata and training data 130 Instances testdata = testVersion.getInstances(); 131 String testProject = testVersion.getProject(); 132 SetUniqueList<Instances> traindataSet = 133 SetUniqueList.setUniqueList(new LinkedList<Instances>()); 134 for (SoftwareVersion trainingVersion : versions) { 135 if (isVersion(trainingVersion, config.getTrainingVersionFilters())) { 136 if (trainingVersion != testVersion) { 137 if (!trainingVersion.getProject().equals(testProject)) { 138 traindataSet.add(trainingVersion.getInstances()); 139 } 140 } 141 } 142 } 143 144 for (ISetWiseProcessingStrategy processor : config.getSetWisePreprocessors()) { 145 Console.traceln(Level.FINE, String 146 .format("[%s] [%02d/%02d] %s: applying setwise preprocessor %s", 147 config.getExperimentName(), versionCount, testVersionCount, 148 testVersion.getVersion(), processor.getClass().getName())); 149 processor.apply(testdata, traindataSet); 150 } 151 for (ISetWiseDataselectionStrategy dataselector : config.getSetWiseSelectors()) { 152 Console.traceln(Level.FINE, String 153 .format("[%s] [%02d/%02d] %s: applying setwise selection %s", 154 config.getExperimentName(), versionCount, testVersionCount, 155 testVersion.getVersion(), dataselector.getClass().getName())); 156 dataselector.apply(testdata, traindataSet); 157 } 158 for (ISetWiseProcessingStrategy processor : config.getSetWisePostprocessors()) { 159 Console.traceln(Level.FINE, String 160 .format("[%s] [%02d/%02d] %s: applying setwise postprocessor %s", 161 config.getExperimentName(), versionCount, testVersionCount, 162 testVersion.getVersion(), processor.getClass().getName())); 163 processor.apply(testdata, traindataSet); 164 } 165 for (ISetWiseTrainingStrategy setwiseTrainer : config.getSetWiseTrainers()) { 166 Console.traceln(Level.FINE, String 167 .format("[%s] [%02d/%02d] %s: applying setwise trainer %s", 168 config.getExperimentName(), versionCount, testVersionCount, 169 testVersion.getVersion(), setwiseTrainer.getName())); 170 setwiseTrainer.apply(traindataSet); 171 } 172 for (ISetWiseTestdataAwareTrainingStrategy setwiseTestdataAwareTrainer : config.getSetWiseTestdataAwareTrainers()) { 173 Console.traceln(Level.FINE, String 174 .format("[%s] [%02d/%02d] %s: applying testdata aware setwise trainer %s", 175 config.getExperimentName(), versionCount, testVersionCount, 176 testVersion.getVersion(), setwiseTestdataAwareTrainer.getName())); 177 setwiseTestdataAwareTrainer.apply(traindataSet, testdata); 178 } 179 Instances traindata = makeSingleTrainingSet(traindataSet); 180 for (IProcessesingStrategy processor : config.getPreProcessors()) { 181 Console.traceln(Level.FINE, String 182 .format("[%s] [%02d/%02d] %s: applying preprocessor %s", 183 config.getExperimentName(), versionCount, testVersionCount, 184 testVersion.getVersion(), processor.getClass().getName())); 185 processor.apply(testdata, traindata); 186 } 187 for (IPointWiseDataselectionStrategy dataselector : config.getPointWiseSelectors()) 188 { 189 Console.traceln(Level.FINE, String 190 .format("[%s] [%02d/%02d] %s: applying pointwise selection %s", 191 config.getExperimentName(), versionCount, testVersionCount, 192 testVersion.getVersion(), dataselector.getClass().getName())); 193 traindata = dataselector.apply(testdata, traindata); 194 } 195 for (IProcessesingStrategy processor : config.getPostProcessors()) { 196 Console.traceln(Level.FINE, String 197 .format("[%s] [%02d/%02d] %s: applying setwise postprocessor %s", 198 config.getExperimentName(), versionCount, testVersionCount, 199 testVersion.getVersion(), processor.getClass().getName())); 200 processor.apply(testdata, traindata); 201 } 202 for (ITrainingStrategy trainer : config.getTrainers()) { 203 Console.traceln(Level.FINE, String 204 .format("[%s] [%02d/%02d] %s: applying trainer %s", 205 config.getExperimentName(), versionCount, testVersionCount, 206 testVersion.getVersion(), trainer.getName())); 207 trainer.apply(traindata); 208 } 209 for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 210 Console.traceln(Level.FINE, String 211 .format("[%s] [%02d/%02d] %s: applying trainer %s", 212 config.getExperimentName(), versionCount, testVersionCount, 213 testVersion.getVersion(), trainer.getName())); 214 trainer.apply(testdata, traindata); 215 } 216 File resultsDir = new File(config.getResultsPath()); 217 if (!resultsDir.exists()) { 218 resultsDir.mkdir(); 219 } 220 for (IEvaluationStrategy evaluator : config.getEvaluators()) { 221 Console.traceln(Level.FINE, String 222 .format("[%s] [%02d/%02d] %s: applying evaluator %s", 223 config.getExperimentName(), versionCount, testVersionCount, 224 testVersion.getVersion(), evaluator.getClass().getName())); 225 List<ITrainer> allTrainers = new LinkedList<>(); 226 for (ISetWiseTrainingStrategy setwiseTrainer : config.getSetWiseTrainers()) { 227 allTrainers.add(setwiseTrainer); 228 } 229 for (ISetWiseTestdataAwareTrainingStrategy setwiseTestdataAwareTrainer : config.getSetWiseTestdataAwareTrainers()) { 230 allTrainers.add(setwiseTestdataAwareTrainer); 231 } 232 for (ITrainingStrategy trainer : config.getTrainers()) { 233 allTrainers.add(trainer); 234 } 235 for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 236 allTrainers.add(trainer); 237 } 238 if (writeHeader) { 239 evaluator.setParameter(config.getResultsPath() + "/" + 240 config.getExperimentName() + ".csv"); 241 } 242 evaluator.apply(testdata, traindata, allTrainers, writeHeader); 243 writeHeader = false; 244 } 245 Console.traceln(Level.INFO, String.format("[%s] [%02d/%02d] %s: finished", 246 config.getExperimentName(), versionCount, 247 testVersionCount, 248 testVersion.getVersion())); 249 versionCount++; 250 } 251 } 252 } 253 254 /** 255 * Helper method that checks if a version passes all filters. 256 * 257 * @param version 258 * version that is checked 259 * @param filters 260 * list of the filters 261 * @return true, if the version passes all filters, false otherwise 262 */ 263 private boolean isVersion(SoftwareVersion version, List<IVersionFilter> filters) { 264 boolean result = true; 265 for (IVersionFilter filter : filters) { 266 result &= !filter.apply(version); 267 } 268 return result; 269 } 270 271 /** 272 * Helper method that combines a set of Weka {@link Instances} sets into a single 273 * {@link Instances} set. 274 * 275 * @param traindataSet 276 * set of {@link Instances} to be combines 277 * @return single {@link Instances} set 278 */ 279 public static Instances makeSingleTrainingSet(SetUniqueList<Instances> traindataSet) { 280 Instances traindataFull = null; 281 for (Instances traindata : traindataSet) { 282 if (traindataFull == null) { 283 traindataFull = new Instances(traindata); 284 } 285 else { 286 for (int i = 0; i < traindata.numInstances(); i++) { 287 traindataFull.add(traindata.instance(i)); 288 } 289 } 290 } 291 return traindataFull; 47 protected boolean isTrainingVersion(SoftwareVersion trainingVersion, 48 SoftwareVersion testVersion) 49 { 50 return !trainingVersion.getProject().equals(testVersion.getProject()); 292 51 } 293 52 } -
trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/RelaxedCrossProjectExperiment.java
r65 r67 15 15 package de.ugoe.cs.cpdp.execution; 16 16 17 import java.io.File;18 import java.util.Collections;19 import java.util.LinkedList;20 import java.util.List;21 import java.util.logging.Level;22 23 import org.apache.commons.collections4.list.SetUniqueList;24 25 import weka.core.Instances;26 17 import de.ugoe.cs.cpdp.ExperimentConfiguration; 27 import de.ugoe.cs.cpdp.dataprocessing.IProcessesingStrategy;28 import de.ugoe.cs.cpdp.dataprocessing.ISetWiseProcessingStrategy;29 import de.ugoe.cs.cpdp.dataselection.IPointWiseDataselectionStrategy;30 import de.ugoe.cs.cpdp.dataselection.ISetWiseDataselectionStrategy;31 import de.ugoe.cs.cpdp.eval.IEvaluationStrategy;32 import de.ugoe.cs.cpdp.loader.IVersionLoader;33 import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy;34 import de.ugoe.cs.cpdp.training.ISetWiseTrainingStrategy;35 import de.ugoe.cs.cpdp.training.ITestAwareTrainingStrategy;36 import de.ugoe.cs.cpdp.training.ITrainer;37 import de.ugoe.cs.cpdp.training.ITrainingStrategy;38 import de.ugoe.cs.cpdp.versions.IVersionFilter;39 18 import de.ugoe.cs.cpdp.versions.SoftwareVersion; 40 import de.ugoe.cs.util.console.Console;41 19 42 20 /** 43 * Class responsible for executing an experiment according to an {@link ExperimentConfiguration}. 44 * The steps of an experiment are as follows: 45 * <ul> 46 * <li>load the data from the provided data path</li> 47 * <li>filter the data sets according to the provided version filters</li> 48 * <li>execute the following steps for each data sets as test data that is not ignored through the 49 * test version filter: 50 * <ul> 51 * <li>filter the data sets to setup the candidate training data: 52 * <ul> 53 * <li>filter all data sets according to the training data filter 54 * </ul> 55 * </li> 56 * <li>apply the setwise preprocessors</li> 57 * <li>apply the setwise data selection algorithms</li> 58 * <li>apply the setwise postprocessors</li> 59 * <li>train the setwise training classifiers</li> 60 * <li>unify all remaining training data into one data set</li> 61 * <li>apply the preprocessors</li> 62 * <li>apply the pointwise data selection algorithms</li> 63 * <li>apply the postprocessors</li> 64 * <li>train the normal classifiers</li> 65 * <li>evaluate the results for all trained classifiers on the training data</li> 66 * </ul> 67 * </li> 68 * </ul> 69 * 70 * Note that this class implements {@link Runnable}, i.e., each experiment can be started in its own 71 * thread. 21 * <p> 22 * Implements a cross project experiment where all versions not from the same project are used 23 * together with all older version from the test product. 24 * </p> 72 25 * 73 26 * @author Steffen Herbold 74 27 */ 75 public class RelaxedCrossProjectExperiment implements IExecutionStrategy { 76 77 /** 78 * configuration of the experiment 79 */ 80 private final ExperimentConfiguration config; 28 public class RelaxedCrossProjectExperiment extends AbstractCrossProjectExperiment { 81 29 82 30 /** … … 87 35 */ 88 36 public RelaxedCrossProjectExperiment(ExperimentConfiguration config) { 89 this.config = config;37 super(config); 90 38 } 91 39 92 /* *93 * Executes the experiment with the steps as described in the class comment.40 /* 41 * (non-Javadoc) 94 42 * 95 * @see Runnable#run() 43 * @see 44 * de.ugoe.cs.cpdp.execution.AbstractCrossProjectExperiment#isTrainingVersion(de.ugoe.cs.cpdp. 45 * versions.SoftwareVersion, de.ugoe.cs.cpdp.versions.SoftwareVersion) 96 46 */ 97 47 @Override 98 public void run() { 99 final List<SoftwareVersion> versions = new LinkedList<>(); 100 101 for (IVersionLoader loader : config.getLoaders()) { 102 versions.addAll(loader.load()); 103 } 104 105 for (IVersionFilter filter : config.getVersionFilters()) { 106 filter.apply(versions); 107 } 108 boolean writeHeader = true; 109 int versionCount = 1; 110 int testVersionCount = 0; 111 112 for (SoftwareVersion testVersion : versions) { 113 if (isVersion(testVersion, config.getTestVersionFilters())) { 114 testVersionCount++; 48 protected boolean isTrainingVersion(SoftwareVersion trainingVersion, 49 SoftwareVersion testVersion) 50 { 51 if (trainingVersion.getProject().equals(testVersion.getProject())) { 52 if (trainingVersion.compareTo(testVersion) < 0) { 53 // only add if older 54 return true; 115 55 } 116 56 } 117 118 // sort versions 119 Collections.sort(versions); 120 121 for (SoftwareVersion testVersion : versions) { 122 if (isVersion(testVersion, config.getTestVersionFilters())) { 123 Console.traceln(Level.INFO, String.format("[%s] [%02d/%02d] %s: starting", 124 config.getExperimentName(), versionCount, 125 testVersionCount, 126 testVersion.getVersion())); 127 128 // Setup testdata and training data 129 Instances testdata = testVersion.getInstances(); 130 String testProject = testVersion.getProject(); 131 SetUniqueList<Instances> traindataSet = 132 SetUniqueList.setUniqueList(new LinkedList<Instances>()); 133 for (SoftwareVersion trainingVersion : versions) { 134 if (isVersion(trainingVersion, config.getTrainingVersionFilters())) { 135 if (trainingVersion != testVersion) { 136 if (trainingVersion.getProject().equals(testProject)) { 137 if (trainingVersion.compareTo(testVersion) < 0) { 138 // only add if older 139 traindataSet.add(trainingVersion.getInstances()); 140 } 141 } 142 else { 143 traindataSet.add(trainingVersion.getInstances()); 144 } 145 } 146 } 147 } 148 149 for (ISetWiseProcessingStrategy processor : config.getSetWisePreprocessors()) { 150 Console.traceln(Level.FINE, String 151 .format("[%s] [%02d/%02d] %s: applying setwise preprocessor %s", 152 config.getExperimentName(), versionCount, testVersionCount, 153 testVersion.getVersion(), processor.getClass().getName())); 154 processor.apply(testdata, traindataSet); 155 } 156 for (ISetWiseDataselectionStrategy dataselector : config.getSetWiseSelectors()) { 157 Console.traceln(Level.FINE, String 158 .format("[%s] [%02d/%02d] %s: applying setwise selection %s", 159 config.getExperimentName(), versionCount, testVersionCount, 160 testVersion.getVersion(), dataselector.getClass().getName())); 161 dataselector.apply(testdata, traindataSet); 162 } 163 for (ISetWiseProcessingStrategy processor : config.getSetWisePostprocessors()) { 164 Console.traceln(Level.FINE, String 165 .format("[%s] [%02d/%02d] %s: applying setwise postprocessor %s", 166 config.getExperimentName(), versionCount, testVersionCount, 167 testVersion.getVersion(), processor.getClass().getName())); 168 processor.apply(testdata, traindataSet); 169 } 170 for (ISetWiseTrainingStrategy setwiseTrainer : config.getSetWiseTrainers()) { 171 Console.traceln(Level.FINE, String 172 .format("[%s] [%02d/%02d] %s: applying setwise trainer %s", 173 config.getExperimentName(), versionCount, testVersionCount, 174 testVersion.getVersion(), setwiseTrainer.getName())); 175 setwiseTrainer.apply(traindataSet); 176 } 177 for (ISetWiseTestdataAwareTrainingStrategy setwiseTestdataAwareTrainer : config.getSetWiseTestdataAwareTrainers()) { 178 Console.traceln(Level.FINE, String 179 .format("[%s] [%02d/%02d] %s: applying testdata aware setwise trainer %s", 180 config.getExperimentName(), versionCount, testVersionCount, 181 testVersion.getVersion(), setwiseTestdataAwareTrainer.getName())); 182 setwiseTestdataAwareTrainer.apply(traindataSet, testdata); 183 } 184 Instances traindata = makeSingleTrainingSet(traindataSet); 185 for (IProcessesingStrategy processor : config.getPreProcessors()) { 186 Console.traceln(Level.FINE, String 187 .format("[%s] [%02d/%02d] %s: applying preprocessor %s", 188 config.getExperimentName(), versionCount, testVersionCount, 189 testVersion.getVersion(), processor.getClass().getName())); 190 processor.apply(testdata, traindata); 191 } 192 for (IPointWiseDataselectionStrategy dataselector : config.getPointWiseSelectors()) 193 { 194 Console.traceln(Level.FINE, String 195 .format("[%s] [%02d/%02d] %s: applying pointwise selection %s", 196 config.getExperimentName(), versionCount, testVersionCount, 197 testVersion.getVersion(), dataselector.getClass().getName())); 198 traindata = dataselector.apply(testdata, traindata); 199 } 200 for (IProcessesingStrategy processor : config.getPostProcessors()) { 201 Console.traceln(Level.FINE, String 202 .format("[%s] [%02d/%02d] %s: applying setwise postprocessor %s", 203 config.getExperimentName(), versionCount, testVersionCount, 204 testVersion.getVersion(), processor.getClass().getName())); 205 processor.apply(testdata, traindata); 206 } 207 for (ITrainingStrategy trainer : config.getTrainers()) { 208 Console.traceln(Level.FINE, String 209 .format("[%s] [%02d/%02d] %s: applying trainer %s", 210 config.getExperimentName(), versionCount, testVersionCount, 211 testVersion.getVersion(), trainer.getName())); 212 trainer.apply(traindata); 213 } 214 for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 215 Console.traceln(Level.FINE, String 216 .format("[%s] [%02d/%02d] %s: applying trainer %s", 217 config.getExperimentName(), versionCount, testVersionCount, 218 testVersion.getVersion(), trainer.getName())); 219 trainer.apply(testdata, traindata); 220 } 221 File resultsDir = new File(config.getResultsPath()); 222 if (!resultsDir.exists()) { 223 resultsDir.mkdir(); 224 } 225 for (IEvaluationStrategy evaluator : config.getEvaluators()) { 226 Console.traceln(Level.FINE, String 227 .format("[%s] [%02d/%02d] %s: applying evaluator %s", 228 config.getExperimentName(), versionCount, testVersionCount, 229 testVersion.getVersion(), evaluator.getClass().getName())); 230 List<ITrainer> allTrainers = new LinkedList<>(); 231 for (ISetWiseTrainingStrategy setwiseTrainer : config.getSetWiseTrainers()) { 232 allTrainers.add(setwiseTrainer); 233 } 234 for (ISetWiseTestdataAwareTrainingStrategy setwiseTrainer : config.getSetWiseTestdataAwareTrainers()) { 235 allTrainers.add(setwiseTrainer); 236 } 237 for (ITrainingStrategy trainer : config.getTrainers()) { 238 allTrainers.add(trainer); 239 } 240 for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 241 allTrainers.add(trainer); 242 } 243 if (writeHeader) { 244 evaluator.setParameter(config.getResultsPath() + "/" + 245 config.getExperimentName() + ".csv"); 246 } 247 evaluator.apply(testdata, traindata, allTrainers, writeHeader); 248 writeHeader = false; 249 } 250 Console.traceln(Level.INFO, String.format("[%s] [%02d/%02d] %s: finished", 251 config.getExperimentName(), versionCount, 252 testVersionCount, 253 testVersion.getVersion())); 254 versionCount++; 255 } 57 else { 58 return true; 256 59 } 257 } 258 259 /** 260 * Helper method that checks if a version passes all filters. 261 * 262 * @param version 263 * version that is checked 264 * @param filters 265 * list of the filters 266 * @return true, if the version passes all filters, false otherwise 267 */ 268 private boolean isVersion(SoftwareVersion version, List<IVersionFilter> filters) { 269 boolean result = true; 270 for (IVersionFilter filter : filters) { 271 result &= !filter.apply(version); 272 } 273 return result; 274 } 275 276 /** 277 * Helper method that combines a set of Weka {@link Instances} sets into a single 278 * {@link Instances} set. 279 * 280 * @param traindataSet 281 * set of {@link Instances} to be combines 282 * @return single {@link Instances} set 283 */ 284 public static Instances makeSingleTrainingSet(SetUniqueList<Instances> traindataSet) { 285 Instances traindataFull = null; 286 for (Instances traindata : traindataSet) { 287 if (traindataFull == null) { 288 traindataFull = new Instances(traindata); 289 } 290 else { 291 for (int i = 0; i < traindata.numInstances(); i++) { 292 traindataFull.add(traindata.instance(i)); 293 } 294 } 295 } 296 return traindataFull; 60 return false; 297 61 } 298 62 }
Note: See TracChangeset
for help on using the changeset viewer.