Ejemplo n.º 1
0
  private Trail handleNoTrueChild(Trail trail) {
    TreeModel treeModel = getModel();

    TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy();
    switch (noTrueChildStrategy) {
      case RETURN_NULL_PREDICTION:
        return trail.selectNull();
      case RETURN_LAST_PREDICTION:
        Node lastPrediction = trail.getLastPrediction();

        // "Return the parent Node only if it specifies a score attribute"
        if (lastPrediction.hasScore()) {
          return trail.selectLastPrediction();
        }
        return trail.selectNull();
      default:
        throw new UnsupportedFeatureException(treeModel, noTrueChildStrategy);
    }
  }
Ejemplo n.º 2
0
  private Node evaluateTree(Trail trail, EvaluationContext context) {
    TreeModel treeModel = getModel();

    Node root = treeModel.getNode();

    Boolean status = evaluateNode(trail, root, context);

    if (status != null && status.booleanValue()) {
      trail = handleTrue(trail, root, context);

      Node node = trail.getResult();

      // "It is not possible that the scoring process ends in a Node which does not have a score
      // attribute"
      if (node != null && !node.hasScore()) {
        throw new InvalidFeatureException(node);
      }

      return node;
    }

    return null;
  }