treelite
Public Member Functions | Friends | List of all members
TreeBuilder Class Reference

tree builder class More...

#include <frontend.h>

Public Member Functions

 TreeBuilder (const TreeBuilder &)=delete
 
 TreeBuilder (TreeBuilder &&)=default
 
TreeBuilderoperator= (const TreeBuilder &)=delete
 
TreeBuilderoperator= (TreeBuilder &&)=default
 
bool CreateNode (int node_key)
 Create an empty node within a tree. More...
 
bool DeleteNode (int node_key)
 Remove a node from a tree. More...
 
bool SetRootNode (int node_key)
 Set a node as the root of a tree. More...
 
bool SetNumericalTestNode (int node_key, unsigned feature_id, Operator op, tl_float threshold, bool default_left, int left_child_key, int right_child_key)
 Turn an empty node into a numerical test node; the test is in the form [feature value] OP [threshold]. Depending on the result of the test, either left or right child would be taken. More...
 
bool SetCategoricalTestNode (int node_key, unsigned feature_id, const std::vector< uint32_t > &left_categories, bool default_left, int left_child_key, int right_child_key)
 Turn an empty node into a categorical test node. A list defines all categories that would be classified as the left side. Categories are integers ranging from 0 to (n-1), where n is the number of categories in that particular feature. Let's assume n <= 64. More...
 
bool SetLeafNode (int node_key, tl_float leaf_value)
 Turn an empty node into a leaf node. More...
 
bool SetLeafVectorNode (int node_key, const std::vector< tl_float > &leaf_vector)
 Turn an empty node into a leaf vector node The leaf vector (collection of multiple leaf weights per leaf node) is useful for multi-class random forest classifier. More...
 

Friends

class ModelBuilder
 

Detailed Description

tree builder class

Definition at line 70 of file frontend.h.

Member Function Documentation

◆ CreateNode()

bool CreateNode ( int  node_key)

Create an empty node within a tree.

Parameters
node_keyunique integer key to identify the new node
Returns
whether successful

Definition at line 106 of file builder.cc.

◆ DeleteNode()

bool DeleteNode ( int  node_key)

Remove a node from a tree.

Parameters
node_keyunique integer key to identify the node to be removed
Returns
whether successful

Definition at line 115 of file builder.cc.

◆ SetCategoricalTestNode()

bool SetCategoricalTestNode ( int  node_key,
unsigned  feature_id,
const std::vector< uint32_t > &  left_categories,
bool  default_left,
int  left_child_key,
int  right_child_key 
)

Turn an empty node into a categorical test node. A list defines all categories that would be classified as the left side. Categories are integers ranging from 0 to (n-1), where n is the number of categories in that particular feature. Let's assume n <= 64.

Parameters
node_keyunique integer key to identify the node being modified; this node needs to be empty
feature_idid of feature
left_categorieslist of categories belonging to the left child
default_leftdefault direction for missing values
left_child_keyunique integer key to identify the left child node
right_child_keyunique integer key to identify the right child node
Returns
whether successful

Definition at line 187 of file builder.cc.

◆ SetLeafNode()

bool SetLeafNode ( int  node_key,
tl_float  leaf_value 
)

Turn an empty node into a leaf node.

Parameters
node_keyunique integer key to identify the node being modified; this node needs to be empty
leaf_valueleaf value (weight) of the leaf node
Returns
whether successful

Definition at line 225 of file builder.cc.

◆ SetLeafVectorNode()

bool SetLeafVectorNode ( int  node_key,
const std::vector< tl_float > &  leaf_vector 
)

Turn an empty node into a leaf vector node The leaf vector (collection of multiple leaf weights per leaf node) is useful for multi-class random forest classifier.

Parameters
node_keyunique integer key to identify the node being modified; this node needs to be empty
leaf_vectorleaf vector of the leaf node
Returns
whether successful

Definition at line 239 of file builder.cc.

◆ SetNumericalTestNode()

bool SetNumericalTestNode ( int  node_key,
unsigned  feature_id,
Operator  op,
tl_float  threshold,
bool  default_left,
int  left_child_key,
int  right_child_key 
)

Turn an empty node into a numerical test node; the test is in the form [feature value] OP [threshold]. Depending on the result of the test, either left or right child would be taken.

Parameters
node_keyunique integer key to identify the node being modified; this node needs to be empty
feature_idid of feature
opbinary operator to use in the test
thresholdthreshold value
default_leftdefault direction for missing values
left_child_keyunique integer key to identify the left child node
right_child_keyunique integer key to identify the right child node
Returns
whether successful

Definition at line 148 of file builder.cc.

◆ SetRootNode()

bool SetRootNode ( int  node_key)

Set a node as the root of a tree.

Parameters
node_keyunique integer key to identify the root node
Returns
whether successful

Definition at line 135 of file builder.cc.


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