From: <Jen...@us...> - 2008-05-13 11:11:13
|
Revision: 832 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=832&view=rev Author: JensLehmann Date: 2008-05-13 04:11:07 -0700 (Tue, 13 May 2008) Log Message: ----------- started posonly learning for refexamples algorithm Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestEquivalentClassView.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-06 18:27:11 UTC (rev 831) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-05-13 11:11:07 UTC (rev 832) @@ -45,6 +45,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; @@ -274,10 +275,12 @@ } algHeuristic = new FlexibleHeuristic(((PosNegLP)learningProblem).getNegativeExamples().size(), ((PosNegLP)learningProblem).getPercentPerLengthUnit()); } else { - if(learningProblem instanceof PosOnlyDefinitionLP) { - throw new RuntimeException("does not work with positive examples only yet"); - } - algHeuristic = new MultiHeuristic(((PosNegLP)learningProblem).getPositiveExamples().size(),((PosNegLP)learningProblem).getNegativeExamples().size()); + if(learningProblem instanceof PosOnlyLP) { +// throw new RuntimeException("does not work with positive examples only yet"); + algHeuristic = new MultiHeuristic(((PosOnlyLP)learningProblem).getPositiveExamples().size(),0); + } else { + algHeuristic = new MultiHeuristic(((PosNegLP)learningProblem).getPositiveExamples().size(),((PosNegLP)learningProblem).getNegativeExamples().size()); + } } // compute used concepts/roles from allowed/ignored Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-06 18:27:11 UTC (rev 831) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-05-13 11:11:07 UTC (rev 832) @@ -80,13 +80,17 @@ // basic setup: learning problem and reasoning service private ReasoningService rs; + // often the learning problems needn't be accessed directly; instead + // use the example sets below and the posonly variable private PosNegLP learningProblem; private PosOnlyDefinitionLP posOnlyLearningProblem; private Description startDescription; private boolean posOnly = false; private int nrOfExamples; private int nrOfPositiveExamples; + private Set<Individual> positiveExamples; private int nrOfNegativeExamples; + private Set<Individual> negativeExamples; // noise regulates how many positives can be misclassified and when the algorithm terminates private double noise = 0.0; @@ -199,7 +203,6 @@ private long evaluateSetCreationTimeNs = 0; private long improperConceptsRemovalTimeNs = 0; - // prefixes private String baseURI; @@ -227,8 +230,10 @@ PosNegLP lp = (PosNegLP) learningProblem; this.learningProblem = lp; posOnly = false; - nrOfPositiveExamples = lp.getPositiveExamples().size(); - nrOfNegativeExamples = lp.getNegativeExamples().size(); + positiveExamples = lp.getPositiveExamples(); + negativeExamples = lp.getNegativeExamples(); + nrOfPositiveExamples = positiveExamples.size(); + nrOfNegativeExamples = negativeExamples.size(); // System.out.println(nrOfPositiveExamples); // System.out.println(nrOfNegativeExamples); @@ -238,8 +243,11 @@ PosOnlyDefinitionLP lp = (PosOnlyDefinitionLP) learningProblem; this.posOnlyLearningProblem = lp; posOnly = true; + positiveExamples = lp.getPositiveExamples(); + negativeExamples = new TreeSet<Individual>(); nrOfPositiveExamples = lp.getPositiveExamples().size(); - nrOfNegativeExamples = lp.getPseudoNegatives().size(); +// nrOfNegativeExamples = lp.getPseudoNegatives().size(); + nrOfNegativeExamples = 0; } nrOfExamples = nrOfPositiveExamples + nrOfNegativeExamples; this.rs = rs; @@ -312,11 +320,11 @@ // start search with start class if(startDescription == null) { startNode = new ExampleBasedNode(Thing.instance); - startNode.setCoveredExamples(learningProblem.getPositiveExamples(), learningProblem.getNegativeExamples()); + startNode.setCoveredExamples(positiveExamples, negativeExamples); } else { startNode = new ExampleBasedNode(startDescription); - Set<Individual> coveredNegatives = rs.instanceCheck(startDescription, learningProblem.getNegativeExamples()); - Set<Individual> coveredPositives = rs.instanceCheck(startDescription, learningProblem.getPositiveExamples()); + Set<Individual> coveredNegatives = rs.instanceCheck(startDescription, negativeExamples); + Set<Individual> coveredPositives = rs.instanceCheck(startDescription, positiveExamples); startNode.setCoveredExamples(coveredPositives, coveredNegatives); } @@ -635,10 +643,11 @@ if(useOverlyGeneralList && refinement instanceof Union) { if(containsOverlyGeneralElement((Union)refinement)) { conceptTestsOverlyGeneralList++; - quality = getNumberOfNegatives(); +// quality = getNumberOfNegatives(); + quality = nrOfNegativeExamples; qualityKnown = true; newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.OVERLY_GENERAL_LIST); - newNode.setCoveredExamples(learningProblem.getPositiveExamples(), learningProblem.getNegativeExamples()); + newNode.setCoveredExamples(positiveExamples, negativeExamples); } } @@ -717,7 +726,7 @@ // we need to make sure that all positives are covered // before adding something to the overly general list - if((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == getNumberOfNegatives()) + if((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == nrOfNegativeExamples) overlyGeneralList.add(refinement); } @@ -833,20 +842,20 @@ + conceptTestsTooWeakList + "/" + conceptTestsOverlyGeneralList + "/" + redundantConcepts); } - @SuppressWarnings({"unused"}) - private int coveredNegativesOrTooWeak(Description concept) { - if(posOnly) - return posOnlyLearningProblem.coveredPseudoNegativeExamplesOrTooWeak(concept); - else - return learningProblem.coveredNegativeExamplesOrTooWeak(concept); - } +// @SuppressWarnings({"unused"}) +// private int coveredNegativesOrTooWeak(Description concept) { +// if(posOnly) +// return posOnlyLearningProblem.coveredPseudoNegativeExamplesOrTooWeak(concept); +// else +// return learningProblem.coveredNegativeExamplesOrTooWeak(concept); +// } - private int getNumberOfNegatives() { - if(posOnly) - return posOnlyLearningProblem.getPseudoNegatives().size(); - else - return learningProblem.getNegativeExamples().size(); - } +// private int getNumberOfNegatives() { +// if(posOnly) +// return posOnlyLearningProblem.getPseudoNegatives().size(); +// else +// return learningProblem.getNegativeExamples().size(); +// } private boolean containsTooWeakElement(Intersection mc) { for(Description child : mc.getChildren()) { @@ -1047,7 +1056,7 @@ return posOnlyLearningProblem.computeScore(getBestSolution()); else return learningProblem.computeScore(getBestSolution()); - } + } public ExampleBasedNode getStartNode() { return startNode; Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-06 18:27:11 UTC (rev 831) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-05-13 11:11:07 UTC (rev 832) @@ -787,11 +787,11 @@ */ public static Class<? extends LearningProblem> getLearningProblemClass(ConfFileOption problemOption) { Class<? extends LearningProblem> lpClass = null; - if (problemOption == null || problemOption.getStringValue().equals("posNegDefinition")) + if (problemOption == null || problemOption.getStringValue().equals("posNegDefinitionLP")) lpClass = PosNegDefinitionLP.class; - else if (problemOption.getStringValue().equals("posNegInclusion")) + else if (problemOption.getStringValue().equals("posNegInclusionLP")) lpClass = PosNegInclusionLP.class; - else if (problemOption.getStringValue().equals("posOnlyDefinition")) + else if (problemOption.getStringValue().equals("posOnlyDefinitionLP")) lpClass = PosOnlyDefinitionLP.class; else handleError("Unknown value " + problemOption.getValue() + " for option \"problem\"."); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-05-06 18:27:11 UTC (rev 831) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-05-13 11:11:07 UTC (rev 832) @@ -4,7 +4,6 @@ import org.protege.editor.owl.ui.frame.InheritedAnonymousClassesFrameSection; import org.protege.editor.owl.ui.frame.OWLClassAssertionAxiomIndividualSection; import org.protege.editor.owl.ui.frame.OWLDisjointClassesAxiomFrameSection; -import org.protege.editor.owl.ui.frame.OWLEquivalentClassesAxiomFrameSection; import org.protege.editor.owl.ui.frame.OWLSubClassAxiomFrameSection; import org.semanticweb.owl.model.OWLClass; import org.protege.editor.owl.OWLEditorKit; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-05-06 18:27:11 UTC (rev 831) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-05-13 11:11:07 UTC (rev 832) @@ -19,7 +19,6 @@ import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.AddAxiom; import org.semanticweb.owl.model.OWLAxiom; -import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLOntology; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestEquivalentClassView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestEquivalentClassView.java 2008-05-06 18:27:11 UTC (rev 831) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestEquivalentClassView.java 2008-05-13 11:11:07 UTC (rev 832) @@ -5,7 +5,6 @@ import java.awt.GridLayout; import java.util.*; -import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClass; import org.protege.editor.owl.ui.frame.OWLFrame; import javax.swing.JButton; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |