use of org.dmg.pmml.tree.TreeModel in project jpmml-r by jpmml.
the class RangerConverter method encodeRegression.
private MiningModel encodeRegression(RGenericVector forest, Schema schema) {
ScoreEncoder scoreEncoder = new ScoreEncoder() {
@Override
public Node encode(Node node, Number splitValue, RNumberVector<?> terminalClassCount) {
node.setScore(splitValue);
return node;
}
};
List<TreeModel> treeModels = encodeForest(forest, MiningFunction.REGRESSION, scoreEncoder, schema);
MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel())).setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, treeModels));
return miningModel;
}
use of org.dmg.pmml.tree.TreeModel in project jpmml-r by jpmml.
the class BoostingConverter method encodeModel.
@Override
public Model encodeModel(Schema schema) {
RGenericVector boosting = getObject();
RGenericVector trees = boosting.getGenericElement("trees");
RDoubleVector weights = boosting.getDoubleElement("weights");
CategoricalLabel categoricalLabel = (CategoricalLabel) schema.getLabel();
List<TreeModel> treeModels = encodeTreeModels(trees);
MiningModel miningModel = new MiningModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel)).setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.WEIGHTED_MAJORITY_VOTE, treeModels, weights.getValues())).setOutput(ModelUtil.createProbabilityOutput(DataType.DOUBLE, categoricalLabel));
return miningModel;
}
use of org.dmg.pmml.tree.TreeModel in project jpmml-r by jpmml.
the class BinaryTreeConverter method encodeTreeModel.
private TreeModel encodeTreeModel(RGenericVector tree, Schema schema) {
Node root = encodeNode(tree, True.INSTANCE, schema);
TreeModel treeModel = new TreeModel(this.miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root).setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}
Aggregations