protected int getCorrectPosClassified(AbstractReasonerComponent rs, OWLClass concept, Set<OWLIndividual> testSetPos) { return rs.hasType(concept, testSetPos).size(); }
protected int getCorrectPosClassified(AbstractReasonerComponent rs, OWLClassExpression concept, Set<OWLIndividual> testSetPos) { return rs.hasType(concept, testSetPos).size(); }
protected int getCorrectNegClassified(AbstractReasonerComponent rs, OWLClass concept, Set<OWLIndividual> testSetNeg) { return testSetNeg.size() - rs.hasType(concept, testSetNeg).size(); }
protected int getCorrectNegClassified(AbstractReasonerComponent rs, OWLClassExpression concept, Set<OWLIndividual> testSetNeg) { return testSetNeg.size() - rs.hasType(concept, testSetNeg).size(); }
protected SortedSet<OWLIndividual> hasTypeImpl(OWLClassExpression concept, Set<OWLIndividual> individuals) throws ReasoningMethodUnsupportedException { SortedSet<OWLIndividual> returnSet = individuals.stream() .filter(individual -> hasType(concept, individual)) .collect(Collectors.toCollection(TreeSet::new)); return returnSet; }
public static void splitGroup(OWLClassExpression concept, OWLDataFactory dataFactory, AbstractReasonerComponent reasoner, SortedSet<OWLIndividual> posExs, SortedSet<OWLIndividual> posExsT, SortedSet<OWLIndividual> posExsF, SortedSet<OWLIndividual> posExsU) { OWLClassExpression negConcept = dataFactory.getOWLObjectComplementOf(concept); for ( OWLIndividual individual :posExs ){//int e=0; e<nodeExamples.size(); e++) { // int exIndex = nodeExamples.get(e); if (reasoner.hasType(concept, individual)) posExsT.add(individual); else if (reasoner.hasType(negConcept, individual)) posExsF.add(individual); else posExsU.add(individual); } }
private void splitGroup(OWLClassExpression concept, SortedSet<OWLIndividual> nodeExamples, SortedSet<OWLIndividual> posExsT, SortedSet<OWLIndividual> falseExs, SortedSet<OWLIndividual> posExsU) { OWLClassExpression negConcept = dataFactory.getOWLObjectComplementOf(concept); for ( OWLIndividual individual :nodeExamples ){//int e=0; e<nodeExamples.size(); e++) { // int exIndex = nodeExamples.get(e); if (reasoner.hasType(concept, individual)) posExsT.add(individual); else if (reasoner.hasType(negConcept, individual)) falseExs.add(individual); else posExsU.add(individual); } } /**
public static void splitting(OWLDataFactory df, AbstractReasonerComponent reasoner, OWLIndividual[] trainingExs, SortedSet<OWLIndividual> posExs, SortedSet<OWLIndividual> negExs, SortedSet<OWLIndividual> undExs, OWLClassExpression classToDescribe2, boolean binaryClassification) { for (OWLIndividual trainingEx : trainingExs) { if (reasoner.hasType(classToDescribe2, trainingEx)) posExs.add(trainingEx); else if (!binaryClassification) { OWLObjectComplementOf owlObjectComplementOf = df.getOWLObjectComplementOf(classToDescribe2); if (reasoner.hasType(owlObjectComplementOf, trainingEx)) negExs.add(trainingEx); else undExs.add(trainingEx); } else negExs.add(trainingEx); } }
private int getCorrectUndClassified(AbstractReasonerComponent rs, OWLClassExpression concept, Set<OWLIndividual> testUnd) { OWLDataFactory df = new OWLDataFactoryImpl(); OWLObjectComplementOf complementOfConcept = df.getOWLObjectComplementOf(concept); int nOfUnc=0; for (OWLIndividual ind:testUnd){ if ((!rs.hasType(concept, ind)) && !(rs.hasType(complementOfConcept, ind))) nOfUnc++; } return nOfUnc; }
private double crispAccuracy(OWLClassExpression description, double noise) { int maxNotCovered = (int) Math.ceil(noise*positiveExamples.size()); int notCoveredPos = 0; int notCoveredNeg = 0; for (OWLIndividual example : positiveExamples) { if (!getReasoner().hasType(description, example)) { notCoveredPos++; if(notCoveredPos >= maxNotCovered) { return -1; } } } for (OWLIndividual example : negativeExamples) { if (!getReasoner().hasType(description, example)) { notCoveredNeg++; } } return (positiveExamples.size() - notCoveredPos + notCoveredNeg) / (double) allExamples.size(); }
@Override public int getCorrectNegClassified(AbstractReasonerComponent rs, OWLClassExpression concept, Set<OWLIndividual> testSetNeg){ // for dealing explictly with the Open World Assumption OWLDataFactory df = new OWLDataFactoryImpl(); OWLObjectComplementOf complementOfConcept = df.getOWLObjectComplementOf(concept); // the real complement if it is exist return (rs.hasType (complementOfConcept, testSetNeg)).size(); }
private double crispfMeasure(OWLClassExpression description, double noise) { // crisp F-measure int additionalInstances = 0; for(OWLIndividual ind : negativeExamples) { if(getReasoner().hasType(description, ind)) { additionalInstances++; } } int coveredInstances = 0; for(OWLIndividual ind : positiveExamples) { if(getReasoner().hasType(description, ind)) { coveredInstances++; } } double recall = coveredInstances/(double)positiveExamples.size(); if(recall < 1 - noise) { return -1; } double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); return Heuristics.getFScore(recall, precision); }
@Override public ScorePosNeg<OWLNamedIndividual> computeScore(OWLClassExpression concept, double noise) { SortedSet<OWLIndividual> posAsPos = new TreeSet<>(); SortedSet<OWLIndividual> posAsNeg = new TreeSet<>(); SortedSet<OWLIndividual> negAsPos = new TreeSet<>(); SortedSet<OWLIndividual> negAsNeg = new TreeSet<>(); for (OWLIndividual example : positiveExamples) { if (getReasoner().hasType(concept, example)) { posAsPos.add(example); } else { posAsNeg.add(example); } } for (OWLIndividual example : negativeExamples) { if (getReasoner().hasType(concept, example)) negAsPos.add(example); else negAsNeg.add(example); } // TODO: this computes accuracy twice - more elegant method should be implemented double accuracy = getAccuracy(posAsPos.size(), posAsNeg.size(), negAsPos.size(), negAsNeg.size(), noise); return new ScoreTwoValued( OWLClassExpressionUtils.getLength(concept), getPercentPerLengthUnit(), posAsPos, posAsNeg, negAsPos, negAsNeg, accuracy); }
rv[i].total = sets[i].size(); SortedSet<OWLIndividual> trueSet = reasoner.hasType(trueConcept, sets[i]); SortedSet<OWLIndividual> falseSet = reasoner.hasType(falseConcept, sets[i]); rv[i].trueSet.addAll(trueSet); rv[i].falseSet.addAll(falseSet); if (getReasoner().hasType(trueConcept, example)) { rv[i].trueSet.add(example); } else if (getReasoner().hasType(falseConcept, example)) { rv[i].falseSet.add(example); } else {
result=-1; }else if (reasoner.hasType(rootClass, indTestEx)) stack.push(currentTree.getPosSubTree()); else if (reasoner.hasType(dataFactory.getOWLObjectComplementOf(rootClass), indTestEx)) stack.push(currentTree.getNegSubTree()); else { result=-1; }else if (reasoner.hasType(rootClass, indTestEx)) stack.push(currentTree.getPosSubTree()); else
Set<OWLIndividual> tmp = rs.hasType(concept, testPos); Set<OWLIndividual> tmp2 = Sets.difference(testPos, tmp); Set<OWLIndividual> tmp3 = rs.hasType(concept, testNeg); accuracy.addNumber(currAccuracy); int negAsPosTraining = rs.hasType(concept, trainNeg).size(); double precisionTraining = trainingCorrectPosClassified + negAsPosTraining == 0 ? 0 : trainingCorrectPosClassified / (double) (trainingCorrectPosClassified + negAsPosTraining); double recallTraining = trainingCorrectPosClassified / (double) trainPos.size(); fMeasureTraining.addNumber(100*Heuristics.getFScore(recallTraining, precisionTraining)); int negAsPos = rs.hasType(concept, testNeg).size(); double precision = correctPosClassified + negAsPos == 0 ? 0 : correctPosClassified / (double) (correctPosClassified + negAsPos); double recall = correctPosClassified / (double) testPos.size();
if(getReasoner().hasType(concept, example)) posClassified.add(example); if(getReasoner().hasType(concept, example)) posClassified.add(example); if(getReasoner().hasType(negatedConcept, example)) negClassified.add(example); if(getReasoner().hasType(negatedConcept, example)) negClassified.add(example);
if (getReasoner().hasType(concept, example)) { ++rv[i].trueCount; } else {