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));
}
}