From: <jen...@us...> - 2008-03-03 20:07:34
|
Revision: 678 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=678&view=rev Author: jenslehmann Date: 2008-03-03 12:06:17 -0800 (Mon, 03 Mar 2008) Log Message: ----------- added support for specifying a start class (the search starts from there instead of owl:Thing) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-03 19:38:48 UTC (rev 677) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-03-03 20:06:17 UTC (rev 678) @@ -299,6 +299,7 @@ rs, operator, algHeuristic, + startClass, // usedConcepts, // usedRoles, noisePercentage/(double)100, Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-03 19:38:48 UTC (rev 677) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-03-03 20:06:17 UTC (rev 678) @@ -80,6 +80,7 @@ private ReasoningService rs; private PosNegLP learningProblem; private PosOnlyDefinitionLP posOnlyLearningProblem; + private Description startDescription; private boolean posOnly = false; private int nrOfExamples; private int nrOfPositiveExamples; @@ -171,6 +172,7 @@ ReasoningService rs, RefinementOperator operator, ExampleBasedHeuristic heuristic, + Description startDescription, // Set<AtomicConcept> allowedConcepts, // Set<AtomicRole> allowedRoles, double noise, @@ -197,6 +199,7 @@ nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; this.rs = rs; this.operator = (RhoDRDown) operator; + this.startDescription = startDescription; // initialise candidate set with heuristic as ordering candidates = new TreeSet<ExampleBasedNode>(heuristic); this.noise = noise; @@ -216,19 +219,28 @@ // calculate quality threshold required for a solution allowedMisclassifications = (int) Math.round(noise * nrOfExamples); - // start search with most general concept - Thing top = new Thing(); - ExampleBasedNode topNode = new ExampleBasedNode(top); - // top covers all negatives - int coveredNegativeExamples = getNumberOfNegatives(); - topNode.setCoveredNegativeExamples(coveredNegativeExamples); - topNode.setCoveredPositives(learningProblem.getPositiveExamples()); - topNode.setCoveredNegatives(learningProblem.getNegativeExamples()); - candidates.add(topNode); - candidatesStable.add(topNode); + // start search with start class + ExampleBasedNode startNode; + if(startDescription == null) { + Thing top = new Thing(); + startNode = new ExampleBasedNode(top); + // top covers all negatives + int coveredNegativeExamples = getNumberOfNegatives(); + startNode.setCoveredNegativeExamples(coveredNegativeExamples); + startNode.setCoveredPositives(learningProblem.getPositiveExamples()); + startNode.setCoveredNegatives(learningProblem.getNegativeExamples()); + } else { + startNode = new ExampleBasedNode(startDescription); + Set<Individual> coveredNegatives = rs.instanceCheck(startDescription, learningProblem.getNegativeExamples()); + startNode.setCoveredPositives(rs.instanceCheck(startDescription, learningProblem.getPositiveExamples())); + startNode.setCoveredNegatives(coveredNegatives); + startNode.setCoveredNegativeExamples(coveredNegatives.size()); + } + candidates.add(startNode); + candidatesStable.add(startNode); // note that TOP may already be a solution - ExampleBasedNode bestNode = topNode; + ExampleBasedNode bestNode = startNode; // solutionFound = (coveredNegativeExamples == 0); // solutions = new LinkedList<Concept>(); // if(solutionFound) @@ -272,7 +284,7 @@ } } expandedNodes.clear(); - treeString += topNode.getTreeString(); + treeString += startNode.getTreeString(); treeString += "\n"; if(replaceSearchTree) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |