From: <jen...@us...> - 2009-12-19 10:54:53
|
Revision: 1934 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1934&view=rev Author: jenslehmann Date: 2009-12-19 10:54:30 +0000 (Sat, 19 Dec 2009) Log Message: ----------- implemented predictive accuracy for class learning (for evaluation purposes) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-19 09:52:58 UTC (rev 1933) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-19 10:54:30 UTC (rev 1934) @@ -100,7 +100,7 @@ DoubleConfigOption approxAccuracy = new DoubleConfigOption("approxAccuracy", "accuracy of the approximation (only for expert use)", 0.05); options.add(approxAccuracy); StringConfigOption accMethod = new StringConfigOption("accuracyMethod", "Specifies, which method/function to use for computing accuracy.","standard"); // or domain/range of a property. - accMethod.setAllowedValues(new String[] {"standard", "fmeasure", "predacc", "generalised_fmeasure", "jaccard"}); + accMethod.setAllowedValues(new String[] {"standard", "fmeasure", "pred_acc", "generalised_fmeasure", "jaccard"}); options.add(accMethod); return options; } @@ -123,7 +123,7 @@ heuristic = HeuristicType.GEN_FMEASURE; } else if(accM.equals("jaccard")) { heuristic = HeuristicType.JACCARD; - } else if(accM.equals("predacc")) { + } else if(accM.equals("pred_acc")) { heuristic = HeuristicType.PRED_ACC; } @@ -437,7 +437,7 @@ Set<Individual> union = Helper.union(classInstancesSet, additionalInstancesSet); return (1 - (union.size() - coveredInstancesSet.size()) / (double) union.size()); - } else if (heuristic.equals(HeuristicType.OWN) || heuristic.equals(HeuristicType.FMEASURE)) { + } else if (heuristic.equals(HeuristicType.OWN) || heuristic.equals(HeuristicType.FMEASURE) || heuristic.equals(HeuristicType.PRED_ACC)) { // computing R(C) restricted to relevant instances int additionalInstances = 0; @@ -462,8 +462,17 @@ } double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); - - return heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, precision) : getAccuracy(recall, precision); + + if(heuristic.equals(HeuristicType.OWN)) { + return getAccuracy(recall, precision); + } else if(heuristic.equals(HeuristicType.FMEASURE)) { + return getFMeasure(recall, precision); + } else if(heuristic.equals(HeuristicType.PRED_ACC)) { + // correctly classified divided by all examples + return (coveredInstances + superClassInstances.size() - additionalInstances) / (double) (classInstances.size() + superClassInstances.size()); + } + +// return heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, precision) : getAccuracy(recall, precision); } throw new Error("ClassLearningProblem error: not implemented"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |