Changeset 68
- Timestamp:
- 05/03/16 10:30:09 (9 years ago)
- Location:
- trunk/CrossPare
- Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/.classpath
r62 r68 21 21 <classpathentry kind="lib" path="lib/alternatingDecisionTrees.jar"/> 22 22 <classpathentry kind="lib" path="lib/guava-19.0.jar"/> 23 <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.38-bin.jar"/> 23 24 <classpathentry kind="output" path="bin"/> 24 25 </classpath> -
trunk/CrossPare/build.xml
r62 r68 23 23 <pathelement location="lib/ojalgo-37.1.jar" /> 24 24 <pathelement location="lib/elki-bundle-0.7.1.jar" /> 25 <pathelement location="lib/mysql-connector-java-5.1.38-bin" /> 25 26 </path> 26 27 -
trunk/CrossPare/experimentconfig.xsd
r45 r68 25 25 <xs:element name="postprocessor" type="setupType" minOccurs="0" maxOccurs="unbounded"/> 26 26 <xs:element name="trainer" type="setupType" minOccurs="0" maxOccurs="unbounded"/> 27 <xs:element name="testawaretrainer" type="setupType" minOccurs="0" maxOccurs="unbounded"/> 27 28 <xs:element name="eval" type="setupType" minOccurs="0" maxOccurs="unbounded"/> 29 <xs:element name="storage" type="setupType" minOccurs="0" maxOccurs="unbounded"/> 28 30 <xs:element name="partialconfig" type="pathType" minOccurs="0" maxOccurs="unbounded"/> 29 31 </xs:sequence> -
trunk/CrossPare/src/de/ugoe/cs/cpdp/ExperimentConfiguration.java
r66 r68 39 39 import de.ugoe.cs.cpdp.dataselection.ISetWiseDataselectionStrategy; 40 40 import de.ugoe.cs.cpdp.eval.IEvaluationStrategy; 41 import de.ugoe.cs.cpdp.eval.IResultStorage; 41 42 import de.ugoe.cs.cpdp.loader.IVersionLoader; 42 43 import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy; … … 116 117 117 118 /** 118 * setwise testdata aware trainers, i.e., trainers that require the selected training data to be separate from119 * each other and the current testdata119 * setwise testdata aware trainers, i.e., trainers that require the selected training data to be 120 * separate from each other and the current testdata 120 121 */ 121 122 private List<ISetWiseTestdataAwareTrainingStrategy> setwiseTestdataAwareTrainers; 122 123 123 124 /** 124 125 * data processors that are applied before the pointwise data selection … … 140 141 */ 141 142 private List<ITrainingStrategy> trainers; 142 143 143 144 /** 144 145 * normal trainers, i.e., trainers that require the selected training data in a single data set … … 150 151 */ 151 152 private List<IEvaluationStrategy> evaluators; 153 154 /** 155 * result storages used for experiments 156 */ 157 private List<IResultStorage> resultStorages; 152 158 153 159 /** … … 198 204 testAwareTrainers = new LinkedList<>(); 199 205 evaluators = new LinkedList<>(); 206 resultStorages = new LinkedList<>(); 200 207 201 208 if (file == null) { … … 347 354 return setwiseTestdataAwareTrainers; 348 355 } 349 356 350 357 /** 351 358 * returns the processors applied before the pointwise data selection … … 383 390 return trainers; 384 391 } 385 392 386 393 /** 387 394 * returns the test aware training algorithms … … 400 407 public List<IEvaluationStrategy> getEvaluators() { 401 408 return evaluators; 409 } 410 411 public List<IResultStorage> getResultStorages() { 412 return resultStorages; 402 413 } 403 414 … … 435 446 } 436 447 else if (qName.equals("loader")) { 437 final IVersionLoader loader = 438 (IVersionLoader) Class.forName("de.ugoe.cs.cpdp.loader." + 439 attributes.getValue("name")).newInstance(); 448 final IVersionLoader loader = (IVersionLoader) Class 449 .forName("de.ugoe.cs.cpdp.loader." + attributes.getValue("name")).newInstance(); 440 450 loader.setLocation(attributes.getValue("datalocation")); 441 451 loaders.add(loader); … … 447 457 } 448 458 else if (qName.equals("versionfilter")) { 449 final IVersionFilter filter = 450 (IVersionFilter) Class.forName("de.ugoe.cs.cpdp.versions." +451 attributes.getValue("name")).newInstance();459 final IVersionFilter filter = (IVersionFilter) Class 460 .forName("de.ugoe.cs.cpdp.versions." + attributes.getValue("name")) 461 .newInstance(); 452 462 filter.setParameter(attributes.getValue("param")); 453 463 versionFilters.add(filter); 454 464 } 455 465 else if (qName.equals("testVersionfilter")) { 456 final IVersionFilter filter = 457 (IVersionFilter) Class.forName("de.ugoe.cs.cpdp.versions." +458 attributes.getValue("name")).newInstance();466 final IVersionFilter filter = (IVersionFilter) Class 467 .forName("de.ugoe.cs.cpdp.versions." + attributes.getValue("name")) 468 .newInstance(); 459 469 filter.setParameter(attributes.getValue("param")); 460 470 testVersionFilters.add(filter); 461 471 } 462 472 else if (qName.equals("trainVersionfilter")) { 463 final IVersionFilter filter = 464 (IVersionFilter) Class.forName("de.ugoe.cs.cpdp.versions." +465 attributes.getValue("name")).newInstance();473 final IVersionFilter filter = (IVersionFilter) Class 474 .forName("de.ugoe.cs.cpdp.versions." + attributes.getValue("name")) 475 .newInstance(); 466 476 filter.setParameter(attributes.getValue("param")); 467 477 trainingVersionFilters.add(filter); 468 478 } 469 479 else if (qName.equals("setwisepreprocessor")) { 470 final ISetWiseProcessingStrategy processor = 471 (ISetWiseProcessingStrategy) Class.forName("de.ugoe.cs.cpdp.dataprocessing." + 472 attributes.getValue("name")) 473 .newInstance(); 480 final ISetWiseProcessingStrategy processor = (ISetWiseProcessingStrategy) Class 481 .forName("de.ugoe.cs.cpdp.dataprocessing." + attributes.getValue("name")) 482 .newInstance(); 474 483 processor.setParameter(attributes.getValue("param")); 475 484 setwisepreprocessors.add(processor); … … 477 486 else if (qName.equals("setwiseselector")) { 478 487 final ISetWiseDataselectionStrategy selection = 479 (ISetWiseDataselectionStrategy) Class .forName("de.ugoe.cs.cpdp.dataselection." +480 488 (ISetWiseDataselectionStrategy) Class 489 .forName("de.ugoe.cs.cpdp.dataselection." + attributes.getValue("name")) 481 490 .newInstance(); 482 491 selection.setParameter(attributes.getValue("param")); … … 484 493 } 485 494 else if (qName.equals("setwisepostprocessor")) { 486 final ISetWiseProcessingStrategy processor = 487 (ISetWiseProcessingStrategy) Class.forName("de.ugoe.cs.cpdp.dataprocessing." + 488 attributes.getValue("name")) 489 .newInstance(); 495 final ISetWiseProcessingStrategy processor = (ISetWiseProcessingStrategy) Class 496 .forName("de.ugoe.cs.cpdp.dataprocessing." + attributes.getValue("name")) 497 .newInstance(); 490 498 processor.setParameter(attributes.getValue("param")); 491 499 setwisepostprocessors.add(processor); 492 500 } 493 501 else if (qName.equals("setwisetrainer")) { 494 final ISetWiseTrainingStrategy trainer = 495 (ISetWiseTrainingStrategy) Class.forName("de.ugoe.cs.cpdp.training." + 496 attributes.getValue("name")) 497 .newInstance(); 502 final ISetWiseTrainingStrategy trainer = (ISetWiseTrainingStrategy) Class 503 .forName("de.ugoe.cs.cpdp.training." + attributes.getValue("name")) 504 .newInstance(); 498 505 trainer.setParameter(attributes.getValue("param")); 499 506 setwiseTrainers.add(trainer); … … 501 508 else if (qName.equals("setwisetestdataawaretrainer")) { 502 509 final ISetWiseTestdataAwareTrainingStrategy trainer = 503 (ISetWiseTestdataAwareTrainingStrategy) Class .forName("de.ugoe.cs.cpdp.training." +504 510 (ISetWiseTestdataAwareTrainingStrategy) Class 511 .forName("de.ugoe.cs.cpdp.training." + attributes.getValue("name")) 505 512 .newInstance(); 506 513 trainer.setParameter(attributes.getValue("param")); … … 510 517 } 511 518 else if (qName.equals("preprocessor")) { 512 final IProcessesingStrategy processor = 513 (IProcessesingStrategy) Class.forName("de.ugoe.cs.cpdp.dataprocessing." + 514 attributes.getValue("name")) 515 .newInstance(); 519 final IProcessesingStrategy processor = (IProcessesingStrategy) Class 520 .forName("de.ugoe.cs.cpdp.dataprocessing." + attributes.getValue("name")) 521 .newInstance(); 516 522 processor.setParameter(attributes.getValue("param")); 517 523 preprocessors.add(processor); … … 526 532 } 527 533 else if (qName.equals("postprocessor")) { 528 final IProcessesingStrategy processor = 529 (IProcessesingStrategy) Class.forName("de.ugoe.cs.cpdp.dataprocessing." + 530 attributes.getValue("name")) 531 .newInstance(); 534 final IProcessesingStrategy processor = (IProcessesingStrategy) Class 535 .forName("de.ugoe.cs.cpdp.dataprocessing." + attributes.getValue("name")) 536 .newInstance(); 532 537 processor.setParameter(attributes.getValue("param")); 533 538 postprocessors.add(processor); 534 539 } 535 540 else if (qName.equals("trainer")) { 536 final ITrainingStrategy trainer = 537 (ITrainingStrategy) Class.forName("de.ugoe.cs.cpdp.training." + 538 attributes.getValue("name")) 539 .newInstance(); 541 final ITrainingStrategy trainer = (ITrainingStrategy) Class 542 .forName("de.ugoe.cs.cpdp.training." + attributes.getValue("name")) 543 .newInstance(); 540 544 trainer.setParameter(attributes.getValue("param")); 541 545 trainers.add(trainer); 542 546 } 543 547 else if (qName.equals("testawaretrainer")) { 544 final ITestAwareTrainingStrategy trainer = 545 (ITestAwareTrainingStrategy) Class.forName("de.ugoe.cs.cpdp.training." + 546 attributes.getValue("name")) 547 .newInstance(); 548 final ITestAwareTrainingStrategy trainer = (ITestAwareTrainingStrategy) Class 549 .forName("de.ugoe.cs.cpdp.training." + attributes.getValue("name")) 550 .newInstance(); 548 551 trainer.setParameter(attributes.getValue("param")); 549 552 testAwareTrainers.add(trainer); 550 553 } 551 554 else if (qName.equals("eval")) { 552 final IEvaluationStrategy evaluator = 553 (IEvaluationStrategy) Class.forName("de.ugoe.cs.cpdp.eval." + 554 attributes.getValue("name")) 555 .newInstance(); 555 final IEvaluationStrategy evaluator = (IEvaluationStrategy) Class 556 .forName("de.ugoe.cs.cpdp.eval." + attributes.getValue("name")).newInstance(); 556 557 evaluators.add(evaluator); 558 } 559 else if (qName.equals("storage")) { 560 final IResultStorage resultStorage = (IResultStorage) Class 561 .forName("de.ugoe.cs.cpdp.eval." + attributes.getValue("name")).newInstance(); 562 resultStorages.add(resultStorage); 557 563 } 558 564 else if (qName.equals("saveClassifier")) { … … 625 631 626 632 if (!executionStrategy.equals(other.executionStrategy)) { 627 throw new ExperimentConfigurationException( 628 "Executionstrategies must be the same, if config files should be added."); 633 throw new ExperimentConfigurationException("Executionstrategies must be the same, if config files should be added."); 629 634 } 630 635 … … 651 656 builder.append("Results path: " + resultsPath + StringTools.ENDLINE); 652 657 builder.append("Version filters: " + versionFilters.toString() + StringTools.ENDLINE); 653 builder .append("Test version filters: " + testVersionFilters.toString() +654 StringTools.ENDLINE);658 builder 659 .append("Test version filters: " + testVersionFilters.toString() + StringTools.ENDLINE); 655 660 builder.append("Training version filters: " + trainingVersionFilters.toString() + 656 661 StringTools.ENDLINE); … … 661 666 StringTools.ENDLINE); 662 667 builder.append("Setwise trainers: " + setwiseTrainers.toString() + StringTools.ENDLINE); 663 builder.append("Setwise Testdata Aware trainers: " + setwiseTestdataAwareTrainers.toString() + StringTools.ENDLINE); 668 builder.append("Setwise Testdata Aware trainers: " + 669 setwiseTestdataAwareTrainers.toString() + StringTools.ENDLINE); 664 670 builder 665 671 .append("Pointwise preprocessors: " + preprocessors.toString() + StringTools.ENDLINE); 666 builder .append("Pointwise selectors: " + pointwiseselectors.toString() +667 StringTools.ENDLINE);668 builder .append("Pointwise postprocessors: " + postprocessors.toString() +669 StringTools.ENDLINE);672 builder 673 .append("Pointwise selectors: " + pointwiseselectors.toString() + StringTools.ENDLINE); 674 builder 675 .append("Pointwise postprocessors: " + postprocessors.toString() + StringTools.ENDLINE); 670 676 builder.append("Pointwise trainers: " + trainers.toString() + StringTools.ENDLINE); 671 677 builder.append("Evaluators: " + evaluators.toString() + StringTools.ENDLINE); -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/AbstractWekaEvaluation.java
r63 r68 19 19 import java.io.PrintWriter; 20 20 import java.util.ArrayList; 21 import java.util.Iterator; 21 22 import java.util.LinkedList; 22 23 import java.util.List; … … 43 44 * <li>fscore</li> 44 45 * <li>gscore</li> 46 * <li>MCC</li> 45 47 * <li>AUC</li> 46 48 * <li>AUCEC (weighted by LOC, if applicable; 0.0 if LOC not available)</li> 47 49 * <li>tpr: true positive rate</li> 48 50 * <li>tnr: true negative rate</li> 51 * <li>fpr: false positive rate</li> 52 * <li>fnr: false negative rate</li> 49 53 * <li>tp: true positives</li> 50 54 * <li>fp: false positives</li> 51 55 * <li>tn: true negatives</li> 52 56 * <li>fn: false negatives</li> 53 * <li>errortrain: training error</li>54 * <li>recalltrain: training recall</li>55 * <li>precisiontrain: training precision</li>56 * <li>succHetrain: training success with recall>0.7 and precision>0.557 57 * </ul> 58 58 * … … 67 67 68 68 private boolean outputIsSystemOut = true; 69 70 private String configurationName = "default"; 69 71 70 72 /** 71 * Creates the weka evaluator. Allows the creation of the evaluator in different ways, e.g., for73 * Creates the Weka evaluator. Allows the creation of the evaluator in different ways, e.g., for 72 74 * cross-validation or evaluation on the test data. 73 75 * … … 90 92 Instances traindata, 91 93 List<ITrainer> trainers, 92 boolean writeHeader) 94 boolean writeHeader, 95 List<IResultStorage> storages) 93 96 { 94 final List<Classifier> classifiers = new LinkedList<Classifier>(); 97 final List<Classifier> classifiers = new LinkedList<>(); 98 final List<ExperimentResult> experimentResults = new LinkedList<>(); 99 String productName = testdata.relationName(); 100 95 101 for (ITrainer trainer : trainers) { 96 102 if (trainer instanceof IWekaCompatibleTrainer) { 97 103 classifiers.add(((IWekaCompatibleTrainer) trainer).getClassifier()); 104 experimentResults.add(new ExperimentResult(configurationName, productName, ((IWekaCompatibleTrainer) trainer).getName())); 98 105 } 99 106 else { … … 129 136 } 130 137 131 output.append( testdata.relationName());138 output.append(productName); 132 139 output.append("," + testdata.numInstances()); 133 140 output.append("," + traindata.numInstances()); 134 141 135 142 Evaluation eval = null; 136 //Evaluation evalTrain = null; 137 for (Classifier classifier : classifiers) { 143 Iterator<Classifier> classifierIter = classifiers.iterator(); 144 Iterator<ExperimentResult> resultIter = experimentResults.iterator(); 145 while (classifierIter.hasNext()) { 146 Classifier classifier = classifierIter.next(); 138 147 eval = createEvaluator(testdata, classifier); 139 //evalTrain = createEvaluator(traindata, classifier);140 148 141 149 double pf = … … 143 151 double gmeasure = 2 * eval.recall(1) * (1.0 - pf) / (eval.recall(1) + (1.0 - pf)); 144 152 double aucec = calculateReviewEffort(testdata, classifier); 145 146 if (eval.recall(1) >= 0.7 && eval.precision(1) >= 0.5) { 147 output.append(",1"); 148 } 149 else { 150 output.append(",0"); 151 } 152 153 if (eval.recall(1) >= 0.7 && eval.precision(1) >= 0.7) { 154 output.append(",1"); 155 } 156 else { 157 output.append(",0"); 158 } 159 160 if (gmeasure > 0.75) { 161 output.append(",1"); 162 } 163 else { 164 output.append(",0"); 165 } 166 167 if (gmeasure > 0.6) { 168 output.append(",1"); 169 } 170 else { 171 output.append(",0"); 172 } 173 153 double succHe = eval.recall(1) >= 0.7 && eval.precision(1) >= 0.5 ? 1.0 : 0.0; 154 double succZi = eval.recall(1) >= 0.7 && eval.precision(1) >= 0.7 ? 1.0 : 0.0; 155 double succG75 = gmeasure > 0.75 ? 1.0 : 0.0; 156 double succG60 = gmeasure > 0.6 ? 1.0 : 0.0; 157 158 output.append("," + succHe); 159 output.append("," + succZi); 160 output.append("," + succG75); 161 output.append("," + succG60); 174 162 output.append("," + eval.errorRate()); 175 163 output.append("," + eval.recall(1)); … … 188 176 output.append("," + eval.numTrueNegatives(1)); 189 177 output.append("," + eval.numFalsePositives(1)); 178 179 ExperimentResult result = resultIter.next(); 180 result.setSizeTestData(testdata.numInstances()); 181 result.setSizeTrainingData(traindata.numInstances()); 182 result.setSuccHe(succHe); 183 result.setSuccZi(succZi); 184 result.setSuccG75(succG75); 185 result.setSuccG60(succG60); 186 result.setError(eval.errorRate()); 187 result.setRecall(eval.recall(1)); 188 result.setPrecision(eval.precision(1)); 189 result.setFscore(eval.fMeasure(1)); 190 result.setGscore(gmeasure); 191 result.setMcc(eval.matthewsCorrelationCoefficient(1)); 192 result.setAuc(eval.areaUnderROC(1)); 193 result.setAucec(aucec); 194 result.setTpr(eval.truePositiveRate(1)); 195 result.setTnr(eval.trueNegativeRate(1)); 196 result.setFpr(eval.falsePositiveRate(1)); 197 result.setFnr(eval.falseNegativeRate(1)); 198 result.setTp(eval.numTruePositives(1)); 199 result.setFn(eval.numFalseNegatives(1)); 200 result.setTn(eval.numTrueNegatives(1)); 201 result.setFp(eval.numFalsePositives(1)); 202 for( IResultStorage storage : storages ) { 203 storage.addResult(result); 204 } 190 205 } 191 206 … … 301 316 output = new PrintWriter(new FileOutputStream(parameters)); 302 317 outputIsSystemOut = false; 318 int filenameStart = parameters.lastIndexOf('/')+1; 319 int filenameEnd = parameters.lastIndexOf('.'); 320 configurationName = parameters.substring(filenameStart, filenameEnd); 303 321 } 304 322 catch (FileNotFoundException e) { -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/IEvaluationStrategy.java
r41 r68 40 40 * @param writeHeader 41 41 * if true, a header line for the results file is written (may not be applicable) 42 * @param storages 43 * result storages that shall additionally be used 42 44 */ 43 void apply(Instances testdata, Instances traindata, List<ITrainer> trainers, boolean writeHeader); 45 void apply(Instances testdata, 46 Instances traindata, 47 List<ITrainer> trainers, 48 boolean writeHeader, 49 List<IResultStorage> storages); 44 50 } -
trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/AbstractCrossProjectExperiment.java
r67 r68 299 299 config.getExperimentName() + ".csv"); 300 300 } 301 evaluator.apply(testdata, traindata, allTrainers, writeHeader );301 evaluator.apply(testdata, traindata, allTrainers, writeHeader, config.getResultStorages()); 302 302 writeHeader = false; 303 303 } -
trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/ClassifierCreationExperiment.java
r41 r68 168 168 config.getExperimentName() + ".csv"); 169 169 } 170 evaluator.apply(testdata, traindata, allTrainers, writeHeader );170 evaluator.apply(testdata, traindata, allTrainers, writeHeader, config.getResultStorages()); 171 171 writeHeader = false; 172 172 }
Note: See TracChangeset
for help on using the changeset viewer.