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; }
return new TreeModel() .setNode(root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT)
TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, miningSchema, rootNode) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT) .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD)
TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, miningSchema, rootNode) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT) .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD);
/** * Create an instance of {@link TreeModel } * */ public TreeModel createTreeModel() { return new TreeModel(); }
/** * Create an instance of {@link TreeModel } * */ public TreeModel createTreeModel() { return new TreeModel(); }
static public TreeModel encodeTreeModel(byte[] compressedTree, PredicateManager predicateManager, Schema schema){ Label label = new ContinuousLabel(null, DataType.DOUBLE); AtomicInteger idSequence = new AtomicInteger(1); ByteBufferWrapper buffer = new ByteBufferWrapper(compressedTree); Node root = encodeNode(new True(), idSequence, compressedTree, buffer, predicateManager, new CategoryManager(), schema); TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(label), root) .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD); return treeModel; }
private TreeModel encodeTreeModel(RGenericVector tree, Schema schema){ Node root = encodeNode(new True(), tree, schema); TreeModel treeModel = new TreeModel(this.miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT); return treeModel; }
public TreeModel encodeTreeModel(PredicateManager predicateManager, Schema schema){ org.dmg.pmml.tree.Node root = encodeNode(new True(), predicateManager, 0, schema); TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT) .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD) .setMathContext(MathContext.FLOAT); return treeModel; }
public TreeModel encodeTreeModel(PredicateManager predicateManager, Schema schema){ Node root = encodeNode(new True(), predicateManager, new CategoryManager(), 0, schema); TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT) .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD); return treeModel; }
public TreeModel encodeTreeModel(PredicateManager predicateManager, Schema schema){ org.dmg.pmml.tree.Node root = encodeNode(new True(), predicateManager, 0, schema); TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT) .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD) .setMathContext(MathContext.FLOAT); return treeModel; }
private TreeModel encodeTreeModel(MiningFunction miningFunction, RGenericVector tree, RGenericVector c_splits, Schema schema){ Node root = encodeNode(new True(), 0, tree, c_splits, new FlagManager(), new CategoryManager(), schema); TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT); return treeModel; }
private TreeModel encodeRegression(RGenericVector frame, RIntegerVector rowNames, RIntegerVector var, RIntegerVector n, int[][] splitInfo, RNumberVector<?> splits, RIntegerVector csplit, Schema schema){ RNumberVector<?> yval = (RNumberVector<?>)frame.getValue("yval"); ScoreEncoder scoreEncoder = new ScoreEncoder(){ @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; } }; Node root = encodeNode(new True(), 1, rowNames, var, n, splitInfo, splits, csplit, scoreEncoder, schema); TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root); return configureTreeModel(treeModel); }
private TreeModel encodeTreeModel(MiningFunction miningFunction, ScoreEncoder scoreEncoder, RGenericVector childNodeIDs, RNumberVector<?> splitVarIDs, RNumberVector<?> splitValues, RGenericVector terminalClassCounts, Schema schema){ RNumberVector<?> leftChildIDs = (RNumberVector<?>)childNodeIDs.getValue(0); RNumberVector<?> rightChildIDs = (RNumberVector<?>)childNodeIDs.getValue(1); Node root = encodeNode(new True(), 0, scoreEncoder, leftChildIDs, rightChildIDs, splitVarIDs, splitValues, terminalClassCounts, new CategoryManager(), schema); TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT); return treeModel; }
static private <M extends Model<M> & DecisionTreeModel> TreeModel encodeTreeModel(M model, PredicateManager predicateManager, MiningFunction miningFunction, ScoreEncoder scoreEncoder, Schema schema){ Node root = new Node() .setPredicate(new True()); encodeNode(root, model.rootNode(), predicateManager, new CategoryManager(), scoreEncoder, schema); TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT); return treeModel; }
public TreeModel encodeTreeModel(Schema schema){ org.dmg.pmml.tree.Node root = new org.dmg.pmml.tree.Node() .setPredicate(new True()); encodeNode(root, 0, schema); TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT) .setMissingValueStrategy(TreeModel.MissingValueStrategy.NONE) .setMathContext(MathContext.FLOAT); return treeModel; }
private <P extends Number> TreeModel encodeTreeModel(MiningFunction miningFunction, ScoreEncoder<P> scoreEncoder, List<? extends Number> leftDaughter, List<? extends Number> rightDaughter, List<P> nodepred, List<? extends Number> bestvar, List<Double> xbestsplit, Schema schema){ RGenericVector randomForest = getObject(); Node root = encodeNode(new True(), 0, scoreEncoder, leftDaughter, rightDaughter, bestvar, xbestsplit, nodepred, new CategoryManager(), schema); TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root) .setMissingValueStrategy(TreeModel.MissingValueStrategy.NULL_PREDICTION) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT); if(this.compact){ Visitor visitor = new RandomForestCompactor(); visitor.applyTo(treeModel); } return treeModel; }
static public <E extends Estimator & HasTree> TreeModel encodeTreeModel(E estimator, PredicateManager predicateManager, ScoreDistributionManager scoreDistributionManager, MiningFunction miningFunction, Schema schema){ Tree tree = estimator.getTree(); int[] leftChildren = tree.getChildrenLeft(); int[] rightChildren = tree.getChildrenRight(); int[] features = tree.getFeature(); double[] thresholds = tree.getThreshold(); double[] values = tree.getValues(); Node root = encodeNode(new True(), predicateManager, scoreDistributionManager, 0, leftChildren, rightChildren, features, thresholds, values, miningFunction, schema); TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root) .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT); ClassDictUtil.clearContent(tree); return treeModel; }
@Test public void transform(){ Node node1a = new BranchNode(); Node node2a = new BranchNode(); Node node2b = new LeafNode(); node1a.addNodes(node2a, node2b); Node node3a = new LeafNode(); node2a.addNodes(node3a); assertTrue(node1a.getNodes() instanceof ArrayList); assertTrue(node2a.getNodes() instanceof ArrayList); TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, new MiningSchema(), node1a); ArrayListTransformer transformer = new ArrayListTransformer(); transformer.applyTo(treeModel); assertTrue(node1a.getNodes() instanceof DoubletonList); assertTrue(node2a.getNodes() instanceof SingletonList); } }