@Override public OWLClassExpression getCurrentlyBestDescription() { return currentBestSolution.getDescription(); }
@Override public OWLClassExpression getCurrentlyBestDescription() { return currentBestSolution.getDescription(); }
/** * @return the first, i.e. the shortest class OWLClassExpression of this node */ public OWLClassExpression getDesc() { return (equivalents.isEmpty()) ? null : equivalents.first().getDescription(); }
/** * @return a list which contains only the class expressions of this set. */ public List<OWLClassExpression> toDescriptionList() { List<OWLClassExpression> list = new LinkedList<>(); for(EvaluatedDescription<? extends Score> ed : set.descendingSet()) { list.add(ed.getDescription()); } return list; }
@Override public List<OWLClassExpression> getCurrentlyBestDescriptions(int nrOfDescriptions) { List<OWLClassExpression> bestDescriptions = new ArrayList<>(); for (EvaluatedDescription<? extends Score> evDesc : getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions)) { bestDescriptions.add(evDesc.getDescription()); } return bestDescriptions; }
/** * @see #getCurrentlyBestEvaluatedDescription() * @return The best class OWLClassExpression found by the learning algorithm so far. */ public OWLClassExpression getCurrentlyBestDescription() { return getCurrentlyBestEvaluatedDescription().getDescription(); }
@Override public OWLClassExpression getCurrentlyBestDescription() { EvaluatedDescription<? extends Score> ed = getCurrentlyBestEvaluatedDescription(); return ed == null ? null : ed.getDescription(); }
@Override public OWLClassExpression getCurrentlyBestDescription() { EvaluatedDescription<? extends Score> ed = getCurrentlyBestEvaluatedDescription(); return ed == null ? null : ed.getDescription(); }
private String solutionAsString(EvaluatedDescription ed) { return renderer.render(ed.getDescription()).replace("\n", "").replaceAll("\\\\s{2,}", " "); }
private String solutionAsString(EvaluatedDescription ed) { return renderer.render(ed.getDescription()).replace("\n", "").replaceAll("\\\\s{2,}", " "); }
@Override public int compare(EvaluatedDescription<? extends Score> ed1, EvaluatedDescription<? extends Score> ed2) { return ComparisonChain.start() .compare(ed1.getAccuracy(), ed2.getAccuracy()) // higher accuracy is better .compare(getLength(ed2), getLength(ed1)) // shorter is better .compare(ed1.getDescription(), ed2.getDescription()) // syntactic sorting .result(); }
@Override public int compare(EvaluatedRDFResourceTree tree1, EvaluatedRDFResourceTree tree2) { return ComparisonChain.start() .compare(getScore(tree1), getScore(tree2)) .compare(tree1.asEvaluatedDescription().getDescription(), tree2.asEvaluatedDescription().getDescription()) .result(); }
private LinkedHashSet<OWLSubClassOfAxiom> convertIntoAxioms(OWLOntologyManager manager, NavigableSet<? extends EvaluatedDescription> evaluatedDescriptions) { LinkedHashSet<OWLSubClassOfAxiom> axioms = new LinkedHashSet<>(evaluatedDescriptions.size()); OWLDataFactory factory = manager.getOWLDataFactory(); for (EvaluatedDescription description : evaluatedDescriptions.descendingSet()) { OWLAnnotation annotation = factory. getOWLAnnotation(BundleUtilities.PROBABILISTIC_ANNOTATION_PROPERTY, factory.getOWLLiteral(description.getAccuracy())); OWLSubClassOfAxiom axiom = factory. getOWLSubClassOfAxiom((OWLClassExpression) description.getDescription(), dummyClass, Collections.singleton(annotation)); axioms.add(axiom); } return axioms; }
@Override public List<EvaluatedAxiom<OWLSubClassOfAxiom>> getCurrentlyBestEvaluatedAxioms(int nrOfAxioms) { currentlyBestAxioms = new TreeSet<>(); for (EvaluatedDescription<? extends Score> ed : getCurrentlyBestEvaluatedDescriptions(nrOfAxioms)) { currentlyBestAxioms.add(new EvaluatedAxiom<>(df.getOWLSubClassOfAxiom(entityToDescribe, ed.getDescription()), new AxiomScore(ed.getAccuracy()))); } return new ArrayList<>(currentlyBestAxioms); }
private void showIfBetterSolutionsFound() { if(!singleSuggestionMode && bestEvaluatedDescriptions.getBestAccuracy() > currentHighestAccuracy) { currentHighestAccuracy = bestEvaluatedDescriptions.getBestAccuracy(); expressionTestCountLastImprovement = expressionTests; timeLastImprovement = System.nanoTime(); long durationInMillis = getCurrentRuntimeInMilliSeconds(); String durationStr = getDurationAsString(durationInMillis); logger.info("more accurate (" + dfPercent.format(currentHighestAccuracy) + ") class expression found after " + durationStr + ": " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription())); } }
private void showIfBetterSolutionsFound() { if(!singleSuggestionMode && bestEvaluatedDescriptions.getBestAccuracy() > currentHighestAccuracy) { currentHighestAccuracy = bestEvaluatedDescriptions.getBestAccuracy(); expressionTestCountLastImprovement = expressionTests; timeLastImprovement = System.nanoTime(); long durationInMillis = getCurrentRuntimeInMilliSeconds(); String durationStr = getDurationAsString(durationInMillis); // track new best accuracy if enabled if(keepTrackOfBestScore) { runtimeVsBestScore.put(getCurrentRuntimeInMilliSeconds(), currentHighestAccuracy); } logger.info("more accurate (" + dfPercent.format(currentHighestAccuracy) + ") class expression found after " + durationStr + ": " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription())); } }
@Override protected void learnAxioms() { if(batchMode) { runBatched(); } else { runIterative(); } currentlyBestEvaluatedDescriptions.forEach( ed -> currentlyBestAxioms.add( new EvaluatedAxiom<>(df.getOWLSubClassOfAxiom(entityToDescribe, ed.getDescription()), new AxiomScore(ed.getAccuracy())))); }
private String render(EvaluatedDescription ed) { return owlRenderer.render(ed.getDescription()) + dfPercent.format(ed.getAccuracy()); }
private String render(EvaluatedDescription ed) { return owlRenderer.render(ed.getDescription()) + dfPercent.format(ed.getAccuracy()); }
private void updateLearningProblem(EvaluatedDescription<? extends Score> partialSolution) { // get individuals covered by the solution SortedSet<OWLIndividual> coveredExamples = la.getReasoner().getIndividuals(partialSolution.getDescription()); // remove from pos examples as those are already covered currentPosExamples.removeAll(coveredExamples); // remove from neg examples as those will always be covered in the combined solution currentNegExamples.removeAll(coveredExamples); // update the learning problem itself // TODO do we need some re-init of the lp afterwards? if(lp instanceof PosNegLP) { ((PosNegLP) la.getLearningProblem()).setPositiveExamples(currentPosExamples); ((PosNegLP) la.getLearningProblem()).setNegativeExamples(currentNegExamples); } else if(lp instanceof PosOnlyLP) { ((PosOnlyLP) la.getLearningProblem()).setPositiveExamples(currentPosExamples); } else if(lp instanceof ClassLearningProblem){ // TODO } }