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
 
void CreateNode (int node_key)
 Create an empty node within a tree. More...
 
void DeleteNode (int node_key)
 Remove a node from a tree. More...
 
void SetRootNode (int node_key)
 Set a node as the root of a tree. More...
 
void SetNumericalTestNode (int node_key, unsigned feature_id, const char *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...
 
void SetNumericalTestNode (int node_key, unsigned feature_id, Operator op, tl_float threshold, bool default_left, int left_child_key, int right_child_key)
 
void 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...
 
void SetLeafNode (int node_key, tl_float leaf_value)
 Turn an empty node into a leaf node. More...
 
void 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()

void CreateNode ( int  node_key)

Create an empty node within a tree.

Parameters
node_keyunique integer key to identify the new node

Definition at line 98 of file builder.cc.

◆ DeleteNode()

void DeleteNode ( int  node_key)

Remove a node from a tree.

Parameters
node_keyunique integer key to identify the node to be removed

Definition at line 105 of file builder.cc.

◆ SetCategoricalTestNode()

void 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

Definition at line 185 of file builder.cc.

◆ SetLeafNode()

void 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

Definition at line 219 of file builder.cc.

◆ SetLeafVectorNode()

void 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

Definition at line 230 of file builder.cc.

◆ SetNumericalTestNode()

void SetNumericalTestNode ( int  node_key,
unsigned  feature_id,
const char *  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

Definition at line 138 of file builder.cc.

◆ SetRootNode()

void SetRootNode ( int  node_key)

Set a node as the root of a tree.

Parameters
node_keyunique integer key to identify the root node

Definition at line 128 of file builder.cc.


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