Node negativeLeftChild; Node positiveRightChild; if (child1.getPredicate() instanceof True) { negativeLeftChild = child1; positiveRightChild = child2; } else { Preconditions.checkArgument(child2.getPredicate() instanceof True); negativeLeftChild = child2; positiveRightChild = child1; Predicate predicate = positiveRightChild.getPredicate(); boolean defaultDecision = positiveRightChild.getId().equals(root.getDefaultChild());
Node rightChild = children.get(0); Node leftChild = children.get(1); assertInstanceOf(leftChild.getPredicate(), True.class); assertEquals(node.getRecordCount().doubleValue(), leftChild.getRecordCount() + rightChild.getRecordCount());
private void addCategoricalField(Node node){ this.replacedPredicates.put(node, (SimpleSetPredicate)node.getPredicate()); } }
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } }
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } }
private boolean isDefinedField(HasFieldReference<?> hasFieldReference){ FieldName name = hasFieldReference.getField(); Node ancestorNode = getAncestorNode(node -> hasFieldReference(node.getPredicate(), name)); return (ancestorNode != null); } }
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } }
static private Iterator<Node> getChildren(Node node){ Predicate predicate = node.getPredicate(); Predicate childPredicate = child.getPredicate();
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } List<Node> parentChildren = parentNode.getNodes(); if(parentChildren.size() != 1){ return; } boolean success = parentChildren.remove(node); if(!success){ throw new IllegalArgumentException(); } // End if if((MiningFunction.REGRESSION).equals(this.miningFunction)){ initScore(parentNode, node); } else if((MiningFunction.CLASSIFICATION).equals(this.miningFunction)){ initScoreDistribution(parentNode, node); } else { throw new IllegalArgumentException(); } } }
Node secondChild = children.get(1); Predicate firstPredicate = firstChild.getPredicate(); Predicate secondPredicate = secondChild.getPredicate();
private void makeDefault(Node node){ Predicate predicate = node.getPredicate(); CompoundPredicate compoundPredicate; if(predicate instanceof CompoundPredicate){ compoundPredicate = (CompoundPredicate)predicate; } else { compoundPredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.SURROGATE) .addPredicates(predicate); node.setPredicate(compoundPredicate); } compoundPredicate.addPredicates(new True()); }
@Override public void exitNode(Node node){ Double recordCount = node.getRecordCount(); Predicate predicate = node.getPredicate(); if(recordCount != null){ node.setRecordCount(null); } // End if if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } }
Node negativeLeftChild; Node positiveRightChild; if (child1.getPredicate() instanceof True) { negativeLeftChild = child1; positiveRightChild = child2; } else { Preconditions.checkArgument(child2.getPredicate() instanceof True); negativeLeftChild = child2; positiveRightChild = child1; Predicate predicate = positiveRightChild.getPredicate(); boolean defaultDecision = positiveRightChild.getId().equals(root.getDefaultChild());
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } if((MiningFunction.REGRESSION).equals(this.miningFunction)){ initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } else if((MiningFunction.CLASSIFICATION).equals(this.miningFunction)){ // Replace intermediate nodes, but not terminal nodes if(node.hasNodes()){ replaceChildWithGrandchildren(parentNode, node); } } else { throw new IllegalArgumentException(); } } }
@Override public void exitNode(Node node){ Predicate predicate = node.getPredicate(); if(predicate instanceof True){ Node parentNode = getParentNode(); if(parentNode == null){ return; } if((MiningFunction.REGRESSION).equals(this.miningFunction)){ initScore(parentNode, node); replaceChildWithGrandchildren(parentNode, node); } else if((MiningFunction.CLASSIFICATION).equals(this.miningFunction)){ // Replace intermediate nodes, but not terminal nodes if(node.hasNodes()){ replaceChildWithGrandchildren(parentNode, node); } } else { throw new IllegalArgumentException(); } } }
Node secondChild = children.get(1); Predicate firstPredicate = firstChild.getPredicate(); Predicate secondPredicate = secondChild.getPredicate();
Node secondChild = children.get(1); Predicate firstPredicate = firstChild.getPredicate(); Predicate secondPredicate = secondChild.getPredicate();
static public ComplexNode toComplexNode(Node node){ ComplexNode result = new ComplexNode() .setId(node.getId()) .setScore(node.getScore()) .setRecordCount(node.getRecordCount()) .setDefaultChild(node.getDefaultChild()) .setPredicate(node.getPredicate()); if(node.hasNodes()){ (result.getNodes()).addAll(node.getNodes()); } // End if if(node.hasScoreDistributions()){ (result.getScoreDistributions()).addAll(node.getScoreDistributions()); } return result; } }
value.setPredicate(node.getPredicate()); value.setPartition(node.getPartition());
value.setPredicate(node.getPredicate()); value.setPartition(node.getPartition());