treelite
Classes | Public Member Functions | Friends | List of all members
Tree::Node Class Reference

tree node More...

#include <tree.h>

Public Member Functions

int cleft () const
 index of left child
 
int cright () const
 index of right child
 
int cdefault () const
 index of default child when feature is missing
 
unsigned split_index () const
 feature index of split condition
 
bool default_left () const
 when feature is unknown, whether goes to left child
 
bool is_leaf () const
 whether current node is leaf node
 
tl_float leaf_value () const
 
const std::vector< tl_float > & leaf_vector () const
 
bool has_leaf_vector () const
 
tl_float threshold () const
 
int parent () const
 get parent of the node
 
bool is_left_child () const
 whether current node is left child
 
bool is_root () const
 whether current node is root
 
Operator comparison_op () const
 get comparison operator
 
const std::vector< uint32_t > & left_categories () const
 get categories for left child node
 
SplitFeatureType split_type () const
 get feature split type
 
bool has_data_count () const
 test whether this node has data count
 
size_t data_count () const
 get data count
 
bool has_sum_hess () const
 test whether this node has hessian sum
 
double sum_hess () const
 get hessian sum
 
bool has_gain () const
 test whether this node has gain value
 
double gain () const
 get gain value
 
bool missing_category_to_zero () const
 test whether missing values should be converted into zero; only applicable for categorical splits
 
void set_numerical_split (unsigned split_index, tl_float threshold, bool default_left, Operator cmp)
 create a numerical split More...
 
void set_categorical_split (unsigned split_index, bool default_left, bool missing_category_to_zero, const std::vector< uint32_t > &left_categories)
 create a categorical split More...
 
void set_leaf (tl_float value)
 set the leaf value of the node More...
 
void set_leaf_vector (const std::vector< tl_float > &leaf_vector)
 set the leaf vector of the node; useful for multi-class random forest classifier More...
 
void set_sum_hess (double sum_hess)
 set the hessian sum of the node More...
 
void set_data_count (size_t data_count)
 set the data count of the node More...
 
void set_gain (double gain)
 set the gain value of the node More...
 
void set_parent (int pidx, bool is_left_child=true)
 set parent of the node More...
 

Friends

class Tree
 

Detailed Description

tree node

Definition at line 26 of file tree.h.

Member Function Documentation

◆ has_leaf_vector()

bool has_leaf_vector ( ) const
inline
Returns
tests whether leaf node has a non-empty leaf vector

Definition at line 67 of file tree.h.

◆ leaf_value()

tl_float leaf_value ( ) const
inline
Returns
get leaf value of leaf node

Definition at line 54 of file tree.h.

◆ leaf_vector()

const std::vector<tl_float>& leaf_vector ( ) const
inline
Returns
get leaf vector of leaf node; useful for multi-class random forest classifier

Definition at line 61 of file tree.h.

◆ set_categorical_split()

void set_categorical_split ( unsigned  split_index,
bool  default_left,
bool  missing_category_to_zero,
const std::vector< uint32_t > &  left_categories 
)
inline

create a categorical split

Parameters
split_indexfeature index to split
thresholdthreshold value
default_leftthe default direction when feature is unknown
cmpcomparison operator to compare between feature value and threshold

Definition at line 152 of file tree.h.

◆ set_data_count()

void set_data_count ( size_t  data_count)
inline

set the data count of the node

Parameters
data_countdata count

Definition at line 195 of file tree.h.

◆ set_gain()

void set_gain ( double  gain)
inline

set the gain value of the node

Parameters
gaingain value

Definition at line 202 of file tree.h.

◆ set_leaf()

void set_leaf ( tl_float  value)
inline

set the leaf value of the node

Parameters
valueleaf value

Definition at line 167 of file tree.h.

◆ set_leaf_vector()

void set_leaf_vector ( const std::vector< tl_float > &  leaf_vector)
inline

set the leaf vector of the node; useful for multi-class random forest classifier

Parameters
leaf_vectorleaf vector

Definition at line 178 of file tree.h.

◆ set_numerical_split()

void set_numerical_split ( unsigned  split_index,
tl_float  threshold,
bool  default_left,
Operator  cmp 
)
inline

create a numerical split

Parameters
split_indexfeature index to split
thresholdthreshold value
default_leftthe default direction when feature is unknown
cmpcomparison operator to compare between feature value and threshold

Definition at line 135 of file tree.h.

◆ set_parent()

void set_parent ( int  pidx,
bool  is_left_child = true 
)
inline

set parent of the node

Parameters
pidxnode id of the parent
is_left_childwhether the node is left child or not

Definition at line 210 of file tree.h.

◆ set_sum_hess()

void set_sum_hess ( double  sum_hess)
inline

set the hessian sum of the node

Parameters
sum_hesshessian sum

Definition at line 188 of file tree.h.

◆ threshold()

tl_float threshold ( ) const
inline
Returns
get threshold of the node

Definition at line 71 of file tree.h.


The documentation for this class was generated from the following file: