Search in sources :

Example 1 with Visitor

use of org.dmg.pmml.Visitor in project jpmml-sparkml by jpmml.

the class TreeModelUtil method encodeTreeModel.

public static TreeModel encodeTreeModel(org.apache.spark.ml.tree.Node node, PredicateManager predicateManager, MiningFunction miningFunction, Schema schema) {
    Node root = encodeNode(node, predicateManager, Collections.<FieldName, Set<String>>emptyMap(), miningFunction, schema).setPredicate(new True());
    TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root).setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
    String compact = TreeModelOptions.COMPACT;
    if (compact != null && Boolean.valueOf(compact)) {
        Visitor visitor = new TreeModelCompactor();
        visitor.applyTo(treeModel);
    }
    return treeModel;
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) DecisionTreeModel(org.apache.spark.ml.tree.DecisionTreeModel) HashSet(java.util.HashSet) Set(java.util.Set) Visitor(org.dmg.pmml.Visitor) InternalNode(org.apache.spark.ml.tree.InternalNode) Node(org.dmg.pmml.tree.Node) LeafNode(org.apache.spark.ml.tree.LeafNode) True(org.dmg.pmml.True) TreeModelCompactor(org.jpmml.sparkml.visitors.TreeModelCompactor) FieldName(org.dmg.pmml.FieldName)

Aggregations

HashSet (java.util.HashSet)1 Set (java.util.Set)1 DecisionTreeModel (org.apache.spark.ml.tree.DecisionTreeModel)1 InternalNode (org.apache.spark.ml.tree.InternalNode)1 LeafNode (org.apache.spark.ml.tree.LeafNode)1 FieldName (org.dmg.pmml.FieldName)1 True (org.dmg.pmml.True)1 Visitor (org.dmg.pmml.Visitor)1 Node (org.dmg.pmml.tree.Node)1 TreeModel (org.dmg.pmml.tree.TreeModel)1 TreeModelCompactor (org.jpmml.sparkml.visitors.TreeModelCompactor)1