Search in sources :

Example 1 with DecisionTreeNode

use of org.apache.ignite.ml.tree.DecisionTreeNode in project ignite by apache.

the class XGModelVisitor method visitXgModel.

/**
 * {@inheritDoc}
 */
@Override
public XGModelComposition visitXgModel(XGBoostModelParser.XgModelContext ctx) {
    List<DecisionTreeNode> trees = new ArrayList<>();
    Set<String> featureNames = new HashSet<>();
    for (XGBoostModelParser.XgTreeContext treeCtx : ctx.xgTree()) featureNames.addAll(treeDictionaryVisitor.visitXgTree(treeCtx));
    Map<String, Integer> dict = buildDictionary(featureNames);
    XGTreeVisitor treeVisitor = new XGTreeVisitor(dict);
    for (XGBoostModelParser.XgTreeContext treeCtx : ctx.xgTree()) {
        DecisionTreeNode treeNode = treeVisitor.visitXgTree(treeCtx);
        trees.add(treeNode);
    }
    return new XGModelComposition(dict, trees);
}
Also used : XGModelComposition(org.apache.ignite.ml.xgboost.XGModelComposition) ArrayList(java.util.ArrayList) XGBoostModelParser(org.apache.ignite.ml.xgboost.parser.XGBoostModelParser) DecisionTreeNode(org.apache.ignite.ml.tree.DecisionTreeNode) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DecisionTreeNode (org.apache.ignite.ml.tree.DecisionTreeNode)1 XGModelComposition (org.apache.ignite.ml.xgboost.XGModelComposition)1 XGBoostModelParser (org.apache.ignite.ml.xgboost.parser.XGBoostModelParser)1