From: <jen...@us...> - 2010-02-18 10:00:50
|
Revision: 2062 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2062&view=rev Author: jenslehmann Date: 2010-02-18 10:00:44 +0000 (Thu, 18 Feb 2010) Log Message: ----------- added sanity checks for class lerning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-18 09:16:11 UTC (rev 2061) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2010-02-18 10:00:44 UTC (rev 2062) @@ -429,7 +429,7 @@ // returns true if node was added and false otherwise private boolean addNode(Description description, OENode parentNode) { -// System.out.println(description); + System.out.println(description); // redundancy check (return if redundant) boolean nonRedundant = descriptions.add(description); @@ -445,6 +445,12 @@ // System.out.println("Test " + new Date()); // quality of description (return if too weak) double accuracy = learningProblem.getAccuracyOrTooWeak(description, noise); + // issue a warning if accuracy is not between 0 and 1 or -1 (too weak) + if(accuracy > 1 || (accuracy < 0 || accuracy != -1)) { + logger.warn("Invalid accuracy value " + accuracy + " for description " + description + ". This could be caused by a bug in the heuristic measure and should be reported to the DL-Learner bug tracker."); + System.exit(0); + } + // System.out.println("Test2 " + new Date()); expressionTests++; // System.out.println("acc: " + accuracy); @@ -507,6 +513,8 @@ if(!shorterDescriptionExists) { if(!filterFollowsFromKB || !((ClassLearningProblem)learningProblem).followsFromKB(niceDescription)) { bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); +// System.out.println("acc: " + accuracy); +// System.out.println(bestEvaluatedDescriptions); } } @@ -659,6 +667,7 @@ str += current + ": " + descriptionToString(ed.getDescription()) + " (pred. acc.: " + dfPercent.format(((PosNegLPStandard)learningProblem).getPredAccuracyOrTooWeakExact(ed.getDescription(),1)) + ", F-measure: "+ dfPercent.format(((PosNegLPStandard)learningProblem).getFMeasureOrTooWeakExact(ed.getDescription(),1)) + ")\n"; } else { str += current + ": " + descriptionToString(ed.getDescription()) + " " + dfPercent.format(ed.getAccuracy()) + "\n"; + System.out.println(ed); } current++; } Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2010-02-18 09:16:11 UTC (rev 2061) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2010-02-18 10:00:44 UTC (rev 2062) @@ -193,15 +193,15 @@ try { start = new Start(file); } catch (FileNotFoundException e) { - System.out.println("The specified file " + file + " does not exist. See stack trace below."); + System.out.println("The specified file " + file + " does not exist. See stack trace."); e.printStackTrace(); System.exit(0); } catch (ComponentInitException e) { - System.out.println("A component could not be initialised. See stack trace below."); + System.out.println("A component could not be initialised. See stack trace."); e.printStackTrace(); System.exit(0); } catch (ParseException e) { - System.out.println("The specified file " + file + " is not a valid conf file. See stack trace below."); + System.out.println("The specified file " + file + " is not a valid conf file. See stack trace."); e.printStackTrace(); System.exit(0); } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-02-18 09:16:11 UTC (rev 2061) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2010-02-18 10:00:44 UTC (rev 2062) @@ -29,6 +29,7 @@ import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.ClassLearningProblemConfigurator; @@ -153,6 +154,11 @@ } classInstances = new LinkedList<Individual>(reasoner.getIndividuals(classToDescribe)); + // sanity check + if(classInstances.size() == 0) { + throw new ComponentInitException("Class " + classToDescribe + " has 0 instances according to \"" + ComponentManager.getInstance().getComponentName(reasoner.getClass()) + "\". Cannot perform class learning with 0 instances."); + } + classInstancesSet = new TreeSet<Individual>(classInstances); equivalence = (configurator.getType().equals("equivalence")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |