Changeset 68 for trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Timestamp:
- 05/03/16 10:30:09 (9 years ago)
- Location:
- trunk/CrossPare/src/de/ugoe/cs/cpdp/eval
- Files:
-
- 3 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.