treelite
Classes | Typedefs | Functions
treelite::model_builder Namespace Reference

Classes

class  ModelBuilder
 Model builder interface. More...
 
struct  TreeAnnotation
 Annotation for individual trees. Use this object to look up which target and class each tree is associated with. More...
 
struct  PostProcessorFunc
 Specification for postprocessor of prediction outputs. More...
 
struct  Metadata
 Metadata object, consisting of metadata information about the model at large. More...
 

Typedefs

using PostProcessorConfigParam = std::variant< std::int64_t, double, std::string >
 Parameter type used to configure postprocessor functions. More...
 

Functions

std::unique_ptr< ModelBuilderGetModelBuilder (TypeInfo threshold_type, TypeInfo leaf_output_type, Metadata const &metadata, TreeAnnotation const &tree_annotation, PostProcessorFunc const &postprocessor, std::vector< double > const &base_scores, std::optional< std::string > const &attributes=std::nullopt)
 Initialize a model builder object with a given set of metadata. More...
 
std::unique_ptr< ModelBuilderGetModelBuilder (TypeInfo threshold_type, TypeInfo leaf_output_type)
 Initialize a model builder object with empty metadata. Remember to provide metadata later, with a call to InitializeMetadata(). More...
 
std::unique_ptr< ModelBuilderGetModelBuilder (std::string const &json_str)
 Initialize a model builder object from a JSON string. The JSON string must contain all relevant metadata. See GetModelBuilder for the list of necessary metadata. More...
 

Typedef Documentation

◆ PostProcessorConfigParam

using treelite::model_builder::PostProcessorConfigParam = typedef std::variant<std::int64_t, double, std::string>

Parameter type used to configure postprocessor functions.

Function Documentation

◆ GetModelBuilder() [1/3]

std::unique_ptr<ModelBuilder> treelite::model_builder::GetModelBuilder ( std::string const &  json_str)

Initialize a model builder object from a JSON string. The JSON string must contain all relevant metadata. See GetModelBuilder for the list of necessary metadata.

Parameters
json_strJSON string containing relevant metadata.
Returns
Model builder object

◆ GetModelBuilder() [2/3]

std::unique_ptr<ModelBuilder> treelite::model_builder::GetModelBuilder ( TypeInfo  threshold_type,
TypeInfo  leaf_output_type 
)

Initialize a model builder object with empty metadata. Remember to provide metadata later, with a call to InitializeMetadata().

Parameters
threshold_typeType of thresholds in the tree model
leaf_output_typeType of leaf outputs in the tree model
Returns
Model builder object

◆ GetModelBuilder() [3/3]

std::unique_ptr<ModelBuilder> treelite::model_builder::GetModelBuilder ( TypeInfo  threshold_type,
TypeInfo  leaf_output_type,
Metadata const &  metadata,
TreeAnnotation const &  tree_annotation,
PostProcessorFunc const &  postprocessor,
std::vector< double > const &  base_scores,
std::optional< std::string > const &  attributes = std::nullopt 
)

Initialize a model builder object with a given set of metadata.

Parameters
threshold_typeType of thresholds in the tree model
leaf_output_typeType of leaf outputs in the tree model
metadataModel metadata
tree_annotationAnnotation for individual trees
postprocessorPostprocessor for prediction outputs
base_scoresBaseline scores for targets and classes, before adding tree outputs. Also known as the intercept.
attributesArbitrary JSON object, to be stored in the "attributes" field in the model object.
Returns
Model builder object