Changeset 132 for trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Timestamp:
- 06/28/16 12:01:39 (8 years ago)
- Location:
- trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/AbstractWekaEvaluation.java
r118 r132 92 92 Instances traindata, 93 93 List<ITrainer> trainers, 94 List<Double> efforts, 94 95 boolean writeHeader, 95 96 List<IResultStorage> storages) … … 150 151 eval.numFalsePositives(1) / (eval.numFalsePositives(1) + eval.numTrueNegatives(1)); 151 152 double gmeasure = 2 * eval.recall(1) * (1.0 - pf) / (eval.recall(1) + (1.0 - pf)); 152 double aucec = calculateReviewEffort(testdata, classifier );153 double aucec = calculateReviewEffort(testdata, classifier, efforts); 153 154 double succHe = eval.recall(1) >= 0.7 && eval.precision(1) >= 0.5 ? 1.0 : 0.0; 154 155 double succZi = eval.recall(1) >= 0.7 && eval.precision(1) >= 0.7 ? 1.0 : 0.0; … … 208 209 output.flush(); 209 210 } 210 211 212 private double calculateReviewEffort(Instances testdata, Classifier classifier, List<Double> efforts) { 213 if( efforts==null ) { 214 return 0; 215 } 216 217 final List<Integer> bugPredicted = new ArrayList<>(); 218 final List<Integer> nobugPredicted = new ArrayList<>(); 219 double totalLoc = 0.0d; 220 int totalBugs = 0; 221 for (int i = 0; i < testdata.numInstances(); i++) { 222 try { 223 if (Double.compare(classifier.classifyInstance(testdata.instance(i)), 0.0d) == 0) { 224 nobugPredicted.add(i); 225 } 226 else { 227 bugPredicted.add(i); 228 } 229 } 230 catch (Exception e) { 231 throw new RuntimeException( 232 "unexpected error during the evaluation of the review effort", 233 e); 234 } 235 if (Double.compare(testdata.instance(i).classValue(), 1.0d) == 0) { 236 totalBugs++; 237 } 238 totalLoc += efforts.get(i); 239 } 240 241 final List<Double> reviewLoc = new ArrayList<>(testdata.numInstances()); 242 final List<Double> bugsFound = new ArrayList<>(testdata.numInstances()); 243 244 double currentBugsFound = 0; 245 246 while (!bugPredicted.isEmpty()) { 247 double minLoc = Double.MAX_VALUE; 248 int minIndex = -1; 249 for (int i = 0; i < bugPredicted.size(); i++) { 250 double currentLoc = efforts.get(bugPredicted.get(i)); 251 if (currentLoc < minLoc) { 252 minIndex = i; 253 minLoc = currentLoc; 254 } 255 } 256 if (minIndex != -1) { 257 reviewLoc.add(minLoc / totalLoc); 258 259 currentBugsFound += testdata.instance(bugPredicted.get(minIndex)).classValue(); 260 bugsFound.add(currentBugsFound); 261 262 bugPredicted.remove(minIndex); 263 } 264 else { 265 throw new RuntimeException("Shouldn't happen!"); 266 } 267 } 268 269 while (!nobugPredicted.isEmpty()) { 270 double minLoc = Double.MAX_VALUE; 271 int minIndex = -1; 272 for (int i = 0; i < nobugPredicted.size(); i++) { 273 double currentLoc = efforts.get(nobugPredicted.get(i)); 274 if (currentLoc < minLoc) { 275 minIndex = i; 276 minLoc = currentLoc; 277 } 278 } 279 if (minIndex != -1) { 280 reviewLoc.add(minLoc / totalLoc); 281 282 currentBugsFound += testdata.instance(nobugPredicted.get(minIndex)).classValue(); 283 bugsFound.add(currentBugsFound); 284 nobugPredicted.remove(minIndex); 285 } 286 else { 287 throw new RuntimeException("Shouldn't happen!"); 288 } 289 } 290 291 double auc = 0.0; 292 for (int i = 0; i < bugsFound.size(); i++) { 293 auc += reviewLoc.get(i) * bugsFound.get(i) / totalBugs; 294 } 295 296 return auc; 297 } 298 299 @SuppressWarnings("unused") 300 @Deprecated 211 301 private double calculateReviewEffort(Instances testdata, Classifier classifier) { 212 302 -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/IEvaluationStrategy.java
r86 r132 46 46 Instances traindata, 47 47 List<ITrainer> trainers, 48 List<Double> efforts, 48 49 boolean writeHeader, 49 50 List<IResultStorage> storages);
Note: See TracChangeset
for help on using the changeset viewer.