Java Code Examples for org.dmg.pmml.tree.Node#getDefaultChild()
The following examples show how to use
org.dmg.pmml.tree.Node#getDefaultChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeResolver.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
@Override public VisitorAction visit(Node node){ Object defaultChild = node.getDefaultChild(); if(node.hasNodes()){ List<Node> children = node.getNodes(); for(int i = 0, max = children.size(); i < max; i++){ Node child = children.get(i); Object id = child.getId(); if(id != null && (id).equals(defaultChild)){ node.setDefaultChild(child); break; } } } return super.visit(node); }
Example 2
Source File: TreeModelCompactor.java From jpmml-lightgbm with GNU Affero General Public License v3.0 | 4 votes |
@Override public void enterNode(Node node){ Object id = node.getId(); Object score = node.getScore(); Object defaultChild = node.getDefaultChild(); if(id == null){ throw new IllegalArgumentException(); } // End if if(node.hasNodes()){ List<Node> children = node.getNodes(); if(children.size() != 2 || score != null || defaultChild == null){ throw new IllegalArgumentException(); } Node firstChild = children.get(0); Node secondChild = children.get(1); if(equalsNode(defaultChild, firstChild)){ children = swapChildren(node); firstChild = children.get(0); secondChild = children.get(1); } else if(equalsNode(defaultChild, secondChild)){ // Ignored } else { throw new IllegalArgumentException(); } node.setDefaultChild(null); secondChild.setPredicate(True.INSTANCE); } else { if(score == null || defaultChild != null){ throw new IllegalArgumentException(); } } node.setId(null); }
Example 3
Source File: TreeModelCompactor.java From jpmml-xgboost with GNU Affero General Public License v3.0 | 4 votes |
@Override public void enterNode(Node node){ Object id = node.getId(); Object score = node.getScore(); Object defaultChild = node.getDefaultChild(); if(id == null){ throw new IllegalArgumentException(); } // End if if(node.hasNodes()){ List<Node> children = node.getNodes(); if(children.size() != 2 || score != null || defaultChild == null){ throw new IllegalArgumentException(); } Node firstChild = children.get(0); Node secondChild = children.get(1); if(equalsNode(defaultChild, firstChild)){ children = swapChildren(node); firstChild = children.get(0); secondChild = children.get(1); } else if(equalsNode(defaultChild, secondChild)){ // Ignored } else { throw new IllegalArgumentException(); } node.setDefaultChild(null); secondChild.setPredicate(True.INSTANCE); } else { if(score == null || defaultChild != null){ throw new IllegalArgumentException(); } } node.setId(null); }