Treelite
|
tree builder class More...
#include <frontend.h>
Public Member Functions | |
TreeBuilder (TypeInfo threshold_type, TypeInfo leaf_output_type) | |
Constructor. More... | |
TreeBuilder (const TreeBuilder &)=delete | |
TreeBuilder (TreeBuilder &&)=default | |
TreeBuilder & | operator= (const TreeBuilder &)=delete |
TreeBuilder & | operator= (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, Value 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, Value 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, Value leaf_value) |
Turn an empty node into a leaf node. More... | |
void | SetLeafVectorNode (int node_key, const std::vector< Value > &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 |
struct | ModelBuilderImpl |
tree builder class
Definition at line 211 of file frontend.h.
TreeBuilder | ( | TypeInfo | threshold_type, |
TypeInfo | leaf_output_type | ||
) |
Constructor.
threshold_type | Type of thresholds in numerical splits. All thresholds in a given model must have the same type. |
leaf_output_type | Type of leaf outputs. All leaf outputs in a given model must have the same type. |
Definition at line 173 of file builder.cc.
void CreateNode | ( | int | node_key | ) |
Create an empty node within a tree.
node_key | unique integer key to identify the new node |
Definition at line 178 of file builder.cc.
void DeleteNode | ( | int | node_key | ) |
Remove a node from a tree.
node_key | unique integer key to identify the node to be removed |
Definition at line 185 of file builder.cc.
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.
node_key | unique integer key to identify the node being modified; this node needs to be empty |
feature_id | id of feature |
left_categories | list of categories belonging to the left child |
default_left | default direction for missing values |
left_child_key | unique integer key to identify the left child node |
right_child_key | unique integer key to identify the right child node |
Definition at line 264 of file builder.cc.
void SetLeafNode | ( | int | node_key, |
Value | leaf_value | ||
) |
Turn an empty node into a leaf node.
node_key | unique integer key to identify the node being modified; this node needs to be empty |
leaf_value | leaf value (weight) of the leaf node |
Definition at line 296 of file builder.cc.
void SetLeafVectorNode | ( | int | node_key, |
const std::vector< Value > & | 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.
node_key | unique integer key to identify the node being modified; this node needs to be empty |
leaf_vector | leaf vector of the leaf node |
Definition at line 311 of file builder.cc.
void SetNumericalTestNode | ( | int | node_key, |
unsigned | feature_id, | ||
const char * | op, | ||
Value | 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.
node_key | unique integer key to identify the node being modified; this node needs to be empty |
feature_id | id of feature |
op | binary operator to use in the test |
threshold | threshold value |
default_left | default direction for missing values |
left_child_key | unique integer key to identify the left child node |
right_child_key | unique integer key to identify the right child node |
Definition at line 218 of file builder.cc.
void SetRootNode | ( | int | node_key | ) |
Set a node as the root of a tree.
node_key | unique integer key to identify the root node |
Definition at line 208 of file builder.cc.