From: <Jen...@us...> - 2008-06-05 10:43:29
|
Revision: 942 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=942&view=rev Author: JensLehmann Date: 2008-06-05 03:43:24 -0700 (Thu, 05 Jun 2008) Log Message: ----------- updated statistics and cross validation script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-06-05 10:43:24 UTC (rev 942) @@ -163,19 +163,20 @@ options.add(new BooleanConfigOption("elitism", "specifies whether to use elitism in selection", true)); StringConfigOption algorithmType = new StringConfigOption("algorithmType", "algorithm type", "steadyState"); algorithmType.setAllowedValues(new String[] {"generational", "steadyState"}); - DoubleConfigOption mutationProb = new DoubleConfigOption("mutationProbablitiy", "mutation probability", 0.03); + options.add(algorithmType); + DoubleConfigOption mutationProb = new DoubleConfigOption("mutationProbability", "mutation probability", 0.03); mutationProb.setLowerLimit(0.0); mutationProb.setUpperLimit(1.0); options.add(mutationProb); - DoubleConfigOption crossoverProb = new DoubleConfigOption("crossoverProbablitiy", "crossover probability", 0.95); + DoubleConfigOption crossoverProb = new DoubleConfigOption("crossoverProbability", "crossover probability", 0.95); crossoverProb.setLowerLimit(0.0); crossoverProb.setUpperLimit(1.0); options.add(crossoverProb); - DoubleConfigOption hillClimbingProb = new DoubleConfigOption("hillClimbingProbablitiy", "hill climbing probability", 0.0); + DoubleConfigOption hillClimbingProb = new DoubleConfigOption("hillClimbingProbability", "hill climbing probability", 0.0); hillClimbingProb.setLowerLimit(0.0); hillClimbingProb.setUpperLimit(1.0); options.add(hillClimbingProb); - DoubleConfigOption refinementProb = new DoubleConfigOption("refinementProbablitiy", "refinement operator probability (values higher than 0 turn this into a hybrid GP algorithm - see publication)", 0.00); + DoubleConfigOption refinementProb = new DoubleConfigOption("refinementProbability", "refinement operator probability (values higher than 0 turn this into a hybrid GP algorithm - see publication)", 0.00); refinementProb.setLowerLimit(0.0); refinementProb.setUpperLimit(1.0); options.add(refinementProb); Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-06-05 10:43:24 UTC (rev 942) @@ -104,6 +104,7 @@ private LearningAlgorithm la; private LearningProblem lp; private ReasoningService rs; + private ReasonerComponent rc; /** * Entry point for CLI interface. @@ -183,10 +184,10 @@ // step 2: detect used reasoner ConfFileOption reasonerOption = parser.getConfOptionsByName("reasoner"); - ReasonerComponent reasoner = cm.reasoner(getReasonerClass(reasonerOption), sources); - configureComponent(cm, reasoner, componentPrefixMapping, parser); - initComponent(cm, reasoner); - rs = cm.reasoningService(reasoner); + rc = cm.reasoner(getReasonerClass(reasonerOption), sources); + configureComponent(cm, rc, componentPrefixMapping, parser); + initComponent(cm, rc); + rs = cm.reasoningService(rc); // step 3: detect learning problem ConfFileOption problemOption = parser.getConfOptionsByName("problem"); @@ -754,6 +755,10 @@ return lp; } + public ReasonerComponent getReasonerComponent() { + return rc; + } + public ReasoningService getReasoningService() { return rs; } @@ -829,4 +834,6 @@ return laClass; } + + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-06-05 10:43:24 UTC (rev 942) @@ -35,7 +35,6 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningMethodUnsupportedException; -import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; @@ -100,7 +99,7 @@ private SortedSet<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); private SortedSet<Individual> individuals; - private ReasoningService rs; +// private ReasoningService rs; private OWLAPIReasoner rc; private Set<KnowledgeSource> sources; @@ -177,7 +176,7 @@ atomicRoles = rc.getAtomicRoles(); individuals = rc.getIndividuals(); - rs = new ReasoningService(rc); +// rs = new ReasoningService(rc); // TODO: some code taken from Helper.createFlatABox, but pasted here // because additional things need to @@ -187,9 +186,9 @@ logger.debug("dematerialising concepts"); - for (NamedClass atomicConcept : rs.getAtomicConcepts()) { + for (NamedClass atomicConcept : rc.getAtomicConcepts()) { - SortedSet<Individual> pos = rs.retrieval(atomicConcept); + SortedSet<Individual> pos = rc.retrieval(atomicConcept); classInstancesPos.put(atomicConcept, pos); if(defaultNegation) { @@ -199,7 +198,7 @@ // on the carcinogenesis data set (and probably others), so we have to // be careful here Negation negatedAtomicConcept = new Negation(atomicConcept); - classInstancesNeg.put(atomicConcept, rs.retrieval(negatedAtomicConcept)); + classInstancesNeg.put(atomicConcept, rc.retrieval(negatedAtomicConcept)); } @@ -521,32 +520,32 @@ * @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set) */ public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { - rs.prepareSubsumptionHierarchy(); + rc.prepareSubsumptionHierarchy(allowedConcepts); } @Override public SubsumptionHierarchy getSubsumptionHierarchy() { - return rs.getSubsumptionHierarchy(); + return rc.getSubsumptionHierarchy(); } @Override public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { - rs.prepareRoleHierarchy(allowedRoles); + rc.prepareRoleHierarchy(allowedRoles); } @Override public ObjectPropertyHierarchy getRoleHierarchy() { - return rs.getRoleHierarchy(); + return rc.getRoleHierarchy(); } @Override public void prepareDatatypePropertyHierarchy(Set<DatatypeProperty> allowedRoles) { - rs.prepareDatatypePropertyHierarchy(allowedRoles); + rc.prepareDatatypePropertyHierarchy(allowedRoles); } @Override public DatatypePropertyHierarchy getDatatypePropertyHierarchy() { - return rs.getDatatypePropertyHierarchy(); + return rc.getDatatypePropertyHierarchy(); } @Override @@ -554,7 +553,7 @@ // Negation neg = new Negation(subConcept); // Intersection c = new Intersection(neg,superConcept); // return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); - return rs.subsumes(superConcept, subConcept); + return rc.subsumes(superConcept, subConcept); } /** Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-06-05 10:43:24 UTC (rev 942) @@ -474,6 +474,9 @@ private TreeSet<Description> getMoreSpecialConcepts(Description concept) { Set<Set<OWLClass>> classes = null; try { +// System.out.println(OWLAPIDescriptionConvertVisitor.getOWLDescription(concept)); +// System.out.println(getSubsumptionHierarchy()); +// System.out.println(reasoner); classes = reasoner.getSubClasses(OWLAPIDescriptionConvertVisitor.getOWLDescription(concept)); } catch (OWLReasonerException e) { e.printStackTrace(); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-06-05 10:43:24 UTC (rev 942) @@ -34,6 +34,7 @@ import org.apache.log4j.Logger; import org.dllearner.algorithms.refinement.RefinementOperator; +import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.DataRange; Modified: trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/scripts/CrossValidation.java 2008-06-05 10:43:24 UTC (rev 942) @@ -115,7 +115,8 @@ } LearningProblem lp = start.getLearningProblem(); - ReasoningService rs = start.getReasoningService(); +// ReasoningService rs = start.getReasoningService(); +// start.getReasoningService().releaseKB(); // the training and test sets used later on List<Set<Individual>> trainingSetsPos = new LinkedList<Set<Individual>>(); @@ -194,7 +195,6 @@ try { start = new Start(file); } catch (ComponentInitException e) { - // TODO Auto-generated catch block e.printStackTrace(); } lp = start.getLearningProblem(); @@ -206,17 +206,17 @@ // System.out.println("neg: " + neg.size()); // System.exit(0); - // es fehlt init zwischendurch - - if(la == null) - la = start.getLearningAlgorithm(); + la = start.getLearningAlgorithm(); // init again, because examples have changed try { +// start.getReasonerComponent().init(); + lp.init(); la.init(); } catch (ComponentInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } + long algorithmStartTime = System.nanoTime(); la.start(); long algorithmDuration = System.nanoTime() - algorithmStartTime; @@ -224,6 +224,7 @@ Description concept = la.getBestSolution(); + ReasoningService rs = start.getReasoningService(); Set<Individual> tmp = rs.instanceCheck(concept, testSetsPos.get(currFold)); Set<Individual> tmp2 = Helper.difference(testSetsPos.get(currFold), tmp); Set<Individual> tmp3 = rs.instanceCheck(concept, testSetsNeg.get(currFold)); @@ -258,7 +259,7 @@ System.out.println(" runtime: " + df.format(algorithmDuration/(double)1000000000) + "s"); // free all resources - start.getReasoningService().releaseKB(); + rs.releaseKB(); cm.freeAllComponents(); } @@ -312,7 +313,7 @@ return splits; } - private String statOutput(DecimalFormat df, Stat stat, String unit) { + public static String statOutput(DecimalFormat df, Stat stat, String unit) { String str = "av. " + df.format(stat.getMean()) + unit; str += " (deviation " + df.format(stat.getStandardDeviation()) + unit + "; "; str += "min " + df.format(stat.getMin()) + unit + "; "; Modified: trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java 2008-06-05 05:35:11 UTC (rev 941) +++ trunk/src/dl-learner/org/dllearner/scripts/PaperStatistics.java 2008-06-05 10:43:24 UTC (rev 942) @@ -22,6 +22,7 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; +import java.text.DecimalFormat; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,6 +50,8 @@ */ public class PaperStatistics { + private static DecimalFormat df = new DecimalFormat(); + /** * Points to the current statistic generation function. * @@ -82,7 +85,7 @@ // learning examples: // - trains - // - arches + // - arches => left out, insufficiently many examples // - moral (simple) // - moral (complex) // - poker (pair) @@ -95,22 +98,22 @@ String statBaseDir = "log/stat/"; File[] confFiles = new File[1]; -// confFiles[0] = new File(exampleBaseDir + "trains", "trains_owl"); - confFiles[0] = new File(exampleBaseDir + "arch", "arch"); -// confFiles[2] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_owl"); -// confFiles[3] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_complex_owl"); -// confFiles[4] = new File(exampleBaseDir + "poker", "pair_owl"); -// confFiles[5] = new File(exampleBaseDir + "poker", "straight_owl"); -// confFiles[6] = new File(exampleBaseDir + "forte", "forte_uncle_owl"); + confFiles[0] = new File(exampleBaseDir + "trains", "trains_owl"); +// confFiles[0] = new File(exampleBaseDir + "arch", "arch"); + confFiles[1] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_owl"); + confFiles[2] = new File(exampleBaseDir + "moral_reasoner", "moral_43examples_complex_owl"); + confFiles[3] = new File(exampleBaseDir + "poker", "pair_owl"); + confFiles[4] = new File(exampleBaseDir + "poker", "straight_owl"); + confFiles[5] = new File(exampleBaseDir + "forte", "forte_uncle_owl"); String[] examples = new String[7]; examples[0] = "trains"; - examples[1] = "arches"; - examples[2] = "moral reasoner (43 examples, simple)"; - examples[3] = "moral reasoner (43 examples, complex)"; - examples[4] = "poker (49 examples, pair)"; - examples[5] = "poker (55 examples, straight)"; - examples[6] = "uncle (FORTE data set)"; +// examples[0] = "arches"; + examples[1] = "moral reasoner (43 examples, simple)"; + examples[2] = "moral reasoner (43 examples, complex)"; + examples[3] = "poker (49 examples, pair)"; + examples[4] = "poker (55 examples, straight)"; + examples[5] = "uncle (FORTE data set)"; int startExampleNr = 0; // for any example, we create conf files for each configuration to be tested @@ -121,6 +124,8 @@ algorithmPostfix[3] = "_hybrid"; int startAlgorithmNr = 0; + int[] folds = new int[] {5,5,5,5,5,5}; + File statFile = new File(statBaseDir, "statistics.txt"); String statString = "**automatically generated statistics**\n\n"; @@ -132,16 +137,22 @@ File confFile = new File(confFiles[exampleNr] + algorithmPostfix[algorithmNr] + ".conf"); - CrossValidation cv = new CrossValidation(confFile, 5, false); - Stat classification = new Stat(); - Stat length = new Stat(); - Stat runtime = new Stat(); + System.out.println("running " + folds[exampleNr] + " fold cross validation on " + confFile); + CrossValidation cv = new CrossValidation(confFile, folds[exampleNr], false); + Stat accuracy = cv.getAccuracy(); + Stat length = cv.getLength(); + Stat runtime = cv.getRuntime(); + statString += "conf file: " + confFile + "\n"; - statString += "classification: " + classification.getMean() + "% (standard deviation: " + classification.getStandardDeviation() + "%)\n"; - statString += "concept length: " + length.getMean() + " (standard deviation: " + length.getStandardDeviation() + ")\n"; - statString += "runtime: " + Helper.prettyPrintNanoSeconds(Math.round(runtime.getMean())) + " (standard deviation: " + Helper.prettyPrintNanoSeconds(Math.round(runtime.getStandardDeviation())) + ")\n\n"; +// statString += "classification: " + classification.getMean() + "% (standard deviation: " + classification.getStandardDeviation() + "%)\n"; +// statString += "concept length: " + length.getMean() + " (standard deviation: " + length.getStandardDeviation() + ")\n"; +// statString += "runtime: " + runtime.getMean() + " (standard deviation: " + runtime.getStandardDeviation() + ")\n\n"; + statString += "accuracy: " + CrossValidation.statOutput(df, accuracy, "%") + "\n"; + statString += "length: " + CrossValidation.statOutput(df, length, "") + "\n"; + statString += "runtime: " + CrossValidation.statOutput(df, runtime, "s") + "\n\n"; + Files.createFile(statFile, statString); } // end algorithm loop This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |