本文整理汇总了Java中org.dmg.pmml.tree.Node.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getNodes方法的具体用法?Java Node.getNodes怎么用?Java Node.getNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmg.pmml.tree.Node
的用法示例。
在下文中一共展示了Node.getNodes方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleDefaultChild
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private Trail handleDefaultChild(Trail trail, Node node, EvaluationContext context){
// "The defaultChild missing value strategy requires the presence of the defaultChild attribute in every non-leaf Node"
String defaultChild = node.getDefaultChild();
if(defaultChild == null){
throw new MissingAttributeException(node, PMMLAttributes.NODE_DEFAULTCHILD);
}
trail.addMissingLevel();
List<Node> children = node.getNodes();
for(int i = 0, max = children.size(); i < max; i++){
Node child = children.get(i);
String id = child.getId();
if(id != null && (id).equals(defaultChild)){
// The predicate of the referenced Node is not evaluated
return handleTrue(trail, child, context);
}
}
// "Only Nodes which are immediate children of the respective Node can be referenced"
throw new InvalidAttributeException(node, PMMLAttributes.NODE_DEFAULTCHILD, defaultChild);
}
示例2: handleNodePop
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private void handleNodePop(Node node){
Double recordCount = node.getRecordCount();
String score = node.getScore();
Predicate predicate = node.getPredicate();
if(recordCount != null){
node.setRecordCount(null);
} // End if
if(predicate instanceof True){
Node parentNode = getParentNode();
if(parentNode == null){
return;
}
String parentScore = parentNode.getScore();
if(parentScore != null){
throw new IllegalArgumentException();
}
parentNode.setScore(score);
List<Node> parentChildren = parentNode.getNodes();
boolean success = parentChildren.remove(node);
if(!success){
throw new IllegalArgumentException();
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
parentChildren.addAll(children);
}
}
}
示例3: checkNode
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private static void checkNode(Node node) {
assertNotNull(node.getId());
List<ScoreDistribution> scoreDists = node.getScoreDistributions();
int numDists = scoreDists.size();
if (numDists == 0) {
// Non-leaf
List<Node> children = node.getNodes();
assertEquals(2, children.size());
Node rightChild = children.get(0);
Node leftChild = children.get(1);
assertInstanceOf(leftChild.getPredicate(), True.class);
assertEquals(node.getRecordCount().doubleValue(),
leftChild.getRecordCount() + rightChild.getRecordCount());
assertEquals(node.getId() + "+", rightChild.getId());
assertEquals(node.getId() + "-", leftChild.getId());
checkNode(rightChild);
checkNode(leftChild);
} else {
// Leaf
assertRange(numDists, 1, 2);
ScoreDistribution first = scoreDists.get(0);
if (numDists == 1) {
assertEquals(1.0, first.getConfidence().doubleValue());
} else {
assertGreater(first.getConfidence(), 0.0);
assertLess(first.getConfidence(), 1.0);
ScoreDistribution second = scoreDists.get(1);
assertGreater(second.getConfidence(), 0.0);
assertLess(second.getConfidence(), 1.0);
}
}
}
示例4: handleNodePop
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private void handleNodePop(Node node){
String score = node.getScore();
Predicate predicate = node.getPredicate();
if(predicate instanceof True){
Node parentNode = getParentNode();
if(parentNode == null){
return;
}
String parentScore = parentNode.getScore();
if(parentScore != null){
throw new IllegalArgumentException();
}
parentNode.setScore(score);
List<Node> parentChildren = parentNode.getNodes();
boolean success = parentChildren.remove(node);
if(!success){
throw new IllegalArgumentException();
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
parentChildren.addAll(children);
}
}
}
示例5: visit
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
@Override
public VisitorAction visit(Node node){
if(node.hasNodes()){
List<Node> children = node.getNodes();
children:
while(true){
ListIterator<Node> childIt = children.listIterator();
grandChildren:
while(childIt.hasNext()){
Node child = childIt.next();
Iterator<Node> grandChildIt = getChildren(child);
if(grandChildIt == null){
continue grandChildren;
}
childIt.remove();
while(grandChildIt.hasNext()){
Node grandChild = grandChildIt.next();
grandChildIt.remove();
childIt.add(grandChild);
}
childIt.add(child);
continue children;
}
break;
}
}
return super.visit(node);
}
示例6: getChildren
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
static
private Iterator<Node> getChildren(Node node){
Predicate predicate = node.getPredicate();
if(!(predicate instanceof SimplePredicate)){
return null;
}
SimplePredicate simplePredicate = (SimplePredicate)predicate;
FieldName name = simplePredicate.getField();
SimplePredicate.Operator operator = simplePredicate.getOperator();
if(!(SimplePredicate.Operator.LESS_OR_EQUAL).equals(operator)){
return null;
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
int endPos = 0;
for(Node child : children){
if(!checkPredicate(child, name, operator)){
break;
}
endPos++;
}
if(endPos > 0){
return (children.subList(0, endPos)).iterator();
}
return null;
}
return null;
}
示例7: handleTrue
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private Trail handleTrue(Trail trail, Node node, EvaluationContext context){
// A "true" leaf node
if(!node.hasNodes()){
return trail.selectNode(node);
}
trail.push(node);
List<Node> children = node.getNodes();
for(int i = 0, max = children.size(); i < max; i++){
Node child = children.get(i);
Boolean status = evaluateNode(trail, child, context);
if(status == null){
Trail destination = handleMissingValue(trail, node, child, context);
if(destination != null){
return destination;
}
} else
if(status.booleanValue()){
return handleTrue(trail, child, context);
}
}
// A "true" non-leaf node
return handleNoTrueChild(trail);
}
示例8: collectNodes
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private ImmutableBiMap.Builder<String, Node> collectNodes(Node node, AtomicInteger index, ImmutableBiMap.Builder<String, Node> builder){
builder = EntityUtil.put(node, index, builder);
if(!node.hasNodes()){
return builder;
}
List<Node> children = node.getNodes();
for(Node child : children){
builder = collectNodes(child, index, builder);
}
return builder;
}
示例9: visit
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
@Override
public VisitorAction visit(Node node){
if(node.hasNodes()){
List<Node> nodes = node.getNodes();
Collections.sort(nodes, NodeSorter.COMPARATOR);
}
return super.visit(node);
}
示例10: handleNodePush
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private void handleNodePush(Node node){
String defaultChild = node.getDefaultChild();
String id = node.getId();
String score = node.getScore();
if(id == null){
throw new IllegalArgumentException();
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
if(children.size() != 2 || defaultChild == null || score != null){
throw new IllegalArgumentException();
}
Node firstChild = children.get(0);
Node secondChild = children.get(1);
if((defaultChild).equals(firstChild.getId())){
children.remove(0);
children.add(1, firstChild);
firstChild = children.get(0);
secondChild = children.get(1);
} else
if((defaultChild).equals(secondChild.getId())){
// Ignored
} else
{
throw new IllegalArgumentException();
}
node.setDefaultChild(null);
secondChild.setPredicate(new True());
} else
{
if(defaultChild != null || score == null){
throw new IllegalArgumentException();
}
}
node.setId(null);
}
示例11: handleNodePush
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private void handleNodePush(Node node){
String id = node.getId();
String score = node.getScore();
if(id == null){
throw new IllegalArgumentException();
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
if(children.size() != 2 || score != null){
throw new IllegalArgumentException();
}
Node firstChild = children.get(0);
Node secondChild = children.get(1);
SimplePredicate firstPredicate = (SimplePredicate)firstChild.getPredicate();
SimplePredicate secondPredicate = (SimplePredicate)secondChild.getPredicate();
if(!(firstPredicate.getField()).equals(secondPredicate.getField()) || !(firstPredicate.getValue()).equals(secondPredicate.getValue())){
throw new IllegalArgumentException();
} // End if
if((SimplePredicate.Operator.NOT_EQUAL).equals(firstPredicate.getOperator()) && (SimplePredicate.Operator.EQUAL).equals(secondPredicate.getOperator())){
children.remove(0);
children.add(1, firstChild);
firstChild = children.get(0);
secondChild = children.get(1);
} else
if((SimplePredicate.Operator.LESS_OR_EQUAL).equals(firstPredicate.getOperator()) && (SimplePredicate.Operator.GREATER_THAN).equals(secondPredicate.getOperator())){
// Ignored
} else
{
throw new IllegalArgumentException();
}
secondChild.setPredicate(new True());
} else
{
if(score == null){
throw new IllegalArgumentException();
}
}
node.setId(null);
}
示例12: handleNodePop
import org.dmg.pmml.tree.Node; //导入方法依赖的package包/类
private void handleNodePop(Node node){
String score = node.getScore();
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();
}
String parentScore = parentNode.getScore();
if(parentScore != null){
throw new IllegalArgumentException();
}
parentNode.setScore(score);
if((MiningFunction.REGRESSION).equals(this.miningFunction)){
// Ignored
} else
if((MiningFunction.CLASSIFICATION).equals(this.miningFunction)){
Double recordCount = node.getRecordCount();
List<ScoreDistribution> scoreDistributions = node.getScoreDistributions();
Double parentRecordCount = parentNode.getRecordCount();
if(parentRecordCount != null){
throw new IllegalArgumentException();
}
parentNode.setRecordCount(recordCount);
List<ScoreDistribution> parentScoreDistributions = parentNode.getScoreDistributions();
if(parentScoreDistributions.size() != 0){
throw new IllegalArgumentException();
}
parentScoreDistributions.addAll(scoreDistributions);
} else
{
throw new IllegalArgumentException();
}
}
}