- Timestamp:
- 07/18/16 12:26:03 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/AbstractWekaEvaluation.java
r132 r135 36 36 * <ul> 37 37 * <li>succHe: Success with recall>0.7, precision>0.5</li> 38 * <li>succZi: Success with recall> 0.7, precision>0.7</li>38 * <li>succZi: Success with recall>=0.75, precision>=0.7, and error<=0.25</li> 39 39 * <li>succG75: Success with gscore>0.75</li> 40 40 * <li>succG60: Success with gscore>0.6</li> … … 66 66 private PrintWriter output = new PrintWriter(System.out); 67 67 68 /** 69 * flag that defines if the output is the system out 70 */ 68 71 private boolean outputIsSystemOut = true; 69 72 73 /** 74 * name of the configuration 75 */ 70 76 private String configurationName = "default"; 71 77 … … 92 98 Instances traindata, 93 99 List<ITrainer> trainers, 94 List<Double> efforts, 100 List<Double> efforts, 95 101 boolean writeHeader, 96 102 List<IResultStorage> storages) … … 99 105 final List<ExperimentResult> experimentResults = new LinkedList<>(); 100 106 String productName = testdata.relationName(); 101 107 102 108 for (ITrainer trainer : trainers) { 103 109 if (trainer instanceof IWekaCompatibleTrainer) { 104 110 classifiers.add(((IWekaCompatibleTrainer) trainer).getClassifier()); 105 experimentResults.add(new ExperimentResult(configurationName, productName, ((IWekaCompatibleTrainer) trainer).getName())); 111 experimentResults 112 .add(new ExperimentResult(configurationName, productName, 113 ((IWekaCompatibleTrainer) trainer).getName())); 106 114 } 107 115 else { … … 153 161 double aucec = calculateReviewEffort(testdata, classifier, efforts); 154 162 double succHe = eval.recall(1) >= 0.7 && eval.precision(1) >= 0.5 ? 1.0 : 0.0; 155 double succZi = eval.recall(1) >= 0.7 && eval.precision(1) >= 0.7? 1.0 : 0.0;163 double succZi = eval.recall(1) >= 0.75 && eval.precision(1) >= 0.75 && eval.errorRate()<=0.25 ? 1.0 : 0.0; 156 164 double succG75 = gmeasure > 0.75 ? 1.0 : 0.0; 157 165 double succG60 = gmeasure > 0.6 ? 1.0 : 0.0; 158 166 159 167 output.append("," + succHe); 160 168 output.append("," + succZi); 161 169 output.append("," + succG75); 162 output.append("," + succG60); 170 output.append("," + succG60); 163 171 output.append("," + eval.errorRate()); 164 172 output.append("," + eval.recall(1)); … … 177 185 output.append("," + eval.numTrueNegatives(1)); 178 186 output.append("," + eval.numFalsePositives(1)); 179 187 180 188 ExperimentResult result = resultIter.next(); 181 189 result.setSizeTestData(testdata.numInstances()); 182 190 result.setSizeTrainingData(traindata.numInstances()); 183 result.setSuccHe(succHe);184 result.setSuccZi(succZi);185 result.setSuccG75(succG75);186 result.setSuccG60(succG60);187 191 result.setError(eval.errorRate()); 188 192 result.setRecall(eval.recall(1)); … … 201 205 result.setTn(eval.numTrueNegatives(1)); 202 206 result.setFp(eval.numFalsePositives(1)); 203 for ( IResultStorage storage : storages) {207 for (IResultStorage storage : storages) { 204 208 storage.addResult(result); 205 209 } … … 209 213 output.flush(); 210 214 } 211 212 private double calculateReviewEffort(Instances testdata, Classifier classifier, List<Double> efforts) { 213 if( efforts==null ) { 215 216 /** 217 * <p> 218 * Calculates the effort. TODO: IMPLEMENTATION BUGGY! MUST BE FIXED! 219 * </p> 220 * 221 * @param testdata 222 * the test data 223 * @param classifier 224 * the classifier 225 * @param efforts 226 * the effort information for each instance in the test data 227 * @return 228 */ 229 private double calculateReviewEffort(Instances testdata, 230 Classifier classifier, 231 List<Double> efforts) 232 { 233 if (efforts == null) { 214 234 return 0; 215 235 } 216 236 217 237 final List<Integer> bugPredicted = new ArrayList<>(); 218 238 final List<Integer> nobugPredicted = new ArrayList<>(); … … 229 249 } 230 250 catch (Exception e) { 231 throw new RuntimeException( 232 "unexpected error during the evaluation of the review effort", 251 throw new RuntimeException("unexpected error during the evaluation of the review effort", 233 252 e); 234 253 } … … 297 316 } 298 317 318 /** 319 * <p> 320 * Calculates effort. Deprecated. Do not use! 321 * </p> 322 * 323 * @param testdata 324 * the test data 325 * @param classifier 326 * the classifier 327 * @return 328 */ 299 329 @SuppressWarnings("unused") 300 330 @Deprecated … … 315 345 loc = testdata.attribute("CountLineCodeExe"); 316 346 } 317 if ( loc == null) {347 if (loc == null) { 318 348 return 0.0; 319 349 } … … 333 363 } 334 364 catch (Exception e) { 335 throw new RuntimeException( 336 "unexpected error during the evaluation of the review effort", 365 throw new RuntimeException("unexpected error during the evaluation of the review effort", 337 366 e); 338 367 } … … 419 448 output = new PrintWriter(new FileOutputStream(parameters)); 420 449 outputIsSystemOut = false; 421 int filenameStart = parameters.lastIndexOf('/') +1;450 int filenameStart = parameters.lastIndexOf('/') + 1; 422 451 int filenameEnd = parameters.lastIndexOf('.'); 423 452 configurationName = parameters.substring(filenameStart, filenameEnd);
Note: See TracChangeset
for help on using the changeset viewer.