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; }
private void reset() { // set all values back to their default values (used for running // the algorithm more than once) candidates.clear(); trees.clear(); currentSolution.clear(); bestEvaluatedDescription = learningProblem.evaluate(dataFactory.getOWLThing()); // we need to clone in order not to modify the learning problem currentPosExamples = new TreeSet<>(((PosNegLP) getLearningProblem()).getPositiveExamples()); currentNegExamples = new TreeSet<>(((PosNegLP) getLearningProblem()).getNegativeExamples()); startPosExamplesSize = currentPosExamples.size(); // startNegExamplesSize = currentNegExamples.size(); }
@Override public void run() { try { org.apache.log4j.Logger.getLogger("org.dllearner").setLevel(Level.toLevel(logLevel.toUpperCase())); } catch (Exception e) { logger.warn("Error setting log level to " + logLevel); } lp = context.getBean(AbstractClassExpressionLearningProblem.class); rs = lp.getReasoner(); expression = OWLAPIUtils.classExpressionPropertyExpanderChecked(this.expression, rs, dataFactory, true, logger); if (expression != null) { EvaluatedHypothesis ev = lp.evaluate(expression); if (ev instanceof EvaluatedDescriptionPosNeg) { logger.info("#EVAL# tp: " + ((EvaluatedDescriptionPosNeg) ev).getCoveredPositives().size()); logger.info("#EVAL# fp: " + ((EvaluatedDescriptionPosNeg) ev).getCoveredNegatives().size()); logger.info("#EVAL# tn: " + ((EvaluatedDescriptionPosNeg) ev).getNotCoveredNegatives().size()); logger.info("#EVAL# fn: " + ((EvaluatedDescriptionPosNeg) ev).getNotCoveredPositives().size()); } } else { logger.error("Expression is empty."); throw new RuntimeException("Expression is empty."); } } }
/** * 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(); } }
bestEvaluatedDescription = learningProblem.evaluate(bestDescription); bestEvaluatedDescriptions.add(bestEvaluatedDescription); } else { bestCombinedDescription = dataFactory.getOWLObjectUnionOf(bestEvaluatedDescription.getDescription(), bestDescription); bestEvaluatedDescription = learningProblem.evaluate(bestCombinedDescription); bestEvaluatedDescriptions.add(bestEvaluatedDescription); bestEvaluatedDescription = learningProblem.evaluate(niceDescription);