Treelite
|
in-memory representation of a decision tree More...
#include <tree.h>
Classes | |
struct | Node |
tree node More... | |
Public Member Functions | |
Tree (const Tree &)=delete | |
Tree & | operator= (const Tree &)=delete |
Tree (Tree &&)=default | |
Tree & | operator= (Tree &&)=default |
Tree | Clone () const |
std::vector< PyBufferFrame > | GetPyBuffer () |
void | InitFromPyBuffer (std::vector< PyBufferFrame > frames) |
void | Init () |
initialize the model with a single root node | |
void | AddChilds (int nid) |
add child nodes to node More... | |
std::vector< unsigned > | GetCategoricalFeatures () const |
get list of all categorical features that have appeared anywhere in tree More... | |
int | LeftChild (int nid) const |
Getters. More... | |
int | RightChild (int nid) const |
index of the node's right child More... | |
int | DefaultChild (int nid) const |
index of the node's "default" child, used when feature is missing More... | |
uint32_t | SplitIndex (int nid) const |
feature index of the node's split condition More... | |
bool | DefaultLeft (int nid) const |
whether to use the left child node, when the feature in the split condition is missing More... | |
bool | IsLeaf (int nid) const |
whether the node is leaf node More... | |
tl_float | LeafValue (int nid) const |
get leaf value of the leaf node More... | |
std::vector< tl_float > | LeafVector (int nid) const |
get leaf vector of the leaf node; useful for multi-class random forest classifier More... | |
bool | HasLeafVector (int nid) const |
tests whether the leaf node has a non-empty leaf vector More... | |
tl_float | Threshold (int nid) const |
get threshold of the node More... | |
Operator | ComparisonOp (int nid) const |
get comparison operator More... | |
std::vector< uint32_t > | LeftCategories (int nid) const |
Get list of all categories belonging to the left child node. Categories not in this list will belong to the right child node. Categories are integers ranging from 0 to (n-1), where n is the number of categories in that particular feature. This list is assumed to be in ascending order. More... | |
SplitFeatureType | SplitType (int nid) const |
get feature split type More... | |
bool | HasDataCount (int nid) const |
test whether this node has data count More... | |
uint64_t | DataCount (int nid) const |
get data count More... | |
bool | HasSumHess (int nid) const |
test whether this node has hessian sum More... | |
double | SumHess (int nid) const |
get hessian sum More... | |
bool | HasGain (int nid) const |
test whether this node has gain value More... | |
double | Gain (int nid) const |
get gain value More... | |
bool | MissingCategoryToZero (int nid) const |
test whether missing values should be converted into zero; only applicable for categorical splits More... | |
void | SetNumericalSplit (int nid, unsigned split_index, tl_float threshold, bool default_left, Operator cmp) |
Setters. More... | |
void | SetCategoricalSplit (int nid, unsigned split_index, bool default_left, bool missing_category_to_zero, const std::vector< uint32_t > &left_categories) |
create a categorical split More... | |
void | SetLeaf (int nid, tl_float value) |
set the leaf value of the node More... | |
void | SetLeafVector (int nid, const std::vector< tl_float > &leaf_vector) |
set the leaf vector of the node; useful for multi-class random forest classifier More... | |
void | SetSumHess (int nid, double sum_hess) |
set the hessian sum of the node More... | |
void | SetDataCount (int nid, uint64_t data_count) |
set the data count of the node More... | |
void | SetGain (int nid, double gain) |
set the gain value of the node More... | |
void | ReferenceSerialize (dmlc::Stream *fo) const |
Public Attributes | |
int | num_nodes |
number of nodes | |
|
inline |
add child nodes to node
nid | node id to add children to |
Definition at line 488 of file tree_impl.h.
|
inline |
get comparison operator
nid | ID of node being queried |
Definition at line 581 of file tree_impl.h.
|
inline |
|
inline |
index of the node's "default" child, used when feature is missing
nid | ID of node being queried |
Definition at line 534 of file tree_impl.h.
|
inline |
whether to use the left child node, when the feature in the split condition is missing
nid | ID of node being queried |
Definition at line 544 of file tree_impl.h.
|
inline |
|
inline |
get list of all categorical features that have appeared anywhere in tree
Definition at line 496 of file tree_impl.h.
|
inline |
test whether this node has data count
nid | ID of node being queried |
Definition at line 600 of file tree_impl.h.
|
inline |
test whether this node has gain value
nid | ID of node being queried |
Definition at line 620 of file tree_impl.h.
|
inline |
tests whether the leaf node has a non-empty leaf vector
nid | ID of node being queried |
Definition at line 568 of file tree_impl.h.
|
inline |
test whether this node has hessian sum
nid | ID of node being queried |
Definition at line 610 of file tree_impl.h.
|
inline |
whether the node is leaf node
nid | ID of node being queried |
Definition at line 549 of file tree_impl.h.
|
inline |
get leaf value of the leaf node
nid | ID of node being queried |
Definition at line 554 of file tree_impl.h.
|
inline |
get leaf vector of the leaf node; useful for multi-class random forest classifier
nid | ID of node being queried |
Definition at line 559 of file tree_impl.h.
|
inline |
Get list of all categories belonging to the left child node. Categories not in this list will belong to the right child node. Categories are integers ranging from 0 to (n-1), where n is the number of categories in that particular feature. This list is assumed to be in ascending order.
nid | ID of node being queried |
Definition at line 586 of file tree_impl.h.
|
inline |
Getters.
index of the node's left child
nid | ID of node being queried |
Definition at line 524 of file tree_impl.h.
|
inline |
test whether missing values should be converted into zero; only applicable for categorical splits
nid | ID of node being queried |
Definition at line 630 of file tree_impl.h.
|
inline |
index of the node's right child
nid | ID of node being queried |
Definition at line 529 of file tree_impl.h.
|
inline |
create a categorical split
nid | ID of node being updated |
split_index | feature index to split |
threshold | threshold value |
default_left | the default direction when feature is unknown |
cmp | comparison operator to compare between feature value and threshold |
Definition at line 649 of file tree_impl.h.
|
inline |
set the data count of the node
nid | ID of node being updated |
data_count | data count |
Definition at line 723 of file tree_impl.h.
|
inline |
set the gain value of the node
nid | ID of node being updated |
gain | gain value |
Definition at line 730 of file tree_impl.h.
|
inline |
set the leaf value of the node
nid | ID of node being updated |
value | leaf value |
Definition at line 682 of file tree_impl.h.
|
inline |
set the leaf vector of the node; useful for multi-class random forest classifier
nid | ID of node being updated |
leaf_vector | leaf vector |
Definition at line 691 of file tree_impl.h.
|
inline |
Setters.
create a numerical split
nid | ID of node being updated |
split_index | feature index to split |
threshold | threshold value |
default_left | the default direction when feature is unknown |
cmp | comparison operator to compare between feature value and threshold |
Definition at line 635 of file tree_impl.h.
|
inline |
set the hessian sum of the node
nid | ID of node being updated |
sum_hess | hessian sum |
Definition at line 716 of file tree_impl.h.
|
inline |
feature index of the node's split condition
nid | ID of node being queried |
Definition at line 539 of file tree_impl.h.
|
inline |
get feature split type
nid | ID of node being queried |
Definition at line 595 of file tree_impl.h.
|
inline |
|
inline |
get threshold of the node
nid | ID of node being queried |
Definition at line 576 of file tree_impl.h.