/** * @see Score#getAccuracy() * @return Value in this score system. */ public double getAccuracy() { return score.getAccuracy(); }
@Override public int compareTo(@NotNull EvaluatedHypothesis<T, S> o) { return ComparisonChain.start() .compare(score.getAccuracy(), o.score.getAccuracy()) .compare(hypothesis, o.getDescription()) .result(); }
private boolean stoppingCriteriaSatisfied() { // stop if we have a node covering all positives and none of the negatives // SearchTreeNode bestNode = candidates.last(); // return (bestNode.getCoveredNegatives() == 0); // 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) if(Double.compare(bestCurrentScore.getAccuracy(), minimumTreeScore) <= 0) { return true; } // stop when almost all positive examples have been covered if(tryFullCoverage) { return false; } else { int maxPosRemaining = (int) Math.ceil(startPosExamplesSize * 0.05d); return (currentPosExamples.size()<=maxPosRemaining); } }
private Set<OWLAxiom> asAnnotatedAxioms(Map<OWLAxiom, Score> axioms2Score){ Set<OWLAxiom> annotatedAxioms = new HashSet<>(); for (Entry<OWLAxiom, Score> entry : axioms2Score.entrySet()) { OWLAxiom axiom = entry.getKey(); Score score = entry.getValue(); if(score.getAccuracy() >= threshold){ annotatedAxioms.add(axiom.getAnnotatedAxiom( Collections.singleton(dataFactory.getOWLAnnotation(confidenceProperty, dataFactory.getOWLLiteral(score.getAccuracy()))))); } } return annotatedAxioms; }
/** * This convenience method can be used to store and exchange evaluated * descriptions by transforming them to a JSON string. * @return A JSON representation of an evaluated description. */ public String asJSON() { JSONObject object = new JSONObject(); try { object.put("descriptionManchesterSyntax", OWLAPIRenderers.toManchesterOWLSyntax(hypothesis)); object.put("descriptionOWLXML", OWLAPIRenderers.toOWLXMLSyntax(hypothesis)); object.put("scoreValue", score.getAccuracy()); return object.toString(3); } catch (JSONException e) { e.printStackTrace(); return null; } } }
@Override public int compare(SearchTreeNode o1, SearchTreeNode o2) { return ComparisonChain.start() .compare(o1.getScore().getAccuracy(), o2.getScore().getAccuracy()) .compare(o2.getDescriptionTree().size, o1.getDescriptionTree().size) .compare(o1.getDescriptionTree(), o2.getDescriptionTree(), cmp) .result(); }
@Override public JSONObject call() throws Exception { JSONObject result = new JSONObject(); JSONArray axiomArray = new JSONArray(); List<EvaluatedAxiom> axioms = getEvaluatedAxioms(ks, reasoner, entity, axiomType, maxExecutionTimeInSeconds, threshold, maxNrOfReturnedAxioms, useInference); for(EvaluatedAxiom ax : axioms){ JSONObject axiomObject = new JSONObject(); OWLAxiom axiom = ax.getAxiom(); axiomObject.put("axiom", axiom); axiomObject.put("axiom_rendered", renderer.render(axiom)); axiomObject.put("axiom_sparul", getSPARUL(axiom)); axiomObject.put("confidence", ax.getScore().getAccuracy()); axiomArray.put(axiomObject); } result.put("axiom_type", axiomType); result.put("axioms", axiomArray); return result; }
if(score.getAccuracy() != Double.NEGATIVE_INFINITY) { candidates.add(node); if(Double.compare(score.getAccuracy(), bestCurrentScore.getAccuracy()) > 0) { bestCurrentNode = node; bestCurrentScore = score;
@Override public int compare(SearchTreeNode tree1, SearchTreeNode tree2) { double diff = tree1.getScore().getAccuracy()-tree2.getScore().getAccuracy(); if(diff < 0.00001 && diff > -0.00001) { return edt.compare(tree1.getDescriptionTree(), tree2.getDescriptionTree()); } else if(diff > 0){ return 1; // return (int)Math.signum(diff); } else { return -1; } }
@Override public int compare(SearchTreeNode o1, SearchTreeNode o2) { // int diff = o2.getCoveredNegatives() - o1.getCoveredNegatives(); double score1 = o1.getScore().getAccuracy(); double score2 = o2.getScore().getAccuracy(); int diff = Double.compare(score1, score2); if(diff>0) { return 1; } else if(diff<0) { return -1; } else { double sizeDiff = o2.getDescriptionTree().getSize()- o1.getDescriptionTree().getSize(); if(sizeDiff == 0) { return cmp.compare(o1.getDescriptionTree(), o2.getDescriptionTree()); } else if(sizeDiff>0) { return 1; } else { return -1; } } }
public OWLOntology getGeneratedOntology(boolean withConfidenceAsAnnotations){ OWLOntology ontology = null; try { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = man.getOWLDataFactory(); OWLAnnotationProperty confAnnoProp = factory.getOWLAnnotationProperty(IRI.create(EnrichmentVocabulary.NS + "confidence")); Set<OWLAxiom> axioms = new HashSet<>(); for (EvaluatedAxiom evAx : learnedEvaluatedAxioms) { OWLAxiom ax = evAx.getAxiom(); if (withConfidenceAsAnnotations) { ax = ax.getAnnotatedAxiom(Collections.singleton(factory.getOWLAnnotation(confAnnoProp, factory.getOWLLiteral(evAx.getScore().getAccuracy())))); } axioms.add(ax); } ontology = man.createOntology(axioms); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return ontology; }
if(Double.compare(bestCurrentScore.getAccuracy(), minimumTreeScore) > 0) {
learnedAxioms.add(new EvaluatedAxiom<>(axiom, new AxiomScore(score.getAccuracy())));
learnedAxioms.add(new EvaluatedAxiom(axiom, new AxiomScore(score.getAccuracy())));
double accuracy = score.getAccuracy();