Node rootNode = new Node().setId("r").setRecordCount(dummyCount).setPredicate(new True()); .setId("r-") .setRecordCount(halfCount) .setPredicate(new True()) .setScore("-2.0"); Node right = new Node().setId("r+").setRecordCount(halfCount) .setPredicate(new SimplePredicate(FieldName.create("foo"), SimplePredicate.Operator.GREATER_THAN).setValue("3.14"))
Node rootNode = new Node().setId("r").setRecordCount(dummyCount).setPredicate(new True()); Node left = new Node().setId("r-").setRecordCount(halfCount).setPredicate(new True()); left.addScoreDistributions(new ScoreDistribution("apple", halfCount)); Node right = new Node().setId("r+").setRecordCount(halfCount) .setPredicate(new SimpleSetPredicate(FieldName.create("color"), SimpleSetPredicate.BooleanOperator.IS_NOT_IN,
@Override public VisitorAction visit(Node node){ node.setId(null); return super.visit(node); } };
node.setId(null);
node.setId(null);
node.setId(null);
node.setId(null);
node.setId(null);
private void encodeNode(org.dmg.pmml.tree.Node parent, int index, Schema schema){ parent.setId(String.valueOf(index + 1)); Node node = allNodes.get(index); if(!node.isLeaf()){ int splitIndex = node.getFeatureIndex(); Feature feature = schema.getFeature(splitIndex); org.dmg.pmml.tree.Node leftChild = new org.dmg.pmml.tree.Node() .setPredicate(encodePredicate(feature, node, true)); encodeNode(leftChild, node.getLeftChild().getId(), schema); org.dmg.pmml.tree.Node rightChild = new org.dmg.pmml.tree.Node() .setPredicate(encodePredicate(feature, node, false)); encodeNode(rightChild, node.getRightChild().getId(), schema); parent.addNodes(leftChild, rightChild); boolean defaultLeft = false; parent.setDefaultChild(defaultLeft ? leftChild.getId() : rightChild.getId()); } else { float value = (float)node.getValue(); parent.setScore(ValueUtil.formatValue(value)); } }