public Node(EvaluatedDescription<? extends Score> ed, boolean root) { this.root = root; if (this.root) { accuracy = 0.0d; }else{ equivalents.add(ed); accuracy = ed.getAccuracy(); } }
public double getCurrentlyBestAccuracy() { return bestEvaluatedDescriptions.getBest().getAccuracy(); }
public double getCurrentlyBestAccuracy() { return bestEvaluatedDescriptions.getBest().getAccuracy(); }
@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(); }
private boolean stoppingCriteriaSatisfied() { // global time expired if(isTimeExpired()) { return true; } // stop if there are no more positive examples to cover if(stopOnFirstDefinition && currentPosExamples.size()==0) { return true; } // we stop when the score of the last tree added is too low // (indicating that the algorithm could not find anything appropriate // in the timeframe set) EvaluatedDescription<? extends Score> lastPartialSolution = Iterables.getLast(partialSolutions, null); if(lastPartialSolution != null && Double.compare(lastPartialSolution.getAccuracy(), minAccuracyPartialSolution) <= 0) { return true; } // stop when almost all positive examples have been covered if(tryFullCoverage) { return false; } else { int maxPosRemaining = (int) Math.ceil(initialPosExamples.size() * 0.05d); return (currentPosExamples.size()<=maxPosRemaining); } }
private boolean addPartialSolution(EvaluatedDescription<? extends Score> partialSolution) { // check whether partial solution follows criteria (currently only accuracy threshold) if(Double.compare(partialSolution.getAccuracy(), minAccuracyPartialSolution) > 0) { partialSolutions.add(partialSolution); // create combined solution OWLObjectUnionOf combinedCE = dataFactory.getOWLObjectUnionOf( partialSolutions.stream() .map(EvaluatedHypothesis::getDescription) .collect(Collectors.toSet())); // evalute combined solution EvaluatedDescription<? extends Score> combinedSolution = lp.evaluate(combinedCE); bestEvaluatedDescriptions.add(combinedSolution); return true; } return false; }
/** * @return the best accuracy so far or -Infinity if this set is empty. */ public double getBestAccuracy() { return set.isEmpty() ? Double.NEGATIVE_INFINITY : set.last().getAccuracy(); }
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; }
/** * Adds an class expression to this set. Some kind of lazy evaluation is applied, * i.e. an evaluated description is only generated if the given accuracy * is higher than the accuracy value of the worst evaluated description * contained in this set. * @param description the class expression * @param accuracy the accuracy of the class expression * @param problem the learning problem */ public void add(OWLClassExpression description, double accuracy, AbstractClassExpressionLearningProblem<? extends Score> problem) { // bug // http://sourceforge.net/tracker/?func=detail&atid=986319&aid=3029181&group_id=203619 // -> set should be filled up to max size before we compare acc. with // the worst result if (set.size() < maxSize || getWorst().getAccuracy() <= accuracy) { set.add(problem.evaluate(description)); } // delete the worst element if set is full if (set.size() > maxSize) { set.pollFirst(); } }
@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); }
@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())))); }
if(combinedSolution.getAccuracy() > bestScore){ bestCombinedSolution = combinedSolution; bestCurrentScore = combinedSolution.getAccuracy();
private <T extends OWLAxiom> List<T> convertIntoAxioms(Class<T> type, OWLOntologyManager manager, NavigableSet<? extends EvaluatedDescription> evaluatedDescriptions) { List<T> axioms = new LinkedList<>(); OWLDataFactory factory = manager.getOWLDataFactory(); for (EvaluatedDescription description : evaluatedDescriptions.descendingSet()) { OWLClassExpression ce = (OWLClassExpression) description.getDescription(); ce = OWLClassExpressionSimplifierVisitorImpl.getOWLClassExpression(ce, manager); OWLAnnotation annotation = factory. getOWLAnnotation(BundleUtilities.PROBABILISTIC_ANNOTATION_PROPERTY, factory.getOWLLiteral(description.getAccuracy())); // if (classAxiomType.equalsIgnoreCase("subClassOf") || classAxiomType.equalsIgnoreCase("both")) { T axiom; if (type == OWLEquivalentClassesAxiom.class) { axiom = (T) factory.getOWLEquivalentClassesAxiom(ce, dummyClass, Collections.singleton(annotation)); } else if (type == OWLSubClassOfAxiom.class) { axiom = (T) factory.getOWLSubClassOfAxiom(ce, dummyClass, Collections.singleton(annotation)); } else { throw new RuntimeException("convertIntoAxioms only works with " + "equivalent and subclassOf axioms"); } axioms.add(axiom); } return axioms; }
if(combinedSolution.getAccuracy() > bestScore){ bestCombinedSolution = combinedSolution; bestCurrentScore = combinedSolution.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()); }
if ( !(accuracyMethod instanceof AccMethodPredAcc) && !(accuracyMethod instanceof AccMethodFMeasure) ) { str += ", " + AnnComponentManager.getName(accuracyMethod) + ": " + dfPercent.format(ed.getAccuracy()); str += current + ": " + descriptionString + " " + dfPercent.format(ed.getAccuracy()) + "\n";
public synchronized List<? extends EvaluatedDescription<? extends Score>> getCurrentlyBestMostGeneralEvaluatedDescriptions() { List<? extends EvaluatedDescription<? extends Score>> l = getCurrentlyBestEvaluatedDescriptions(getCurrentlyBestEvaluatedDescriptions().last().getAccuracy()); DescriptionSubsumptionTree t = new DescriptionSubsumptionTree(reasoner); t.insert(l); return t.getMostGeneralDescriptions(true); }
if(!bestEvaluatedDescriptions.isFull() || bestEvaluatedDescriptions.getWorst().getAccuracy() < node.getAccuracy()) { EvaluatedDescription<Score> ed = new EvaluatedDescription<>(classExpression, score); bestEvaluatedDescriptions.add(ed);
private static void assertEqualsPosNegLPStandard(PosNegLPStandard problem, OWLClassExpression description, double accuracy) { assertEquals(accuracy, problem.getAccuracyOrTooWeak(description, 1.0), delta); assertEquals(accuracy, problem.computeScore(description, 1.0).getAccuracy(), delta); assertEquals(accuracy, problem.evaluate(description, 1.0).getAccuracy(), delta); }