From: <jen...@us...> - 2010-02-10 10:50:49
|
Revision: 2003 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2003&view=rev Author: jenslehmann Date: 2010-02-10 10:50:42 +0000 (Wed, 10 Feb 2010) Log Message: ----------- included option in CELOE to filter out all suggestions, which already logically follow from the knowledge base Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosNeg.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosOnly.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosNeg.java trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosOnly.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -21,7 +21,6 @@ import java.text.DecimalFormat; import java.util.Collection; -import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -119,6 +118,7 @@ // important parameters private double noise; private double maxDepth; + private boolean filterFollowsFromKB; // utility variables private String baseURI; @@ -166,6 +166,8 @@ options.add(CommonConfigOptions.maxNrOfResults(10)); options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false)); options.add(CommonConfigOptions.getInstanceBasedDisjoints()); + options.add(new BooleanConfigOption("filterDescriptionsFollowingFromKB", "If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions.", false)); + options.add(new BooleanConfigOption("reuseExistingDescription", "If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base.", false)); return options; } @@ -193,11 +195,18 @@ bestEvaluatedDescriptions = new EvaluatedDescriptionSet(configurator.getMaxNrOfResults()); + isClassLearningProblem = (learningProblem instanceof ClassLearningProblem); + // we put important parameters in class variables noise = configurator.getNoisePercentage()/100d; - maxDepth = configurator.getMaxDepth(); + maxDepth = configurator.getMaxDepth(); + // (filterFollowsFromKB is automatically set to false if the problem + // is not a class learning problem + filterFollowsFromKB = configurator.getFilterDescriptionsFollowingFromKB() + && isClassLearningProblem; - isClassLearningProblem = (learningProblem instanceof ClassLearningProblem); + System.out.println("filter follows from KB: " + filterFollowsFromKB); + // actions specific to ontology engineering if(isClassLearningProblem) { ClassLearningProblem problem = (ClassLearningProblem) learningProblem; @@ -264,8 +273,8 @@ int loop = 0; while (!terminationCriteriaSatisfied()) { - if(!singleSuggestionMode && bestEvaluatedDescriptions.getBest().getAccuracy() > highestAccuracy) { - highestAccuracy = bestEvaluatedDescriptions.getBest().getAccuracy(); + if(!singleSuggestionMode && bestEvaluatedDescriptions.getBestAccuracy() > highestAccuracy) { + highestAccuracy = bestEvaluatedDescriptions.getBestAccuracy(); logger.info("more accurate (" + dfPercent.format(highestAccuracy) + ") class expression found: " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription())); } @@ -442,8 +451,9 @@ } if(!shorterDescriptionExists) { -// System.out.println(niceDescription + " acc " + accuracy); - bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); + if(!filterFollowsFromKB || !((ClassLearningProblem)learningProblem).followsFromKB(niceDescription)) { + bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); + } } } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -201,6 +201,24 @@ public boolean getInstanceBasedDisjoints() { return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "instanceBasedDisjoints") ; } +/** +* filterDescriptionsFollowingFromKB If true, then the results will not contain suggestions, which already follow logically from the knowledge base.. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getFilterDescriptionsFollowingFromKB() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "filterDescriptionsFollowingFromKB") ; +} +/** +* reuseExistingDescription If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base.. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getReuseExistingDescription() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "reuseExistingDescription") ; +} /** * @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. @@ -346,6 +364,24 @@ ComponentManager.getInstance().applyConfigEntry(cELOE, "instanceBasedDisjoints", instanceBasedDisjoints); reinitNecessary = true; } +/** +* @param filterDescriptionsFollowingFromKB If true, then the results will not contain suggestions, which already follow logically from the knowledge base.. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setFilterDescriptionsFollowingFromKB(boolean filterDescriptionsFollowingFromKB) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "filterDescriptionsFollowingFromKB", filterDescriptionsFollowingFromKB); +reinitNecessary = true; +} +/** +* @param reuseExistingDescription If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base.. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setReuseExistingDescription(boolean reuseExistingDescription) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "reuseExistingDescription", reuseExistingDescription); +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 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -28,7 +28,6 @@ import java.util.TreeSet; import org.apache.log4j.Logger; -import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.ComponentInitException; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; @@ -250,7 +249,8 @@ // we check whether the axiom already follows from the knowledge base // boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); - boolean followsFromKB = equivalence ? reasoner.isEquivalentClass(description, classToDescribe) : reasoner.isSuperClassOf(description, classToDescribe); +// boolean followsFromKB = equivalence ? reasoner.isEquivalentClass(description, classToDescribe) : reasoner.isSuperClassOf(description, classToDescribe); + boolean followsFromKB = followsFromKB(description); // 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); @@ -772,4 +772,8 @@ } return reasoner.remainsSatisfiable(axiom); } + + public boolean followsFromKB(Description description) { + return equivalence ? reasoner.isEquivalentClass(description, classToDescribe) : reasoner.isSuperClassOf(description, classToDescribe); + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosNeg.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosNeg.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosNeg.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -44,6 +44,7 @@ */ public class EvaluatedDescriptionPosNeg extends EvaluatedDescription { + private static final long serialVersionUID = -6962185910615506968L; private ScorePosNeg score2; /** Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosOnly.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosOnly.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionPosOnly.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -31,6 +31,7 @@ */ public class EvaluatedDescriptionPosOnly extends EvaluatedDescription { + private static final long serialVersionUID = 4014754537024635033L; private ScorePosOnly score2; public EvaluatedDescriptionPosOnly(Description description, ScorePosOnly score) { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -84,7 +84,6 @@ * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override - @SuppressWarnings( { "unchecked" }) public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { super.applyConfigEntry(entry); String name = entry.getOptionName(); Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosNeg.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosNeg.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosNeg.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -34,6 +34,7 @@ */ public abstract class ScorePosNeg extends Score { + private static final long serialVersionUID = -4646131678864109469L; public abstract double getScoreValue(); Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosOnly.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosOnly.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosOnly.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -30,6 +30,8 @@ */ public class ScorePosOnly extends Score { + private static final long serialVersionUID = 2191608162129054464L; + private Set<Individual> coveredInstances; private Set<Individual> notCoveredPositives; private Set<Individual> additionalInstances; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -41,6 +41,8 @@ */ public class ScoreThreeValued extends ScorePosNeg { + private static final long serialVersionUID = -1780084688122949685L; + public enum ScoreMethod {POSITIVE, FULL}; // configuration options Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreTwoValued.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -38,7 +38,9 @@ */ public class ScoreTwoValued extends ScorePosNeg { - private Set<Individual> posAsPos; + private static final long serialVersionUID = 6264873890324824550L; + + private Set<Individual> posAsPos; private Set<Individual> posAsNeg; private Set<Individual> negAsPos; private Set<Individual> negAsNeg; Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2010-02-10 10:48:19 UTC (rev 2002) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionSet.java 2010-02-10 10:50:42 UTC (rev 2003) @@ -89,6 +89,10 @@ return set.size()==0 ? null : set.last(); } + public double getBestAccuracy() { + return set.size()==0 ? Double.NEGATIVE_INFINITY : set.last().getAccuracy(); + } + public EvaluatedDescription getWorst() { return set.size()==0 ? null : set.first(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |