aboutsummaryrefslogtreecommitdiffstats
path: root/model-integration/src/main/java/ai/vespa/rankingexpression/importer/xgboost/XGBoostTree.java
blob: d05af980ac08d49b06787fff97f54adeadc58449 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.rankingexpression.importer.xgboost;

import java.util.List;

/**
 * Outlines the JSON representation used for parsing the XGBoost output file.
 *
 * @author grace-lam
 */
public class XGBoostTree {

    // ID of current node.
    private int nodeid;
    // Depth of current node w.r.t. the tree's root.
    private int depth;
    // Feature name used for split.
    private String split;
    // Feature value threshold to split on.
    private double split_condition;
    // Next node if feature value < split_condition.
    private int yes;
    // Next node if feature value >= split_condition.
    private int no;
    // Next node if feature value is missing.
    private int missing;
    // Response value for leaf node.
    private double leaf;
    // List of child nodes.
    private List<XGBoostTree> children;

    public int getNodeid() {
        return nodeid;
    }

    public int getDepth() {
        return depth;
    }

    public String getSplit() {
        return split;
    }

    public double getSplit_condition() {
        return split_condition;
    }

    public int getYes() {
        return yes;
    }

    public int getNo() {
        return no;
    }

    public int getMissing() {
        return missing;
    }

    public double getLeaf() {
        return leaf;
    }

    public List<XGBoostTree> getChildren() {
        return children;
    }

    /**
     * Check if current node is a leaf node.
     *
     * @return True if leaf, false otherwise.
     */
    public boolean isLeaf() {
        return children == null;
    }

}