treelite
|
Model builder interface. More...
#include <model_builder.h>
Public Member Functions | |
virtual void | StartTree ()=0 |
Start a new tree. More... | |
virtual void | EndTree ()=0 |
End the current tree. More... | |
virtual void | StartNode (int node_key)=0 |
Start a new node. More... | |
virtual void | EndNode ()=0 |
End the current node. More... | |
virtual void | NumericalTest (std::int32_t split_index, double threshold, bool default_left, Operator cmp, int left_child_key, int right_child_key)=0 |
Declare the current node as a numerical test node, where the test is of form [feature value] [cmp] [threshold]. Data points for which the test evaluates to True will be mapped to the left child node; all other data points (for which the test evaluates to False) will be mapped to the right child node. More... | |
virtual void | CategoricalTest (std::int32_t split_index, bool default_left, std::vector< std::uint32_t > const &category_list, bool category_list_right_child, int left_child_key, int right_child_key)=0 |
Declare the current node as a categorical test node, where the test is of form [feature value] \in [category list]. More... | |
virtual void | LeafScalar (double leaf_value)=0 |
Declare the current node as a leaf node with a scalar output. More... | |
virtual void | LeafVector (std::vector< float > const &leaf_vector)=0 |
Declare the current node as a leaf node with a vector output. More... | |
virtual void | LeafVector (std::vector< double > const &leaf_vector)=0 |
Declare the current node as a leaf node with a vector output. More... | |
virtual void | Gain (double gain)=0 |
Specify the gain (loss reduction) that's resulted from the current split. More... | |
virtual void | DataCount (std::uint64_t data_count)=0 |
Specify the number of data points (samples) that are mapped to the current node. More... | |
virtual void | SumHess (double sum_hess)=0 |
Specify the weighted sample count or the sum of Hessians for the data points that are mapped to the current node. More... | |
virtual void | InitializeMetadata (Metadata const &metadata, TreeAnnotation const &tree_annotation, PostProcessorFunc const &postprocessor, std::vector< double > const &base_scores, std::optional< std::string > const &attributes)=0 |
Specify a metadata for this model, if no metadata was previously specified. More... | |
virtual std::unique_ptr< Model > | CommitModel ()=0 |
Conclude model building and obtain the final model object. More... | |
virtual | ~ModelBuilder ()=default |
Model builder interface.
|
virtualdefault |
|
pure virtual |
Declare the current node as a categorical test node, where the test is of form [feature value] \in [category list].
split_index | Feature ID |
default_left | Whether the missing value should be mapped to the left child |
category_list | List of categories to be tested for match |
category_list_right_child | Whether the data points for which the test evaluates to True should be mapped to the right child or the left child. |
left_child_key | Integer key that unique identifies the left child node. |
right_child_key | Integer key that unique identifies the right child node. |
|
pure virtual |
Conclude model building and obtain the final model object.
|
pure virtual |
Specify the number of data points (samples) that are mapped to the current node.
data_count | Number of data points |
|
pure virtual |
End the current node.
|
pure virtual |
End the current tree.
|
pure virtual |
Specify the gain (loss reduction) that's resulted from the current split.
gain | Gain (loss reduction) |
|
pure virtual |
Specify a metadata for this model, if no metadata was previously specified.
metadata | Model metadata |
tree_annotation | Annotation for individual trees |
postprocessor | Postprocessor for prediction outputs |
base_scores | Baseline scores for targets and classes, before adding tree outputs. Also known as the intercept. |
attributes | Arbitrary JSON object, to be stored in the "attributes" field in the model object. |
|
pure virtual |
Declare the current node as a leaf node with a scalar output.
leaf_value | Value of leaf output |
|
pure virtual |
Declare the current node as a leaf node with a vector output.
leaf_vector | Value of leaf output |
|
pure virtual |
Declare the current node as a leaf node with a vector output.
leaf_vector | Value of leaf output |
|
pure virtual |
Declare the current node as a numerical test node, where the test is of form [feature value] [cmp] [threshold]. Data points for which the test evaluates to True will be mapped to the left child node; all other data points (for which the test evaluates to False) will be mapped to the right child node.
split_index | Feature ID |
threshold | Threshold |
default_left | Whether the missing value should be mapped to the left child |
cmp | Comparison operator |
left_child_key | Integer key that unique identifies the left child node. |
right_child_key | Integer key that unique identifies the right child node. |
|
pure virtual |
Start a new node.
node_key | Integer key that unique identifies the node. |
|
pure virtual |
Start a new tree.
|
pure virtual |
Specify the weighted sample count or the sum of Hessians for the data points that are mapped to the current node.
sum_hess | Weighted sample count or the sum of Hessians |