From: <jen...@us...> - 2009-02-13 11:07:02
|
Revision: 1602 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1602&view=rev Author: jenslehmann Date: 2009-02-13 11:06:53 +0000 (Fri, 13 Feb 2009) Log Message: ----------- improved learning problem structure Modified Paths: -------------- trunk/lib/components.ini trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 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/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/core/LearningProblem.java trunk/src/dl-learner/org/dllearner/core/Score.java trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java trunk/src/dl-learner/org/dllearner/examples/KRKModular.java trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/TreeWindow.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/PosNegInclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyLP.java trunk/src/dl-learner/org/dllearner/learningproblems/ScorePosNeg.java trunk/src/dl-learner/org/dllearner/scripts/DumbLPFinder.java trunk/src/dl-learner/org/dllearner/scripts/NewSample.java trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/scripts/SemanticBibleComparison.java trunk/src/dl-learner/org/dllearner/scripts/WikipediaCategoryCleaner.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/test/ComponentTest.java trunk/src/dl-learner/org/dllearner/test/SworeTest.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/utilities/components/ComponentCombo.java trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStrict.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/InclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLPStrict.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyInclusionLP.java Modified: trunk/lib/components.ini =================================================================== --- trunk/lib/components.ini 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/lib/components.ini 2009-02-13 11:06:53 UTC (rev 1602) @@ -11,11 +11,10 @@ org.dllearner.reasoning.FastRetrievalReasoner org.dllearner.reasoning.FastInstanceChecker # learning problems -org.dllearner.learningproblems.PosNegDefinitionLP -org.dllearner.learningproblems.PosNegDefinitionLPStrict +org.dllearner.learningproblems.PosNegLPStandard +org.dllearner.learningproblems.PosNegLPStrict org.dllearner.learningproblems.PosNegInclusionLP -org.dllearner.learningproblems.PosOnlyDefinitionLP -org.dllearner.learningproblems.PosOnlyInclusionLP +org.dllearner.learningproblems.PosOnlyLP org.dllearner.learningproblems.ClassLearningProblem # learning algorithms org.dllearner.algorithms.RandomGuesser Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -39,9 +39,9 @@ import org.dllearner.core.options.InvalidConfigOptionValueException; import org.dllearner.core.options.StringConfigOption; import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.learningproblems.ScorePosNeg; /** @@ -79,8 +79,8 @@ PosNegLP lp = (PosNegLP) learningProblem; this.learner = ComponentFactory.getExampleBasedROLComponent(lp, rs); //this.learner=new ExampleBasedROLComponent(lp, rs); - } else if(learningProblem instanceof PosOnlyDefinitionLP) { - PosOnlyDefinitionLP lp = (PosOnlyDefinitionLP) learningProblem; + } else if(learningProblem instanceof PosOnlyLP) { + PosOnlyLP lp = (PosOnlyLP) learningProblem; this.learner = ComponentFactory.getExampleBasedROLComponent(lp, rs); //this.learner=new ExampleBasedROLComponent(lp, rs); } @@ -100,12 +100,12 @@ return "DBpedia Navigation Suggestor"; } - public DBpediaNavigationSuggestor(PosOnlyDefinitionLP learningProblem, ReasonerComponent rs) { + public DBpediaNavigationSuggestor(PosOnlyLP learningProblem, ReasonerComponent rs) { super(learningProblem, rs); System.out.println("test1"); } - public DBpediaNavigationSuggestor(PosNegDefinitionLP learningProblem, ReasonerComponent rs) { + public DBpediaNavigationSuggestor(PosNegLPStandard learningProblem, ReasonerComponent rs) { super(learningProblem, rs); System.out.println("test2"); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -22,7 +22,7 @@ import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.Thing; -import org.dllearner.learningproblems.PosNegDefinitionLPStrict; +import org.dllearner.learningproblems.PosNegLPStrict; import org.dllearner.learningproblems.ScorePosNeg; import org.dllearner.learningproblems.ScoreThreeValued; import org.dllearner.reasoning.FastRetrieval; @@ -459,7 +459,7 @@ // learningProblem.getReasoner().getIndividuals(); // neutClassified.retainAll(posClassified); neutClassified.retainAll(negClassified); - PosNegDefinitionLPStrict lp = (PosNegDefinitionLPStrict)learningProblem; + PosNegLPStrict lp = (PosNegLPStrict)learningProblem; return new ScoreThreeValued(conceptLength, lp.getAccuracyPenalty(), lp.getErrorPenalty(), lp.isPenaliseNeutralExamples(), lp.getPercentPerLengthUnit(), posClassified, neutClassified, negClassified, lp.getPositiveExamples(),lp.getNeutralExamples(),lp.getNegativeExamples()); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -49,7 +49,6 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.learningproblems.ScorePosNeg; import org.dllearner.reasoning.ReasonerType; @@ -156,7 +155,7 @@ this.configurator = new ExampleBasedROLComponentConfigurator(this); } - public ExampleBasedROLComponent(PosOnlyDefinitionLP learningProblem, ReasonerComponent reasoningService) { + public ExampleBasedROLComponent(PosOnlyLP learningProblem, ReasonerComponent reasoningService) { super(learningProblem, reasoningService); this.configurator = new ExampleBasedROLComponentConfigurator(this); } @@ -164,7 +163,7 @@ public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); problems.add(PosNegLP.class); - problems.add(PosOnlyDefinitionLP.class); + problems.add(PosOnlyLP.class); return problems; } @@ -324,7 +323,7 @@ if(heuristic == "lexicographic") algHeuristic = new LexicographicHeuristic(); else if(heuristic == "flexible") { - if(learningProblem instanceof PosOnlyDefinitionLP) { + if(learningProblem instanceof PosOnlyLP) { throw new RuntimeException("does not work with positive examples only yet"); } algHeuristic = new FlexibleHeuristic(((PosNegLP)learningProblem).getNegativeExamples().size(), ((PosNegLP)learningProblem).getPercentPerLengthUnit()); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -43,7 +43,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.Union; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.learningproblems.ScorePosNeg; import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.refinementoperators.RhoDRDown; @@ -72,7 +72,7 @@ // 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 PosOnlyLP posOnlyLearningProblem; private Description startDescription; private boolean posOnly = false; private int nrOfExamples; @@ -254,8 +254,8 @@ // System.out.println(nrOfNegativeExamples); // System.exit(0); - } else if (learningProblem instanceof PosOnlyDefinitionLP) { - PosOnlyDefinitionLP lp = (PosOnlyDefinitionLP) learningProblem; + } else if (learningProblem instanceof PosOnlyLP) { + PosOnlyLP lp = (PosOnlyLP) learningProblem; this.posOnlyLearningProblem = lp; posOnly = true; positiveExamples = lp.getPositiveExamples(); @@ -1305,14 +1305,14 @@ public ScorePosNeg getSolutionScore() { if (posOnly) - return posOnlyLearningProblem.computeScore(getBestSolution()); + return (ScorePosNeg) posOnlyLearningProblem.computeScore(getBestSolution()); else return (ScorePosNeg) learningProblem.computeScore(getBestSolution()); } private ScorePosNeg getScore(Description d) { if (posOnly) - return posOnlyLearningProblem.computeScore(d); + return (ScorePosNeg) posOnlyLearningProblem.computeScore(d); else return (ScorePosNeg) learningProblem.computeScore(d); } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -34,7 +34,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.Union; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.learningproblems.ScorePosNeg; import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.Files; @@ -111,7 +111,7 @@ DecimalFormat df = new DecimalFormat(); private PosNegLP learningProblem; - private PosOnlyDefinitionLP posOnlyLearningProblem; + private PosOnlyLP posOnlyLearningProblem; private boolean posOnly = false; // Menge von Kandidaten für Refinement @@ -203,7 +203,7 @@ } - public ROLearner(PosOnlyDefinitionLP learningProblem, ReasonerComponent reasoningService) { + public ROLearner(PosOnlyLP learningProblem, ReasonerComponent reasoningService) { super(learningProblem, reasoningService); this.posOnlyLearningProblem = learningProblem; this.configurator = new ROLearnerConfigurator(this); @@ -214,7 +214,7 @@ public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() { Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>(); problems.add(PosNegLP.class); - problems.add(PosOnlyDefinitionLP.class); + problems.add(PosOnlyLP.class); return problems; } @@ -1102,7 +1102,7 @@ // @Override public ScorePosNeg getSolutionScore() { if(posOnly) - return posOnlyLearningProblem.computeScore(getCurrentlyBestDescription()); + return (ScorePosNeg) posOnlyLearningProblem.computeScore(getCurrentlyBestDescription()); else return (ScorePosNeg) learningProblem.computeScore(getCurrentlyBestDescription()); } @@ -1110,7 +1110,7 @@ public ScorePosNeg getSolutionScore(Description d) { if(posOnly) - return posOnlyLearningProblem.computeScore(d); + return (ScorePosNeg) posOnlyLearningProblem.computeScore(d); else return (ScorePosNeg) learningProblem.computeScore(d); } Modified: trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/cli/ConfMapper.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -41,10 +41,9 @@ import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.ClassLearningProblem; -import org.dllearner.learningproblems.PosNegDefinitionLP; -import org.dllearner.learningproblems.PosNegDefinitionLPStrict; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.learningproblems.PosNegLPStrict; import org.dllearner.learningproblems.PosNegInclusionLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.FastRetrievalReasoner; @@ -85,10 +84,9 @@ reasonerMapping.put("owlAPIReasoner", OWLAPIReasoner.class); reasonerMapping.put("fastInstanceChecker", FastInstanceChecker.class); reasonerMapping.put("fastRetrievalReasoner", FastRetrievalReasoner.class); - learningProblemMapping.put("posNegDefinitionLP", PosNegDefinitionLP.class); + learningProblemMapping.put("posNegDefinitionLP", PosNegLPStandard.class); learningProblemMapping.put("posNegInclusionLP", PosNegInclusionLP.class); - learningProblemMapping.put("posOnlyDefinitionLP", PosOnlyDefinitionLP.class); - learningProblemMapping.put("posNegDefinitionLPStrict", PosNegDefinitionLPStrict.class); + learningProblemMapping.put("posNegDefinitionLPStrict", PosNegLPStrict.class); learningProblemMapping.put("classLearning", ClassLearningProblem.class); learningAlgorithmMapping.put("random", RandomGuesser.class); learningAlgorithmMapping.put("bruteForce", BruteForceLearner.class); Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -73,9 +73,9 @@ import org.dllearner.kb.KBFile; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.learningproblems.PosNegInclusionLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.learningproblems.ScorePosNeg; import org.dllearner.parser.ConfParser; import org.dllearner.parser.KBParser; @@ -291,13 +291,13 @@ handleError("Invalid value \"" + problemOption.getStringValue() + "\" in " + problemOption + ". Valid values are " + confMapper.getLearningProblems() + "."); } } else { - lpClass = PosNegDefinitionLP.class; + lpClass = PosNegLPStandard.class; } lp = cm.learningProblem(lpClass, rc); SortedSet<String> posExamples = parser.getPositiveExamples(); SortedSet<String> negExamples = parser.getNegativeExamples(); cm.applyConfigEntry(lp, "positiveExamples", posExamples); - if (lpClass != PosOnlyDefinitionLP.class) + if (lpClass != PosOnlyLP.class) cm.applyConfigEntry(lp, "negativeExamples", negExamples); configureComponent(cm, lp, parser); initComponent(cm, lp); @@ -365,9 +365,9 @@ componentPrefixMapping.put(FastRetrievalReasoner.class, "fastRetrieval"); // learning problems - configured via + and - flags for examples - componentPrefixMapping.put(PosNegDefinitionLP.class, "posNegDefinitionLP"); + componentPrefixMapping.put(PosNegLPStandard.class, "posNegDefinitionLP"); componentPrefixMapping.put(PosNegInclusionLP.class, "posNegInclusionLP"); - componentPrefixMapping.put(PosOnlyDefinitionLP.class, "posOnlyDefinitionLP"); + componentPrefixMapping.put(PosOnlyLP.class, "posOnlyDefinitionLP"); // learning algorithms componentPrefixMapping.put(ROLearner.class, "refinement"); @@ -943,11 +943,11 @@ ConfFileOption problemOption) { Class<? extends LearningProblem> lpClass = null; if (problemOption == null || problemOption.getStringValue().equals("posNegDefinitionLP")) - lpClass = PosNegDefinitionLP.class; + lpClass = PosNegLPStandard.class; else if (problemOption.getStringValue().equals("posNegInclusionLP")) lpClass = PosNegInclusionLP.class; else if (problemOption.getStringValue().equals("posOnlyDefinitionLP")) - lpClass = PosOnlyDefinitionLP.class; + lpClass = PosOnlyLP.class; else handleError("Unknown value " + problemOption.getValue() + " for option \"problem\"."); Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -86,8 +86,8 @@ * @see org.dllearner.core.Score#getScoreValue() * @return Value in this score system. */ - public double getScoreValue() { - return score.getScoreValue(); + public double getAccuracy() { + return score.getAccuracy(); } /** @@ -117,7 +117,7 @@ OWLDescription d = OWLAPIDescriptionConvertVisitor.getOWLDescription(description); object.put("descriptionOWLXML", OWLAPIRenderers.toOWLXMLSyntax(d)); object.put("descriptionKBSyntax", description.toKBSyntaxString()); - object.put("scoreValue", score.getScoreValue()); + object.put("scoreValue", score.getAccuracy()); return object.toString(3); } catch (JSONException e) { e.printStackTrace(); Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -239,7 +239,7 @@ // because learning algorithms are advised to order descriptions by accuracy, // so we won't find any concept with higher accuracy in the remaining list // if(ed.getAccuracy() < accuracyThreshold) { - if(ed.getScoreValue() < accuracyThreshold) { + if(ed.getAccuracy() < accuracyThreshold) { return returnList; } Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007-2008, Jens Lehmann + * Copyright (C) 2007-2009, Jens Lehmann * * This file is part of DL-Learner. * @@ -20,7 +20,6 @@ package org.dllearner.core; import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.ScorePosNeg; /** * Base class for all learning problems. @@ -30,14 +29,6 @@ * of learning class descriptions. However, this may be extended * to other scenarios if desired. * - * TODO: The current learning problem implementations assume that - * we learn a description for a class, which does not exist - * in the knowledge base so far (if it exists, it needs to be ignored - * explicitly). However, often we want to learn a complex definition - * for a concept which is already integrated in a subsumption hierarchy - * or may already have an associated description. It may make sense - * to use this knowledge for (re-)learning descriptions. - * * @author Jens Lehmann * */ @@ -71,15 +62,43 @@ public void changeReasonerComponent(ReasonerComponent reasoner) { this.reasoner = reasoner; } - + /** * Computes the <code>Score</code> of a given class description * with respect to this learning problem. * This can (but does not need to) be used by learning algorithms * to measure how good the description fits the learning problem. + * Score objects are used to store e.g. covered examples, accuracy etc., + * so often it is more efficient to only create score objects for + * promising class descriptions. * @param description A class description (as solution candidate for this learning problem). * @return A <code>Score</code> object. */ public abstract Score computeScore(Description description); + /** + * This method returns a value, which indicates how accurate a + * class description solves a learning problem. There can be different + * ways to compute accuracy depending on the type of learning problem + * and other factors. However, all implementations are required to + * return a value between 0 and 1, where 1 stands for the highest + * possible accuracy and 0 for the lowest possible accuracy. + * + * @return A value between 0 and 1 indicating the quality (of a class description). + */ + public abstract double getAccuracy(Description description); + + /** + * This method computes the accuracy as {@link #getAccuracy(Description)}, + * but returns -1 instead of the accuracy if 1.) the accuracy of the + * description is below the given threshold and 2.) the accuracy of all + * more special w.r.t. subsumption descriptions is below the given threshold. + * This is used for efficiency reasons, i.e. -1 can be returned instantly if + * it is clear that the description and all its refinements are not + * sufficiently accurate. + * + * @return A value between 0 and 1 indicating the quality (of a class description) + * or -1 as described above. + */ + public abstract double getAccuracyOrTooWeak(Description description, double minAccuracy); } Modified: trunk/src/dl-learner/org/dllearner/core/Score.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Score.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/Score.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -31,14 +31,12 @@ public abstract class Score { /** - * This method returns a value, which indicates how well a - * class description solves a learning problem. Different implementations - * of scoring systems can implement this differently. Higher values - * are better and it is recommended to assign a score value in - * the closed interval from 0 to 1 if possible. + * This method returns a value, which indicates how accurate a + * class description solves a learning problem. * - * @return A value indicating the quality (of a class description). - */ - public abstract double getScoreValue(); + * @see LearningProblem#getAccuracy(Description) + * @return A value between 0 and 1 indicating the quality (of a class description). + */ + public abstract double getAccuracy(); } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ComponentFactory.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -40,11 +40,10 @@ import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.ClassLearningProblem; -import org.dllearner.learningproblems.PosNegDefinitionLP; -import org.dllearner.learningproblems.PosNegDefinitionLPStrict; +import org.dllearner.learningproblems.PosNegLPStandard; +import org.dllearner.learningproblems.PosNegLPStrict; import org.dllearner.learningproblems.PosNegInclusionLP; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.learningproblems.PosOnlyInclusionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.reasoning.DIGReasoner; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.FastRetrievalReasoner; @@ -136,7 +135,7 @@ * @param reasoningService see ReasoningService * @return a component ready for initialization PosNegDefinitionLP **/ -public static PosNegDefinitionLP getPosNegDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { +public static PosNegLPStandard getPosNegDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { return PosNegDefinitionLPConfigurator.getPosNegDefinitionLP(reasoningService, positiveExamples, negativeExamples); } @@ -146,7 +145,7 @@ * @param reasoningService see ReasoningService * @return a component ready for initialization PosNegDefinitionLPStrict **/ -public static PosNegDefinitionLPStrict getPosNegDefinitionLPStrict(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { +public static PosNegLPStrict getPosNegDefinitionLPStrict(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { return PosNegDefinitionLPStrictConfigurator.getPosNegDefinitionLPStrict(reasoningService, positiveExamples, negativeExamples); } @@ -163,22 +162,13 @@ /** * @param positiveExamples positive examples * @param reasoningService see ReasoningService -* @return a component ready for initialization PosOnlyDefinitionLP +* @return a component ready for initialization PosOnlyLP **/ -public static PosOnlyDefinitionLP getPosOnlyDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { -return PosOnlyDefinitionLPConfigurator.getPosOnlyDefinitionLP(reasoningService, positiveExamples); +public static PosOnlyLP getPosOnlyLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { +return PosOnlyLPConfigurator.getPosOnlyLP(reasoningService, positiveExamples); } /** -* @param positiveExamples positive examples -* @param reasoningService see ReasoningService -* @return a component ready for initialization PosOnlyInclusionLP -**/ -public static PosOnlyInclusionLP getPosOnlyInclusionLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { -return PosOnlyInclusionLPConfigurator.getPosOnlyInclusionLP(reasoningService, positiveExamples); -} - -/** * @param learningProblem see LearningProblem * @param reasoningService see ReasoningService * @throws LearningProblemUnsupportedException see Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPConfigurator.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -23,7 +23,7 @@ import java.util.Set; import org.dllearner.core.ComponentManager; import org.dllearner.core.ReasonerComponent; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; /** * automatically generated, do not edit manually. @@ -34,12 +34,12 @@ private boolean reinitNecessary = false; @SuppressWarnings("unused") -private PosNegDefinitionLP posNegDefinitionLP; +private PosNegLPStandard posNegDefinitionLP; /** * @param posNegDefinitionLP see PosNegDefinitionLP **/ -public PosNegDefinitionLPConfigurator(PosNegDefinitionLP posNegDefinitionLP){ +public PosNegDefinitionLPConfigurator(PosNegLPStandard posNegDefinitionLP){ this.posNegDefinitionLP = posNegDefinitionLP; } @@ -49,8 +49,8 @@ * @param negativeExamples negative examples * @return PosNegDefinitionLP **/ -public static PosNegDefinitionLP getPosNegDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { -PosNegDefinitionLP component = ComponentManager.getInstance().learningProblem(PosNegDefinitionLP.class, reasoningService); +public static PosNegLPStandard getPosNegDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { +PosNegLPStandard component = ComponentManager.getInstance().learningProblem(PosNegLPStandard.class, reasoningService); ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples); ComponentManager.getInstance().applyConfigEntry(component, "negativeExamples", negativeExamples); return component; Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegDefinitionLPStrictConfigurator.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -23,7 +23,7 @@ import java.util.Set; import org.dllearner.core.ComponentManager; import org.dllearner.core.ReasonerComponent; -import org.dllearner.learningproblems.PosNegDefinitionLPStrict; +import org.dllearner.learningproblems.PosNegLPStrict; /** * automatically generated, do not edit manually. @@ -34,12 +34,12 @@ private boolean reinitNecessary = false; @SuppressWarnings("unused") -private PosNegDefinitionLPStrict posNegDefinitionLPStrict; +private PosNegLPStrict posNegDefinitionLPStrict; /** * @param posNegDefinitionLPStrict see PosNegDefinitionLPStrict **/ -public PosNegDefinitionLPStrictConfigurator(PosNegDefinitionLPStrict posNegDefinitionLPStrict){ +public PosNegDefinitionLPStrictConfigurator(PosNegLPStrict posNegDefinitionLPStrict){ this.posNegDefinitionLPStrict = posNegDefinitionLPStrict; } @@ -49,8 +49,8 @@ * @param negativeExamples negative examples * @return PosNegDefinitionLPStrict **/ -public static PosNegDefinitionLPStrict getPosNegDefinitionLPStrict(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { -PosNegDefinitionLPStrict component = ComponentManager.getInstance().learningProblem(PosNegDefinitionLPStrict.class, reasoningService); +public static PosNegLPStrict getPosNegDefinitionLPStrict(ReasonerComponent reasoningService, Set<String> positiveExamples, Set<String> negativeExamples) { +PosNegLPStrict component = ComponentManager.getInstance().learningProblem(PosNegLPStrict.class, reasoningService); ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples); ComponentManager.getInstance().applyConfigEntry(component, "negativeExamples", negativeExamples); return component; Deleted: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyDefinitionLPConfigurator.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -1,86 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -package org.dllearner.core.configurators; - -import java.util.Set; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; - -/** -* automatically generated, do not edit manually. -* run org.dllearner.scripts.ConfigJavaGenerator to update -**/ -public class PosOnlyDefinitionLPConfigurator implements Configurator { - -private boolean reinitNecessary = false; -@SuppressWarnings("unused") - -private PosOnlyDefinitionLP posOnlyDefinitionLP; - -/** -* @param posOnlyDefinitionLP see PosOnlyDefinitionLP -**/ -public PosOnlyDefinitionLPConfigurator(PosOnlyDefinitionLP posOnlyDefinitionLP){ -this.posOnlyDefinitionLP = posOnlyDefinitionLP; -} - -/** -* @param reasoningService see reasoningService -* @param positiveExamples positive examples -* @return PosOnlyDefinitionLP -**/ -public static PosOnlyDefinitionLP getPosOnlyDefinitionLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { -PosOnlyDefinitionLP component = ComponentManager.getInstance().learningProblem(PosOnlyDefinitionLP.class, reasoningService); -ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples); -return component; -} - -/** -* positiveExamples positive examples. -* mandatory: true| reinit necessary: false -* default value: null -* @return Set(String) -**/ -@SuppressWarnings("unchecked") -public Set<String> getPositiveExamples() { -return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posOnlyDefinitionLP, "positiveExamples") ; -} - -/** -* @param positiveExamples positive examples. -* mandatory: true| reinit necessary: false -* default value: null -**/ -public void setPositiveExamples(Set<String> positiveExamples) { -ComponentManager.getInstance().applyConfigEntry(posOnlyDefinitionLP, "positiveExamples", positiveExamples); -} - -/** -* true, if this component needs reinitializsation. -* @return boolean -**/ -public boolean isReinitNecessary(){ -return reinitNecessary; -} - - -} Deleted: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyInclusionLPConfigurator.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -1,86 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -package org.dllearner.core.configurators; - -import java.util.Set; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.ReasonerComponent; -import org.dllearner.learningproblems.PosOnlyInclusionLP; - -/** -* automatically generated, do not edit manually. -* run org.dllearner.scripts.ConfigJavaGenerator to update -**/ -public class PosOnlyInclusionLPConfigurator implements Configurator { - -private boolean reinitNecessary = false; -@SuppressWarnings("unused") - -private PosOnlyInclusionLP posOnlyInclusionLP; - -/** -* @param posOnlyInclusionLP see PosOnlyInclusionLP -**/ -public PosOnlyInclusionLPConfigurator(PosOnlyInclusionLP posOnlyInclusionLP){ -this.posOnlyInclusionLP = posOnlyInclusionLP; -} - -/** -* @param reasoningService see reasoningService -* @param positiveExamples positive examples -* @return PosOnlyInclusionLP -**/ -public static PosOnlyInclusionLP getPosOnlyInclusionLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { -PosOnlyInclusionLP component = ComponentManager.getInstance().learningProblem(PosOnlyInclusionLP.class, reasoningService); -ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples); -return component; -} - -/** -* positiveExamples positive examples. -* mandatory: true| reinit necessary: false -* default value: null -* @return Set(String) -**/ -@SuppressWarnings("unchecked") -public Set<String> getPositiveExamples() { -return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posOnlyInclusionLP, "positiveExamples") ; -} - -/** -* @param positiveExamples positive examples. -* mandatory: true| reinit necessary: false -* default value: null -**/ -public void setPositiveExamples(Set<String> positiveExamples) { -ComponentManager.getInstance().applyConfigEntry(posOnlyInclusionLP, "positiveExamples", positiveExamples); -} - -/** -* true, if this component needs reinitializsation. -* @return boolean -**/ -public boolean isReinitNecessary(){ -return reinitNecessary; -} - - -} Added: trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosOnlyLPConfigurator.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +package org.dllearner.core.configurators; + +import java.util.Set; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.learningproblems.PosOnlyLP; + +/** +* automatically generated, do not edit manually. +* run org.dllearner.scripts.ConfigJavaGenerator to update +**/ +public class PosOnlyLPConfigurator implements Configurator { + +private boolean reinitNecessary = false; +@SuppressWarnings("unused") + +private PosOnlyLP posOnlyLP; + +/** +* @param posOnlyLP see PosOnlyLP +**/ +public PosOnlyLPConfigurator(PosOnlyLP posOnlyLP){ +this.posOnlyLP = posOnlyLP; +} + +/** +* @param reasoningService see reasoningService +* @param positiveExamples positive examples +* @return PosOnlyLP +**/ +public static PosOnlyLP getPosOnlyLP(ReasonerComponent reasoningService, Set<String> positiveExamples) { +PosOnlyLP component = ComponentManager.getInstance().learningProblem(PosOnlyLP.class, reasoningService); +ComponentManager.getInstance().applyConfigEntry(component, "positiveExamples", positiveExamples); +return component; +} + +/** +* positiveExamples positive examples. +* mandatory: true| reinit necessary: false +* default value: null +* @return Set(String) +**/ +@SuppressWarnings("unchecked") +public Set<String> getPositiveExamples() { +return (Set<String>) ComponentManager.getInstance().getConfigOptionValue(posOnlyLP, "positiveExamples") ; +} + +/** +* @param positiveExamples positive examples. +* mandatory: true| reinit necessary: false +* default value: null +**/ +public void setPositiveExamples(Set<String> positiveExamples) { +ComponentManager.getInstance().applyConfigEntry(posOnlyLP, "positiveExamples", positiveExamples); +} + +/** +* true, if this component needs reinitializsation. +* @return boolean +**/ +public boolean isReinitNecessary(){ +return reinitNecessary; +} + + +} Modified: trunk/src/dl-learner/org/dllearner/examples/KRKModular.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/examples/KRKModular.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -31,7 +31,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyAssertion; import org.dllearner.kb.KBFile; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.parser.KBParser; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; @@ -258,7 +258,7 @@ // ReasonerComponent rs = new ReasonerComponent(r); //cm.learningProblem(lpClass, reasoner) - LearningProblem lp = new PosNegDefinitionLP(r); + LearningProblem lp = new PosNegLPStandard(r); //cm.getConfigOptionValue(lp, ""); cm.applyConfigEntry(lp, "positiveExamples",pos); cm.applyConfigEntry(lp, "negativeExamples",neg); Modified: trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -49,7 +49,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.kb.OWLFile; -import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.learningproblems.PosOnlyLP; import org.dllearner.reasoning.DIGReasoner; /** @@ -168,7 +168,7 @@ exampleSet.add(individuals.get(i).toString()); // create a positive only learning problem - LearningProblem lp = cm.learningProblem(PosOnlyDefinitionLP.class, rs); + LearningProblem lp = cm.learningProblem(PosOnlyLP.class, rs); cm.applyConfigEntry(lp, "positiveExamples", exampleSet); try { lp.init(); Modified: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -51,7 +51,7 @@ import org.dllearner.algorithms.EvaluatedDescriptionPosNeg; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; /** * @author Tilo Hielscher @@ -417,7 +417,7 @@ // enable tree button if((config.getLearningAlgorithm() instanceof ExampleBasedROLComponent) - && (config.getLearningProblem() instanceof PosNegDefinitionLP)) { + && (config.getLearningProblem() instanceof PosNegLPStandard)) { treeButton.setEnabled(true); } } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -54,7 +54,7 @@ import org.dllearner.core.ReasonerComponent; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.kb.OWLFile; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.reasoning.FastInstanceChecker; /** @@ -128,7 +128,7 @@ ignoredKnowledgeSources.add(OWLAPIOntology.class); panels[0] = new ComponentPanel(config, this, KnowledgeSource.class, OWLFile.class, ignoredKnowledgeSources); panels[1] = new ComponentPanel(config, this, ReasonerComponent.class, FastInstanceChecker.class); - panels[2] = new ComponentPanel(config, this, LearningProblem.class, PosNegDefinitionLP.class); + panels[2] = new ComponentPanel(config, this, LearningProblem.class, PosNegLPStandard.class); panels[3] = new ComponentPanel(config, this, LearningAlgorithm.class, ExampleBasedROLComponent.class); runPanel = new RunPanel(config, this); Modified: trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/gui/TreeWindow.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -30,7 +30,7 @@ import org.dllearner.algorithms.refexamples.ExampleBasedNode; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; -import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLPStandard; /** * TreeWindow @@ -78,7 +78,7 @@ // ebNodeModel.getChildren((ExampleBasedNode) first)); // collect some helper values for display and accuracy calculations - PosNegDefinitionLP lp = (PosNegDefinitionLP) config.getLearningProblem(); + PosNegLPStandard lp = (PosNegLPStandard) config.getLearningProblem(); Set<String> posExamples = lp.getConfigurator().getPositiveExamples(); Set<String> negExamples = lp.getConfigurator().getNegativeExamples(); String baseURI = config.getReasoner().getBaseURI(); Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -111,4 +111,22 @@ public boolean isEquivalenceProblem() { return equivalence; } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningProblem#getAccuracy(org.dllearner.core.owl.Description) + */ + @Override + public double getAccuracy(Description description) { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningProblem#getAccuracyOrTooWeak(org.dllearner.core.owl.Description, double) + */ + @Override + public double getAccuracyOrTooWeak(Description description, double minAccuracy) { + // TODO Auto-generated method stub + return 0; + } } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -52,17 +52,15 @@ */ public double getProtusion() { return protusion; - } - - /** - * - * @return + } + + /* (non-Javadoc) + * @see org.dllearner.core.Score#getAccuracy() */ @Override - public double getScoreValue() { - - - throw new UnsupportedOperationException(); - } + public double getAccuracy() { + // TODO Auto-generated method stub + return 0; + } } Deleted: trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/learningproblems/DefinitionLP.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.learningproblems; - -/** - * Marker interface for definition learning problems. - * - * @author Jens Lehmann - * - */ -public interface DefinitionLP { - -} Deleted: trunk/src/dl-learner/org/dllearner/learningproblems/InclusionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/InclusionLP.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/learningproblems/InclusionLP.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -1,30 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.learningproblems; - -/** - * Marker interface for inclusion learning problems. - * - * @author Jens Lehmann - * - */ -public interface InclusionLP { - -} Deleted: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2009-02-12 18:34:45 UTC (rev 1601) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2009-02-13 11:06:53 UTC (rev 1602) @@ -1,232 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.learningproblems; - -import java.util.Collection; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.configurators.PosNegDefinitionLPConfigurator; -import org.dllearner.core.options.ConfigOption; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; -import org.dllearner.utilities.Helper; - -/** - * The aim of this learning problem is to learn a concept definition such that - * the positive examples and the negative examples do not follow. It is - * 2-valued, because we only distinguish between covered and non-covered - * examples. (A 3-valued problem distinguishes between covered examples, - * examples covered by the negation of the concept, and all other examples.) The - * 2-valued learning problem is often more useful for Description Logics due to - * (the Open World Assumption and) the fact that negative knowledge, e.g. that a - * person does not have a child, is or cannot be expressed. - * - * @author Jens Lehmann - * - */ -public class PosNegDefinitionLP extends PosNegLP implements DefinitionLP { - - private PosNegDefinitionLPConfigurator configurator; - @Override - public PosNegDefinitionLPConfigurator getConfigurator() { - return configurator; - } - - public PosNegDefinitionLP(ReasonerComponent reasoningService) { - super(reasoningService); - this.configurator = new PosNegDefinitionLPConfigurator(this); - } - - public PosNegDefinitionLP(ReasonerComponent reasoningService, SortedSet<Individual> positiveExamples, SortedSet<Individual> negativeExamples) { - super(reasoningService); - this.positiveExamples = positiveExamples; - this.negativeExamples = negativeExamples; - this.configurator = new PosNegDefinitionLPConfigurator(this); - } - - /* - * (non-Javadoc) - * - * @see org.dllearner.core.Component#getName() - */ - public static String getName() { - return "two valued definition learning problem"; - } - - - public static Collection<ConfigOption<?>> createConfigOptions() { - return PosNegLP.createConfigOptions(); - } - - /** - * This method computes (using the reasoner) whether a concept is too weak. - * If it is not weak, it returns the number of covered negative examples. It - * can use retrieval or instance checks for classification. - * - * @see org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks - * TODO: Performance could be slightly improved by counting the number of - * covers instead of using sets and counting their size. - * @param concept - * The concept to test. - * @return -1 if concept is too weak and the number of covered negative - * examples otherwise. - */ - @Override - public int coveredNegativeExamplesOrTooWeak(Description concept) { - - if (useRetrievalForClassification) { - SortedSet<Individual> posClassified = reasoner.getIndividuals(concept); - SortedSet<Individual> negAsPos = Helper.intersection(negativeExamples, posClassified); - SortedSet<Individual> posAsNeg = new TreeSet<Individual>(); - - // the set is constructed piecewise to avoid expensive set - // operations - // on a large number of individuals - for (Individual posExample : positiveExamples) { - if (!posClassified.contains(posExample)) - posAsNeg.add(posExample); - } - - // too weak - if (posAsNeg.size() > 0) - return -1; - // number of covered negatives - else - return negAsPos.size(); - } else { - if (useMultiInstanceChecks != UseMultiInstanceChecks.NEVER) { - // two checks - if (useMultiInstanceChecks == UseMultiInstanceChecks.TWOCHECKS) { - Set<Individual> s = reasoner.hasType(concept, positiveExamples); - // if the concept is too weak, then do not query negative - // examples - if (s.size() != positiveExamples.size()) - return -1; - else { - s = reasoner.hasType(concept, negativeExamples); - return s.size(); - } - // one check - } else { - Set<Individual> s = reasoner.hasType(concept, allExamples); - // test whether all positive examples are covered - if (s.containsAll(positiveExamples)) - return s.size() - positiveExamples.size(); - else - return -1; - } - } else { - // SortedSet<Individual> posAsNeg = new TreeSet<Individual>(); - SortedSet<Individual> negAsPos = new TreeSet<Individual>(); - - for (Individual example : positiveExamples) { - if (!reasoner.hasType(concept, example)) - return -1; - // posAsNeg.add(example); - } - for (Individual example : negativeExamples) { - if (reasoner.hasType(concept, example)) - negAsPos.add(example); - } - - return negAsPos.size(); - } - } - } - - /** - * Computes score of a given concept using the reasoner. Either retrieval or - * instance check are used. For the latter, this method treats - * <code>UseMultiInstanceChecks.TWO_CHECKS</code> as if it were - * <code>UseMultiInstanceChecks.ONE_CHECKS</code> (it does not make much sense - * to implement TWO_CHECKS in this function, because we have to test all - * examples to create a score object anyway). - * - * @see org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks - * @param concept - * The concept to test. - * @return Corresponding Score object. - */ - @Override - public ScorePosNeg computeScore(Description concept) { - if (useRetrievalForClassification) { - SortedSet<Individual> posClassified = reasoner.getIndividuals(concept); - SortedSet<Individual> posAsPos = Helper.intersection(positiveExamples, posClassified); - SortedSet<Individual> negAsPos = Helper.intersection(negativeExamples, posClassified); - SortedSet<Individual> posAsNeg = new TreeSet<Individual>(); - - // piecewise set construction - for (Individual posExample : positiveExamples) { - if (!posClassified.contains(posExample)) - posAsNeg.add(posExample); - } - SortedSet<Individual> negAsNeg = new TreeSet<Individual>(); - for (Individual negExample : negativeExamples) { - if (!posClassified.contains(negExample)) - negAsNeg.add(negExample); - } - return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg); - // instance checks for classification - } else { - SortedSet<Individual> posAsPos = new TreeSet<Individual>(); - SortedSet<Individual> posAsNeg = new TreeSet<Individual>(); - Sorte... [truncated message content] |