Search in sources :

Example 1 with RandomForestCompactor

use of org.jpmml.rexp.visitors.RandomForestCompactor in project jpmml-r by jpmml.

the class RandomForestConverter method encodeTreeModel.

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(True.INSTANCE, 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;
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) Visitor(org.dmg.pmml.Visitor) Node(org.dmg.pmml.tree.Node) BranchNode(org.dmg.pmml.tree.BranchNode) LeafNode(org.dmg.pmml.tree.LeafNode) CategoryManager(org.jpmml.converter.CategoryManager) RandomForestCompactor(org.jpmml.rexp.visitors.RandomForestCompactor)

Aggregations

Visitor (org.dmg.pmml.Visitor)1 BranchNode (org.dmg.pmml.tree.BranchNode)1 LeafNode (org.dmg.pmml.tree.LeafNode)1 Node (org.dmg.pmml.tree.Node)1 TreeModel (org.dmg.pmml.tree.TreeModel)1 CategoryManager (org.jpmml.converter.CategoryManager)1 RandomForestCompactor (org.jpmml.rexp.visitors.RandomForestCompactor)1