From: <jen...@us...> - 2010-07-14 10:08:25
|
Revision: 2198 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2198&view=rev Author: jenslehmann Date: 2010-07-14 10:08:19 +0000 (Wed, 14 Jul 2010) Log Message: ----------- further work on heuristic unit tests Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-07-14 08:58:23 UTC (rev 2197) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2010-07-14 10:08:19 UTC (rev 2198) @@ -117,6 +117,24 @@ public int getMaxExecutionTimeInSeconds() { return (Integer) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "maxExecutionTimeInSeconds") ; } +/** +* betaSC Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for super class learning.. +* mandatory: false| reinit necessary: true +* default value: 3.0 +* @return double +**/ +public double getBetaSC() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "betaSC") ; +} +/** +* betaEq Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for equivalence class learning.. +* mandatory: false| reinit necessary: true +* default value: 1.0 +* @return double +**/ +public double getBetaEq() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "betaEq") ; +} /** * @param classToDescribe class of which a description should be learned. @@ -180,6 +198,24 @@ ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); reinitNecessary = true; } +/** +* @param betaSC Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for super class learning.. +* mandatory: false| reinit necessary: true +* default value: 3.0 +**/ +public void setBetaSC(double betaSC) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "betaSC", betaSC); +reinitNecessary = true; +} +/** +* @param betaEq Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for equivalence class learning.. +* mandatory: false| reinit necessary: true +* default value: 1.0 +**/ +public void setBetaEq(double betaEq) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "betaEq", betaEq); +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-07-14 08:58:23 UTC (rev 2197) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-07-14 10:08:19 UTC (rev 2198) @@ -112,6 +112,10 @@ BooleanConfigOption consistency = new BooleanConfigOption("checkConsistency", "Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.", true); options.add(consistency); options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10)); + DoubleConfigOption betaSC = new DoubleConfigOption("betaSC", "Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for super class learning.", 3.0); + options.add(betaSC); + DoubleConfigOption betaEq = new DoubleConfigOption("betaEq", "Higher values of beta rate recall higher than precision or in other words, covering the instances of the class to describe is more important even at the cost of covering additional instances. The actual implementation depends on the selected heuristic. This values is used only for equivalence class learning.", 1.0); + options.add(betaEq); return options; } @@ -159,9 +163,9 @@ maxExecutionTimeInSeconds = configurator.getMaxExecutionTimeInSeconds(); if(equivalence) { - coverageFactor = 1; + coverageFactor = configurator.getBetaEq(); } else { - coverageFactor = 3; + coverageFactor = configurator.getBetaSC(); } // we compute the instances of the super class to perform Modified: trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 08:58:23 UTC (rev 2197) +++ trunk/src/dl-learner/org/dllearner/test/junit/HeuristicTests.java 2010-07-14 10:08:19 UTC (rev 2198) @@ -33,6 +33,7 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.KB; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Thing; import org.dllearner.kb.KBFile; import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.reasoning.OWLAPIReasoner; @@ -64,28 +65,56 @@ ind[i] = new Individual(ns + "i" + i); } - // A1 has instances i0 to i19 + // assert individuals to owl:Thing (such that they exist in the knowledge base) + for(int i=0; i<100; i++) { + kb.addAxiom(new ClassAssertionAxiom(Thing.instance,ind[i])); + } + + // A0 has 20 instances (i0 to i19) for(int i=0; i<20; i++) { kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[i])); } - // A2 has instances i10 to i29 + // A1 has 20 instances (i10 to i29) for(int i=10; i<30; i++) { kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[i])); } + // A2 has 40 instances (i10 to i49) + for(int i=10; i<50; i++) { + kb.addAxiom(new ClassAssertionAxiom(nc[2],ind[i])); + } + ComponentManager cm = ComponentManager.getInstance(); KnowledgeSource ks = new KBFile(kb); ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); ClassLearningProblem problem = cm.learningProblem(ClassLearningProblem.class, reasoner); ks.init(); reasoner.init(); - + // evaluate A2 wrt. A1 using Jaccard HeuristicTests.configureClassLP(problem, nc[0], "jaccard"); // the value should be 10 (i10-i19) divided by 30 (i0-i29) assertEqualsClassLP(problem, nc[1], 1/(double)3); - + assertEqualsClassLP(problem, nc[2], 1/(double)5); + + HeuristicTests.configureClassLP(problem, nc[0], "pred_acc"); + // the value should be the sum of 10 (correct positives) and 970 (correct negatives) divided by 1000 + assertEqualsClassLP(problem, nc[1], (10+70)/(double)100); + assertEqualsClassLP(problem, nc[2], (10+50)/(double)100); + + HeuristicTests.configureClassLP(problem, nc[0], "fmeasure"); + // recall = precision = F1-score = 0.5 + assertEqualsClassLP(problem, nc[1], 0.5); + // recall = 0.5, precision = 0.25, F1-score = 0.33... + assertEqualsClassLP(problem, nc[2], 1/(double)3); + + // TODO: generalised F-Measure + + // TODO: test approximations + + // TODO: test super class learning + } // the class learning problem provides several ways to get the accuracy of a description, this method This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |