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
 
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, 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_parent (int pidx, bool is_left_child=true)
 set parent of the node More...
 

Friends

class Tree
 

Detailed Description

tree node

Definition at line 22 of file tree.h.

Member Function Documentation

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

Definition at line 63 of file tree.h.

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

Definition at line 50 of file tree.h.

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 57 of file tree.h.

void set_categorical_split ( unsigned  split_index,
bool  default_left,
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 119 of file tree.h.

void set_leaf ( tl_float  value)
inline

set the leaf value of the node

Parameters
valueleaf value

Definition at line 132 of file tree.h.

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 143 of file tree.h.

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 102 of file tree.h.

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 154 of file tree.h.

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

Definition at line 67 of file tree.h.


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