Search in sources :

Example 1 with True

use of org.dmg.pmml.True in project jpmml-r by jpmml.

the class GBMConverter method encodeTreeModel.

private TreeModel encodeTreeModel(MiningFunction miningFunction, RGenericVector tree, RGenericVector c_splits, Schema schema) {
    Node root = new Node().setId("1").setPredicate(new True());
    encodeNode(root, 0, tree, c_splits, schema);
    TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root).setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT);
    return treeModel;
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) Node(org.dmg.pmml.tree.Node) True(org.dmg.pmml.True)

Example 2 with True

use of org.dmg.pmml.True in project jpmml-r by jpmml.

the class IForestConverter method encodeTreeModel.

private TreeModel encodeTreeModel(RGenericVector trees, int index, Schema schema) {
    RIntegerVector nrnodes = (RIntegerVector) trees.getValue("nrnodes");
    RIntegerVector ntree = (RIntegerVector) trees.getValue("ntree");
    RIntegerVector nodeStatus = (RIntegerVector) trees.getValue("nodeStatus");
    RIntegerVector leftDaughter = (RIntegerVector) trees.getValue("lDaughter");
    RIntegerVector rightDaughter = (RIntegerVector) trees.getValue("rDaughter");
    RIntegerVector splitAtt = (RIntegerVector) trees.getValue("splitAtt");
    RDoubleVector splitPoint = (RDoubleVector) trees.getValue("splitPoint");
    RIntegerVector nSam = (RIntegerVector) trees.getValue("nSam");
    int rows = nrnodes.asScalar();
    int columns = ntree.asScalar();
    Node root = new Node().setPredicate(new True());
    encodeNode(root, 0, 0, FortranMatrixUtil.getColumn(nodeStatus.getValues(), rows, columns, index), FortranMatrixUtil.getColumn(nSam.getValues(), rows, columns, index), FortranMatrixUtil.getColumn(leftDaughter.getValues(), rows, columns, index), FortranMatrixUtil.getColumn(rightDaughter.getValues(), rows, columns, index), FortranMatrixUtil.getColumn(splitAtt.getValues(), rows, columns, index), FortranMatrixUtil.getColumn(splitPoint.getValues(), rows, columns, index), schema);
    TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root).setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
    return treeModel;
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) Node(org.dmg.pmml.tree.Node) True(org.dmg.pmml.True)

Example 3 with True

use of org.dmg.pmml.True in project jpmml-r by jpmml.

the class RangerConverter method encodeTreeModel.

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 = new Node().setPredicate(new True());
    encodeNode(root, 0, scoreEncoder, leftChildIDs, rightChildIDs, splitVarIDs, splitValues, terminalClassCounts, schema);
    TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root).setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
    return treeModel;
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) Node(org.dmg.pmml.tree.Node) True(org.dmg.pmml.True)

Example 4 with True

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

the class TreeModelCompactor method addCategoricalField.

private True addCategoricalField(SimpleSetPredicate simpleSetPredicate) {
    True truePredicate = new True();
    this.categoricalFields.put(truePredicate, simpleSetPredicate.getField());
    return truePredicate;
}
Also used : True(org.dmg.pmml.True)

Example 5 with True

use of org.dmg.pmml.True in project pyramid by cheng-li.

the class RegressionTree method encodeTreeModel.

// ======================PMML===========================
// this part follows the design of jpmml package
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;
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) True(org.dmg.pmml.True)

Aggregations

True (org.dmg.pmml.True)21 Node (org.dmg.pmml.tree.Node)9 TreeModel (org.dmg.pmml.tree.TreeModel)7 SimplePredicate (org.dmg.pmml.SimplePredicate)5 SimpleSetPredicate (org.dmg.pmml.SimpleSetPredicate)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 FieldName (org.dmg.pmml.FieldName)3 Predicate (org.dmg.pmml.Predicate)3 MiningModel (org.dmg.pmml.mining.MiningModel)3 Segment (org.dmg.pmml.mining.Segment)3 Segmentation (org.dmg.pmml.mining.Segmentation)3 List (java.util.List)2 Model (org.dmg.pmml.Model)2 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 Statement (com.github.javaparser.ast.stmt.Statement)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1