Changeset 135 for trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Timestamp:
- 07/18/16 12:26:03 (8 years ago)
- Location:
- trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Files:
-
- 5 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); -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/CVWekaEvaluation.java
r86 r135 31 31 public class CVWekaEvaluation extends AbstractWekaEvaluation { 32 32 33 /* *33 /* 34 34 * @see de.ugoe.cs.cpdp.eval.AbstractWekaEvaluation#createEvaluator(weka.core.Instances, 35 35 * weka.classifiers.Classifier) -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/ExperimentResult.java
r68 r135 1 1 2 package de.ugoe.cs.cpdp.eval; 2 3 4 /** 5 * <p> 6 * Data class to store experiment results 7 * </p> 8 * 9 * @author Steffen Herbold 10 */ 3 11 public class ExperimentResult { 4 12 13 /** 14 * configuration name of the experiment 15 */ 5 16 private final String configurationName; 17 18 /** 19 * name of the target product 20 */ 6 21 private final String productName; 22 23 /** 24 * name of the classifier used 25 */ 7 26 private final String classifier; 8 27 28 /** 29 * number of instances of the target product 30 */ 31 int sizeTestData; 32 33 /** 34 * number of instances of the training data 35 */ 36 int sizeTrainingData; 37 38 /** 39 * error of the prediction 40 */ 41 double error = Double.NaN; 42 43 /** 44 * recall of the prediction 45 */ 46 double recall = Double.NaN; 47 48 /** 49 * precision of the prediction 50 */ 51 double precision = Double.NaN; 52 53 /** 54 * F1 score of the prediction 55 */ 56 double fscore = Double.NaN; 57 58 /** 59 * G score of the prediction 60 */ 61 double gscore = Double.NaN; 62 63 /** 64 * Matthews correlation coefficient of the prediction 65 */ 66 double mcc = Double.NaN; 67 68 /** 69 * Area under the curve of the prediction 70 */ 71 double auc = Double.NaN; 72 73 /** 74 * Effort of the prediction 75 */ 76 double aucec = Double.NaN; 77 78 /** 79 * True positive rate of the prediction 80 */ 81 double tpr = Double.NaN; 82 83 /** 84 * True negative rate of the prediction 85 */ 86 double tnr = Double.NaN; 87 88 /** 89 * false positive rate of the prediction 90 */ 91 double fpr = Double.NaN; 92 93 /** 94 * false negative rate of the prediction 95 */ 96 double fnr = Double.NaN; 97 98 /** 99 * number of true positives 100 */ 101 double tp = Double.NaN; 102 103 /** 104 * number of false negatives 105 */ 106 double fn = Double.NaN; 107 108 /** 109 * number of true negatives 110 */ 111 double tn = Double.NaN; 112 113 /** 114 * number of false positives 115 */ 116 double fp = Double.NaN; 117 118 /** 119 * <p> 120 * Constructor. Creates a new ExperimentResult. 121 * </p> 122 * 123 * @param configurationName 124 * the configuration name 125 * @param productName 126 * the product name 127 * @param classifier 128 * the classifier name 129 */ 9 130 public ExperimentResult(String configurationName, String productName, String classifier) { 10 131 this.configurationName = configurationName; … … 12 133 this.classifier = classifier; 13 134 } 14 15 int sizeTestData; 16 int sizeTrainingData; 17 double succHe = Double.NaN; 18 double succZi = Double.NaN; 19 double succG75 = Double.NaN; 20 double succG60 = Double.NaN; 21 double error = Double.NaN; 22 double recall = Double.NaN; 23 double precision = Double.NaN; 24 double fscore = Double.NaN; 25 double gscore = Double.NaN; 26 double mcc = Double.NaN; 27 double auc = Double.NaN; 28 double aucec = Double.NaN; 29 double tpr = Double.NaN; 30 double tnr = Double.NaN; 31 double fpr = Double.NaN; 32 double fnr = Double.NaN; 33 double tp = Double.NaN; 34 double fn = Double.NaN; 35 double tn = Double.NaN; 36 double fp = Double.NaN; 37 135 136 /** 137 * <p> 138 * returns the configuration name 139 * </p> 140 * 141 * @return the configuration name 142 */ 38 143 public String getConfigurationName() { 39 144 return configurationName; 40 145 } 146 147 /** 148 * <p> 149 * returns the product name 150 * </p> 151 * 152 * @return the product name 153 */ 41 154 public String getProductName() { 42 155 return productName; 43 156 } 157 158 /** 159 * <p> 160 * returns the classifier name 161 * </p> 162 * 163 * @return the classifier name 164 */ 44 165 public String getClassifier() { 45 166 return classifier; 46 167 } 168 169 /** 170 * <p> 171 * returns the number of instances of the target product 172 * </p> 173 * 174 * @return number of instances 175 */ 47 176 public int getSizeTestData() { 48 177 return sizeTestData; 49 178 } 179 180 /** 181 * <p> 182 * sets the number of instances of the target product 183 * </p> 184 * 185 * @param sizeTestData 186 * number of instances 187 */ 50 188 public void setSizeTestData(int sizeTestData) { 51 189 this.sizeTestData = sizeTestData; 52 190 } 191 192 /** 193 * <p> 194 * returns the number of instances of the training data 195 * </p> 196 * 197 * @return number of instances 198 */ 53 199 public int getSizeTrainingData() { 54 200 return sizeTrainingData; 55 201 } 202 203 /** 204 * <p> 205 * sets the number of instances of the training data 206 * </p> 207 * 208 * @param sizeTrainingData 209 * number of instances 210 */ 56 211 public void setSizeTrainingData(int sizeTrainingData) { 57 212 this.sizeTrainingData = sizeTrainingData; 58 213 } 59 public double getSuccHe() { 60 return succHe; 61 } 62 public void setSuccHe(double succHe) { 63 this.succHe = succHe; 64 } 65 public double getSuccZi() { 66 return succZi; 67 } 68 public void setSuccZi(double succZi) { 69 this.succZi = succZi; 70 } 71 public double getSuccG75() { 72 return succG75; 73 } 74 public void setSuccG75(double succG75) { 75 this.succG75 = succG75; 76 } 77 public double getSuccG60() { 78 return succG60; 79 } 80 public void setSuccG60(double succG60) { 81 this.succG60 = succG60; 82 } 214 215 /** 216 * <p> 217 * returns the error 218 * </p> 219 * 220 * @return the error 221 */ 83 222 public double getError() { 84 223 return error; 85 224 } 225 226 /** 227 * <p> 228 * sets the error 229 * </p> 230 * 231 * @param error 232 * the error 233 */ 86 234 public void setError(double error) { 87 235 this.error = error; 88 236 } 237 238 /** 239 * <p> 240 * returns the recall 241 * </p> 242 * 243 * @return the recall 244 */ 89 245 public double getRecall() { 90 246 return recall; 91 247 } 248 249 /** 250 * <p> 251 * sets the recall 252 * </p> 253 * 254 * @param recall 255 * the recall 256 */ 92 257 public void setRecall(double recall) { 93 258 this.recall = recall; 94 259 } 260 261 /** 262 * <p> 263 * returns the precision 264 * </p> 265 * 266 * @return the precision 267 */ 95 268 public double getPrecision() { 96 269 return precision; 97 270 } 271 272 /** 273 * <p> 274 * sets the precision 275 * </p> 276 * 277 * @param precision 278 * the precision 279 */ 98 280 public void setPrecision(double precision) { 99 281 this.precision = precision; 100 282 } 283 284 /** 285 * <p> 286 * returns the F1 score 287 * </p> 288 * 289 * @return the F1 score 290 */ 101 291 public double getFscore() { 102 292 return fscore; 103 293 } 294 295 /** 296 * <p> 297 * sets the F1 score 298 * </p> 299 * 300 * @param fscore 301 * the F1 score 302 */ 104 303 public void setFscore(double fscore) { 105 304 this.fscore = fscore; 106 305 } 306 307 /** 308 * <p> 309 * returns the G score 310 * </p> 311 * 312 * @return the G score 313 */ 107 314 public double getGscore() { 108 315 return gscore; 109 316 } 317 318 /** 319 * <p> 320 * sets the G score 321 * </p> 322 * 323 * @param gscore 324 * the G score 325 */ 110 326 public void setGscore(double gscore) { 111 327 this.gscore = gscore; 112 328 } 329 330 /** 331 * <p> 332 * returns the MCC 333 * </p> 334 * 335 * @return the MCC 336 */ 113 337 public double getMcc() { 114 338 return mcc; 115 339 } 340 341 /** 342 * <p> 343 * sets the MCC 344 * </p> 345 * 346 * @param mcc 347 * the MCC 348 */ 116 349 public void setMcc(double mcc) { 117 350 this.mcc = mcc; 118 351 } 352 353 /** 354 * <p> 355 * returns the AUC 356 * </p> 357 * 358 * @return the AUC 359 */ 119 360 public double getAuc() { 120 361 return auc; 121 362 } 363 364 /** 365 * <p> 366 * sets the AUC 367 * </p> 368 * 369 * @param auc 370 * the AUC 371 */ 122 372 public void setAuc(double auc) { 123 373 this.auc = auc; 124 374 } 375 376 /** 377 * <p> 378 * returns the effort as AUCEC 379 * </p> 380 * 381 * @return the effort 382 */ 125 383 public double getAucec() { 126 384 return aucec; 127 385 } 386 387 /** 388 * <p> 389 * sets the effort as AUCEC 390 * </p> 391 * 392 * @param aucec 393 * the effort 394 */ 128 395 public void setAucec(double aucec) { 129 396 this.aucec = aucec; 130 397 } 398 399 /** 400 * <p> 401 * returns the TPR 402 * </p> 403 * 404 * @return the TPR 405 */ 131 406 public double getTpr() { 132 407 return tpr; 133 408 } 409 410 /** 411 * <p> 412 * sets the TPR 413 * </p> 414 * 415 * @param tpr 416 * the TPR 417 */ 134 418 public void setTpr(double tpr) { 135 419 this.tpr = tpr; 136 420 } 421 422 /** 423 * <p> 424 * sets the TNR 425 * </p> 426 * 427 * @return the TNR 428 */ 137 429 public double getTnr() { 138 430 return tnr; 139 431 } 432 433 /** 434 * <p> 435 * sets the TNR 436 * </p> 437 * 438 * @param tnr 439 * the TNR 440 */ 140 441 public void setTnr(double tnr) { 141 442 this.tnr = tnr; 142 443 } 444 445 /** 446 * <p> 447 * returns the FPR 448 * </p> 449 * 450 * @return the FPR 451 */ 143 452 public double getFpr() { 144 453 return fpr; 145 454 } 455 456 /** 457 * <p> 458 * sets the FPR 459 * </p> 460 * 461 * @param fpr 462 * the FPR 463 */ 146 464 public void setFpr(double fpr) { 147 465 this.fpr = fpr; 148 466 } 467 468 /** 469 * <p> 470 * returns the FNR 471 * </p> 472 * 473 * @return the FNR 474 */ 149 475 public double getFnr() { 150 476 return fnr; 151 477 } 478 479 /** 480 * <p> 481 * sets the FNR 482 * </p> 483 * 484 * @param fnr 485 * the FNR 486 */ 152 487 public void setFnr(double fnr) { 153 488 this.fnr = fnr; 154 489 } 490 491 /** 492 * <p> 493 * returns the TPs 494 * </p> 495 * 496 * @return the TPs 497 */ 155 498 public double getTp() { 156 499 return tp; 157 500 } 501 502 /** 503 * <p> 504 * sets the TPs 505 * </p> 506 * 507 * @param tp 508 * the TPs 509 */ 158 510 public void setTp(double tp) { 159 511 this.tp = tp; 160 512 } 513 514 /** 515 * <p> 516 * returns the FNs 517 * </p> 518 * 519 * @return the FNs 520 */ 161 521 public double getFn() { 162 522 return fn; 163 523 } 524 525 /** 526 * <p> 527 * sets the FNs 528 * </p> 529 * 530 * @param fn 531 */ 164 532 public void setFn(double fn) { 165 533 this.fn = fn; 166 534 } 535 536 /** 537 * <p> 538 * returns the TNs 539 * </p> 540 * 541 * @return the TNs 542 */ 167 543 public double getTn() { 168 544 return tn; 169 545 } 546 547 /** 548 * <p> 549 * sets the TNs 550 * </p> 551 * 552 * @param tn 553 * the TNs 554 */ 170 555 public void setTn(double tn) { 171 556 this.tn = tn; 172 557 } 558 559 /** 560 * <p> 561 * returns the FPs 562 * </p> 563 * 564 * @return the FPs 565 */ 173 566 public double getFp() { 174 567 return fp; 175 568 } 569 570 /** 571 * <p> 572 * sets the FPs 573 * </p> 574 * 575 * @param fp 576 * the FPs 577 */ 176 578 public void setFp(double fp) { 177 579 this.fp = fp; -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/MySQLResultStorage.java
r121 r135 22 22 import java.util.Properties; 23 23 24 25 24 import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; 26 25 … … 37 36 public class MySQLResultStorage implements IResultStorage { 38 37 39 /**40 * Connection to the database41 */42 //private Connection con = null;43 44 38 /** 45 39 * Connection pool for the data base. … … 121 115 sql.append(result.getSizeTestData() + ","); 122 116 sql.append(result.getSizeTrainingData() + ","); 123 sql.append(result.getSuccHe() + ",");124 sql.append(result.getSuccZi() + ",");125 sql.append(result.getSuccG75() + ",");126 sql.append(result.getSuccG60() + ",");127 117 sql.append(result.getError() + ","); 128 118 sql.append(result.getRecall() + ","); … … 164 154 public int containsResult(String experimentName, String productName, String classifierName) { 165 155 String sql = "SELECT COUNT(*) as cnt FROM crosspare.results WHERE configurationName=\'" + 166 experimentName + "\' AND productName=\'" + productName + "\' AND classifier=\'" + classifierName + "\';"; 156 experimentName + "\' AND productName=\'" + productName + "\' AND classifier=\'" + 157 classifierName + "\';"; 167 158 Statement stmt; 168 159 try { -
trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/NormalWekaEvaluation.java
r86 r135 27 27 public class NormalWekaEvaluation extends AbstractWekaEvaluation { 28 28 29 /* *29 /* 30 30 * @see de.ugoe.cs.cpdp.eval.AbstractWekaEvaluation#createEvaluator(weka.core.Instances, 31 * 31 * weka.classifiers.Classifier) 32 32 */ 33 33 @Override
Note: See TracChangeset
for help on using the changeset viewer.