public static PMML buildDummyModel() { Node node = new Node().setRecordCount(123.0); TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, null, node); PMML pmml = PMMLUtils.buildSkeletonPMML(); pmml.addModels(treeModel); return pmml; }
private static PMML buildDummyModel() { Node node = new Node().setRecordCount(123.0); TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, null, node); PMML pmml = PMMLUtils.buildSkeletonPMML(); pmml.addModels(treeModel); return pmml; }
modelNode.setRecordCount((double) nodeCount);
Node rootNode = new Node().setId("r").setRecordCount(dummyCount).setPredicate(new True()); .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 Node encode(Node node, int offset){ Number score = yval.getValue(offset); Number recordCount = n.getValue(offset); node .setScore(score) .setRecordCount(recordCount.doubleValue()); return node; } };
@Override public Node encode(Node node, int offset){ String score = categories.get(this.classes.get(offset) - 1); Integer recordCount = n.getValue(offset); node .setScore(score) .setRecordCount(recordCount.doubleValue()); if(hasScoreDistribution){ node = NodeUtil.toComplexNode(node); List<ScoreDistribution> scoreDistributions = node.getScoreDistributions(); for(int i = 0; i < categories.size(); i++){ List<? extends Number> recordCounts = this.recordCounts.get(i); ScoreDistribution scoreDistribution = new ScoreDistribution() .setValue(categories.get(i)) .setRecordCount(recordCounts.get(offset).doubleValue()); scoreDistributions.add(scoreDistribution); } } return node; } };
@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); } }
@Override public void encode(Node node, LeafNode leafNode){ int index = ValueUtil.asInt(leafNode.prediction()); node.setScore(this.categoricalLabel.getValue(index)); ImpurityCalculator impurityCalculator = leafNode.impurityStats(); node.setRecordCount((double)impurityCalculator.count()); double[] stats = impurityCalculator.stats(); for(int i = 0; i < stats.length; i++){ ScoreDistribution scoreDistribution = new ScoreDistribution(this.categoricalLabel.getValue(i), stats[i]); node.addScoreDistributions(scoreDistribution); } } };
node.setRecordCount(recordCount);
.setRecordCount((double)this.internal_count_[index]) .setPredicate(predicate) .addNodes(leftChild, rightChild);