private static void checkTreeModel(TreeModel treeModel) { assertEquals(TreeModel.SplitCharacteristic.BINARY_SPLIT, treeModel.getSplitCharacteristic()); assertEquals(TreeModel.MissingValueStrategy.DEFAULT_CHILD, treeModel.getMissingValueStrategy()); checkNode(treeModel.getNode()); }
@Override public VisitorAction visit(TreeModel treeModel){ TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); switch(missingValueStrategy){ case AGGREGATE_NODES: case WEIGHTED_CONFIDENCE: report(new UnsupportedAttributeException(treeModel, missingValueStrategy)); break; default: break; } return super.visit(treeModel); } }
@Override public void enterTreeModel(TreeModel treeModel){ TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); if(!(TreeModel.MissingValueStrategy.NONE).equals(missingValueStrategy) || !(TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION).equals(noTrueChildStrategy) || !(TreeModel.SplitCharacteristic.BINARY_SPLIT).equals(splitCharacteristic)){ throw new IllegalArgumentException(); } this.miningFunction = treeModel.getMiningFunction(); this.replacedPredicates.clear(); }
@Override public void enterTreeModel(TreeModel treeModel){ TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); if(!(TreeModel.MissingValueStrategy.DEFAULT_CHILD).equals(missingValueStrategy) || !(TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION).equals(noTrueChildStrategy) || !(TreeModel.SplitCharacteristic.BINARY_SPLIT).equals(splitCharacteristic)){ throw new IllegalArgumentException(); } }
@Override public void enterTreeModel(TreeModel treeModel){ TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); if(!(TreeModel.MissingValueStrategy.DEFAULT_CHILD).equals(missingValueStrategy) || !(TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION).equals(noTrueChildStrategy) || !(TreeModel.SplitCharacteristic.BINARY_SPLIT).equals(splitCharacteristic)){ throw new IllegalArgumentException(); } }
@Override public void enterTreeModel(TreeModel treeModel){ TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); if(!(TreeModel.MissingValueStrategy.DEFAULT_CHILD).equals(missingValueStrategy) || !(TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION).equals(noTrueChildStrategy) || !(TreeModel.SplitCharacteristic.BINARY_SPLIT).equals(splitCharacteristic)){ throw new IllegalArgumentException(); } }
@Override public void enterTreeModel(TreeModel treeModel){ TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); if(!(TreeModel.MissingValueStrategy.NONE).equals(missingValueStrategy) || !(TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION).equals(noTrueChildStrategy) || !(TreeModel.SplitCharacteristic.BINARY_SPLIT).equals(splitCharacteristic)){ throw new IllegalArgumentException(); } this.miningFunction = treeModel.getMiningFunction(); }
/** * @param parent The parent Node of the Node that evaluated to the missing value. * @param node The Node that evaluated to the missing value. */ private Trail handleMissingValue(Trail trail, Node parent, Node node, EvaluationContext context){ TreeModel treeModel = getModel(); TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); switch(missingValueStrategy){ case NULL_PREDICTION: return trail.selectNull(); case LAST_PREDICTION: return trail.selectLastPrediction(); case DEFAULT_CHILD: return handleDefaultChild(trail, parent, context); case NONE: return null; default: throw new UnsupportedAttributeException(treeModel, missingValueStrategy); } }