From: <Jen...@us...> - 2008-05-13 13:23:47
|
Revision: 833 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=833&view=rev Author: JensLehmann Date: 2008-05-13 06:23:45 -0700 (Tue, 13 May 2008) Log Message: ----------- started new comparator for ordering solutions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-05-13 11:11:07 UTC (rev 832) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedNode.java 2008-05-13 13:23:45 UTC (rev 833) @@ -22,6 +22,7 @@ import java.text.DecimalFormat; import java.util.Set; +import java.util.SortedSet; import java.util.TreeSet; import org.dllearner.core.owl.Description; @@ -64,9 +65,9 @@ // link to parent in search tree private ExampleBasedNode parent = null; - private Set<ExampleBasedNode> children = new TreeSet<ExampleBasedNode>(nodeComparator); + private SortedSet<ExampleBasedNode> children = new TreeSet<ExampleBasedNode>(nodeComparator); // apart from the child nodes, we also keep child concepts - private Set<Description> childConcepts = new TreeSet<Description>(conceptComparator); + private SortedSet<Description> childConcepts = new TreeSet<Description>(conceptComparator); public ExampleBasedNode(Description concept) { this.concept = concept; @@ -210,11 +211,11 @@ return coveredNegatives; } - public Set<ExampleBasedNode> getChildren() { + public SortedSet<ExampleBasedNode> getChildren() { return children; } - public Set<Description> getChildConcepts() { + public SortedSet<Description> getChildConcepts() { return childConcepts; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-13 11:11:07 UTC (rev 832) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-13 13:23:45 UTC (rev 833) @@ -96,6 +96,12 @@ private double noise = 0.0; private int allowedMisclassifications = 0; + // positive only learning options: + // if no negatives are given, then one possible strategy is to find a very special concept still entailing all positive examples; + // this is realised by changing the termination criterion: a concept is a solution if it has been expanded x times (x is + // configurable) but no more special concept is found (all are either equivalent or too weak) + private int maxPosOnlyExpansion = 3; + // search tree options private boolean writeSearchTree; private File searchTreeFile; @@ -118,7 +124,7 @@ // but the disadvantage of properness testing are additional reasoner // queries and a search bias towards ALL r.something because // ALL r.TOP is improper and automatically expanded further - private boolean testProperness = false; + private boolean testProperness = true; // tree traversal means to run through the most promising concepts // and connect them in an intersection to find a solution @@ -402,6 +408,23 @@ Files.appendFile(searchTreeFile, treeString); } + // special situation for positive only learning: the expanded node can become a solution (see explanations + // for maxPosOnlyExpansion above) + if(posOnly && (bestNode.getHorizontalExpansion() - bestNode.getConcept().getLength() >= maxPosOnlyExpansion)) { + // check whether there are any child concept, which are not too weak (we only need to check whether the best concept + // is too weak) + ExampleBasedNode bestChild = null; + if(bestNode.getChildren().size() > 0) + bestChild = bestNode.getChildren().last(); + if(bestNode.getChildren().size() == 0 || bestChild.isTooWeak()) { + solutions.add(bestNode.getConcept()); + System.out.println("solution: " + bestNode.getConcept()); + System.out.println("TODO: needs to be integrated with other stopping criteria"); + System.exit(0); + } + } + + // handle termination criteria handleStoppingConditions(); //logger.info(minExecutionTimeReached()+"aaaaaaa "+solutions.size()+"::"+guaranteeXgoodDescriptions); @@ -716,7 +739,7 @@ tooWeakList.add(refinement); } else { // Lösung gefunden - if(quality >= 0 && quality<=allowedMisclassifications) { + if(quality >= 0 && quality<=allowedMisclassifications && !posOnly) { solutionFound = true; solutions.add(refinement); } Added: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/SubsumptionComparator.java 2008-05-13 13:23:45 UTC (rev 833) @@ -0,0 +1,32 @@ +package org.dllearner.algorithms.refexamples; + +import java.util.Comparator; + +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.Description; + +public class SubsumptionComparator implements Comparator<ExampleBasedNode> { + + public ReasoningService rs; + + public SubsumptionComparator(ReasoningService rs) { + this.rs = rs; + } + + public int compare(ExampleBasedNode arg0, ExampleBasedNode arg1) { + Description concept1 = arg0.getConcept(); + Description concept2 = arg1.getConcept(); + // return true if concept1 is a super concept of concept2 + boolean value1 = rs.subsumes(concept1, concept2); + if(value1) + return 1; + + boolean value2 = rs.subsumes(concept2, concept1); + if(value2) + return -1; + + // both concepts are equal + return 0; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |