From: <jen...@us...> - 2009-11-16 22:10:01
|
Revision: 1913 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1913&view=rev Author: jenslehmann Date: 2009-11-16 22:09:55 +0000 (Mon, 16 Nov 2009) Log Message: ----------- implemented CELOE single suggestion mode for learning problems with >1000 examples (i.e. all evaluations should be approximated for performance reasons) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -21,6 +21,7 @@ import java.text.DecimalFormat; import java.util.Collection; +import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -36,6 +37,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.CELOEConfigurator; +import org.dllearner.core.options.BooleanConfigOption; import org.dllearner.core.options.CommonConfigOptions; import org.dllearner.core.options.ConfigOption; import org.dllearner.core.owl.ClassHierarchy; @@ -95,6 +97,12 @@ private EvaluatedDescriptionSet bestEvaluatedDescriptions; + // if true, then each solution is evaluated exactly instead of approximately + // private boolean exactBestDescriptionEvaluation = false; + private boolean singleSuggestionMode; + private Description bestDescription; + private double bestAccuracy = Double.MIN_VALUE; + private NamedClass classToDescribe; // examples are either 1.) instances of the class to describe 2.) positive examples // 3.) union of pos.+neg. examples depending on the learning problem at hand @@ -154,6 +162,7 @@ options.add(CommonConfigOptions.getNoisePercentage()); options.add(CommonConfigOptions.getMaxDepth(7)); options.add(CommonConfigOptions.maxNrOfResults(10)); + options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false)); return options; } @@ -172,6 +181,8 @@ startClass = Thing.instance; + singleSuggestionMode = configurator.getSingleSuggestionMode(); + // create refinement operator operator = new RhoDRDown(reasoner, classHierarchy, startClass, configurator); baseURI = reasoner.getBaseURI(); @@ -246,7 +257,7 @@ int loop = 0; while (!terminationCriteriaSatisfied()) { - if(bestEvaluatedDescriptions.getBest().getAccuracy() > highestAccuracy) { + if(!singleSuggestionMode && bestEvaluatedDescriptions.getBest().getAccuracy() > highestAccuracy) { highestAccuracy = bestEvaluatedDescriptions.getBest().getAccuracy(); logger.info("more accurate (" + dfPercent.format(highestAccuracy) + ") class expression found: " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription())); } @@ -260,6 +271,11 @@ TreeSet<Description> refinements = refineNode(nextNode); mon.stop(); +// System.out.println("next node: " + nextNode); +// for(Description refinement : refinements) { +// System.out.println("refinement: " + refinement); +// } + while(refinements.size() != 0) { // pick element from set Description refinement = refinements.pollFirst(); @@ -269,24 +285,30 @@ // (this also avoids duplicate node children) if(length > horizExp && refinement.getDepth() <= maxDepth) { +// System.out.println("potentially adding " + refinement + " to search tree as child of " + nextNode + " " + new Date()); Monitor mon2 = MonitorFactory.start("addNode"); addNode(refinement, nextNode); mon2.stop(); - +// System.out.println("addNode finished" + " " + new Date()); } } updateMinMaxHorizExp(nextNode); +// System.out.println(loop); loop++; } - + if (stop) { logger.info("Algorithm stopped ("+expressionTests+" descriptions tested).\n"); } else { logger.info("Algorithm terminated successfully ("+expressionTests+" descriptions tested).\n"); } + + if(singleSuggestionMode) { + bestEvaluatedDescriptions.add(bestDescription, bestAccuracy, learningProblem); + } // print solution(s) logger.info("solutions:\n" + getSolutionString()); @@ -343,8 +365,10 @@ return false; } +// System.out.println("Test " + new Date()); // quality of description (return if too weak) double accuracy = learningProblem.getAccuracyOrTooWeak(description, noise); +// System.out.println("Test2 " + new Date()); expressionTests++; // System.out.println(description + " " + accuracy); if(accuracy == -1) { @@ -361,7 +385,19 @@ } nodes.add(node); +// System.out.println("Test3 " + new Date()); + // in some cases (e.g. mutation) fully evaluating even a single description is too expensive + // due to the high number of examples -- so we just stick to the approximate accuracy + if(singleSuggestionMode) { + if(accuracy > bestAccuracy) { + bestAccuracy = accuracy; + bestDescription = description; + logger.info("more accurate (" + dfPercent.format(bestAccuracy) + ") class expression found: " + descriptionToString(bestDescription)); + } + return true; + } + // maybe add to best descriptions (method keeps set size fixed); // we need to make sure that this does not get called more often than // necessary since rewriting is expensive @@ -374,6 +410,7 @@ (accuracy >= accThreshold && description.getLength() < worst.getDescriptionLength())); } +// System.out.println("Test4 " + new Date()); if(isCandidate) { Description niceDescription = rewriteNode(node); ConceptTransformation.transformToOrderedForm(niceDescription, descriptionComparator); @@ -383,18 +420,20 @@ // a subdescription of this one unless accuracy is different boolean shorterDescriptionExists = false; for(EvaluatedDescription ed : bestEvaluatedDescriptions.getSet()) { - if(ed.getAccuracy()==accuracy && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { + if(Math.abs(ed.getAccuracy()-accuracy) <= 0.00001 && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { shorterDescriptionExists = true; break; } } if(!shorterDescriptionExists) { - bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); + bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); } } +// System.out.println("Test5 " + new Date()); +// System.out.println("best evaluated descriptions size: " + bestEvaluatedDescriptions.size() + " worst: " + bestEvaluatedDescriptions.getWorst()); return true; } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -174,6 +174,15 @@ public int getMaxNrOfResults() { return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "maxNrOfResults") ; } +/** +* singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getSingleSuggestionMode() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "singleSuggestionMode") ; +} /** * @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. @@ -292,6 +301,15 @@ ComponentManager.getInstance().applyConfigEntry(cELOE, "maxNrOfResults", maxNrOfResults); reinitNecessary = true; } +/** +* @param singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setSingleSuggestionMode(boolean singleSuggestionMode) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "singleSuggestionMode", singleSuggestionMode); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -21,7 +21,6 @@ package org.dllearner.core.configurators; import java.util.Set; - import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.reasoning.PelletReasoner; @@ -73,7 +72,6 @@ reinitNecessary = true; } - /** * true, if this component needs reinitializsation. * @return boolean Modified: trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -63,6 +63,9 @@ private static boolean generatePosExampleClass = true; // set to true if accessing PostreSQL and false for MySQL private static boolean pgSQL = true; + // generate fragment => limits the number of individuals in the ontology + // to speed up learning +// private static boolean onlyFragment = true; public static void main(String[] args) throws ClassNotFoundException, BackingStoreException, SQLException { @@ -233,6 +236,10 @@ kb.addAxiom(new DatatypePropertyDomainAxiom(reliabilityDeltagProp, mutationClass)); kb.addAxiom(new DatatypePropertyRangeAxiom(reliabilityDeltagProp, Datatype.DOUBLE)); + if(generatePosExampleClass) { + kb.addAxiom(new SubClassAxiom(deleteriousMutationClass, mutationClass)); + } + // select data (restricted to pos/neg examples for efficiency) Statement stmt = conn.createStatement(); ResultSet rs = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |