From: <jen...@us...> - 2009-12-28 11:43:04
|
Revision: 1957 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1957&view=rev Author: jenslehmann Date: 2009-12-28 11:42:54 +0000 (Mon, 28 Dec 2009) Log Message: ----------- Introduced option to turn off convenience consistency checks in class learning problems (they are often useful, but can be time consuming.) Use "classLearning.checkConsistency = false;" to turn the checks off (they are turned on by default). Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -99,6 +99,15 @@ public String getAccuracyMethod() { return (String) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "accuracyMethod") ; } +/** +* checkConsistency Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getCheckConsistency() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "checkConsistency") ; +} /** * @param classToDescribe class of which a description should be learned. @@ -144,6 +153,15 @@ ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "accuracyMethod", accuracyMethod); reinitNecessary = true; } +/** +* @param checkConsistency Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setCheckConsistency(boolean checkConsistency) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "checkConsistency", checkConsistency); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -112,6 +112,8 @@ 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", "pred_acc", "generalised_fmeasure", "jaccard"}); options.add(accMethod); + BooleanConfigOption consistency = new BooleanConfigOption("checkConsistency", "Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.", true); + options.add(consistency); return options; } @@ -229,13 +231,6 @@ // for each description with less than 100% coverage, we check whether it is // leads to an inconsistent knowledge base - // workaround due to a bug (see http://sourceforge.net/tracker/?func=detail&aid=2866610&group_id=203619&atid=986319) -// boolean isConsistent = coverage >= 0.999999 || isConsistent(description); - boolean isConsistent = isConsistent(description); - - // we check whether the axiom already follows from the knowledge base - boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); - double acc = 0; if(heuristic.equals(HeuristicType.FMEASURE)) { acc = getFMeasure(coverage, protusion); @@ -246,8 +241,23 @@ // move accuracy computation here if possible acc = getAccuracyOrTooWeakExact(description, 1); } -// double acc = useFMeasure ? getFMeasure(coverage, protusion) : getAccuracy(coverage, protusion); - return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc, isConsistent, followsFromKB); + + if(configurator.getCheckConsistency()) { + + // we check whether the axiom already follows from the knowledge base + boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); + + // workaround due to a bug (see http://sourceforge.net/tracker/?func=detail&aid=2866610&group_id=203619&atid=986319) +// boolean isConsistent = coverage >= 0.999999 || isConsistent(description); + // (if the axiom follows, then the knowledge base remains consistent) + boolean isConsistent = followsFromKB || isConsistent(description); + +// double acc = useFMeasure ? getFMeasure(coverage, protusion) : getAccuracy(coverage, protusion); + return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc, isConsistent, followsFromKB); + + } else { + return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc); + } } public boolean isEquivalenceProblem() { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -49,13 +49,17 @@ private boolean isConsistent; private boolean followsFromKB; - public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy, boolean isConsistent, boolean followsFromKB) { + public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy) { this.coveredInstances = coveredInstances; this.notCoveredInstances = notCoveredInstances; this.additionalInstances = additionalInstances; this.coverage = coverage; this.addition = protusion; this.accuracy = accuracy; + } + + public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy, boolean isConsistent, boolean followsFromKB) { + this(coveredInstances, notCoveredInstances, coverage, additionalInstances, protusion, accuracy); this.isConsistent = isConsistent; this.followsFromKB = followsFromKB; } @@ -107,6 +111,14 @@ return additionalInstances; } + public void setConsistent(boolean isConsistent) { + this.isConsistent = isConsistent; + } + + public void setFollowsFromKB(boolean followsFromKB) { + this.followsFromKB = followsFromKB; + } + /** * @return the isConsistent */ Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -115,6 +115,14 @@ return classScore.followsFromKB(); } + public void setConsistent(boolean isConsistent) { + classScore.setConsistent(isConsistent); + } + + public void setFollowsFromKB(boolean followsFromKB) { + classScore.setFollowsFromKB(followsFromKB); + } + /** * This convenience method can be used to store and exchange evaluated * descriptions by transforming them to a JSON string. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |