treelite
Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
treelite::Model Class Reference

Model class for tree ensemble model. More...

#include <tree.h>

Collaboration diagram for treelite::Model:
Collaboration graph

Public Member Functions

 Model ()
 disable copy; use default move More...
 
virtual ~Model ()=default
 
 Model (Model const &)=delete
 
Modeloperator= (Model const &)=delete
 
 Model (Model &&)=default
 
Modeloperator= (Model &&)=default
 
TypeInfo GetThresholdType () const
 
TypeInfo GetLeafOutputType () const
 
std::size_t GetNumTree () const
 
void SetTreeLimit (std::size_t limit)
 
void DumpAsJSON (std::ostream &fo, bool pretty_print) const
 
std::string DumpAsJSON (bool pretty_print) const
 
TREELITE_DLL_EXPORT std::vector< PyBufferFrameSerializeToPyBuffer ()
 
void SerializeToStream (std::ostream &os)
 
Version GetVersion () const
 Return the Treelite version that produced this Model object. More...
 
PyBufferFrame GetHeaderField (std::string const &name)
 Get a field in the header. More...
 
PyBufferFrame GetTreeField (std::uint64_t tree_id, std::string const &name)
 Get a field in a tree. More...
 
void SetHeaderField (std::string const &name, PyBufferFrame frame)
 Set a field in the header. More...
 
void SetTreeField (std::uint64_t tree_id, std::string const &name, PyBufferFrame frame)
 Set a field in a tree. More...
 

Static Public Member Functions

template<typename ThresholdType , typename LeafOutputType >
static std::unique_ptr< ModelCreate ()
 
static std::unique_ptr< ModelCreate (TypeInfo threshold_type, TypeInfo leaf_output_type)
 
static TREELITE_DLL_EXPORT std::unique_ptr< ModelDeserializeFromPyBuffer (std::vector< PyBufferFrame > const &frames)
 
static std::unique_ptr< ModelDeserializeFromStream (std::istream &is)
 

Public Attributes

ModelPresetVariant variant_
 
std::int32_t num_feature {0}
 Number of features used for the model. It is assumed that all feature indices are between 0 and [num_feature]-1. More...
 
TaskType task_type
 Task type. More...
 
bool average_tree_output {false}
 whether to average tree outputs More...
 
std::int32_t num_target
 
ContiguousArray< std::int32_t > num_class
 
ContiguousArray< std::int32_t > leaf_vector_shape
 
ContiguousArray< std::int32_t > target_id
 
ContiguousArray< std::int32_t > class_id
 
std::string postprocessor
 
float sigmoid_alpha {1.0f}
 
float ratio_c {1.0f}
 
ContiguousArray< double > base_scores
 
std::string attributes
 

Friends

template<typename MixIn >
class detail::serializer::Serializer
 
template<typename MixIn >
class detail::serializer::Deserializer
 

Detailed Description

Model class for tree ensemble model.

Constructor & Destructor Documentation

◆ Model() [1/3]

treelite::Model::Model ( )
inline

disable copy; use default move

◆ ~Model()

virtual treelite::Model::~Model ( )
virtualdefault

◆ Model() [2/3]

treelite::Model::Model ( Model const &  )
delete

◆ Model() [3/3]

treelite::Model::Model ( Model &&  )
default

Member Function Documentation

◆ Create() [1/2]

template<typename ThresholdType , typename LeafOutputType >
std::unique_ptr< Model > treelite::Model::Create
inlinestatic

◆ Create() [2/2]

std::unique_ptr< Model > treelite::Model::Create ( TypeInfo  threshold_type,
TypeInfo  leaf_output_type 
)
inlinestatic

◆ DeserializeFromPyBuffer()

static TREELITE_DLL_EXPORT std::unique_ptr<Model> treelite::Model::DeserializeFromPyBuffer ( std::vector< PyBufferFrame > const &  frames)
static

◆ DeserializeFromStream()

static std::unique_ptr<Model> treelite::Model::DeserializeFromStream ( std::istream &  is)
static

◆ DumpAsJSON() [1/2]

std::string treelite::Model::DumpAsJSON ( bool  pretty_print) const
inline

◆ DumpAsJSON() [2/2]

void treelite::Model::DumpAsJSON ( std::ostream &  fo,
bool  pretty_print 
) const

◆ GetHeaderField()

PyBufferFrame treelite::Model::GetHeaderField ( std::string const &  name)

Get a field in the header.

◆ GetLeafOutputType()

TypeInfo treelite::Model::GetLeafOutputType ( ) const
inline

◆ GetNumTree()

std::size_t treelite::Model::GetNumTree ( ) const
inline

◆ GetThresholdType()

TypeInfo treelite::Model::GetThresholdType ( ) const
inline

◆ GetTreeField()

PyBufferFrame treelite::Model::GetTreeField ( std::uint64_t  tree_id,
std::string const &  name 
)

Get a field in a tree.

◆ GetVersion()

Version treelite::Model::GetVersion ( ) const
inline

Return the Treelite version that produced this Model object.

◆ operator=() [1/2]

Model& treelite::Model::operator= ( Model &&  )
default

◆ operator=() [2/2]

Model& treelite::Model::operator= ( Model const &  )
delete

◆ SerializeToPyBuffer()

TREELITE_DLL_EXPORT std::vector<PyBufferFrame> treelite::Model::SerializeToPyBuffer ( )

◆ SerializeToStream()

void treelite::Model::SerializeToStream ( std::ostream &  os)

◆ SetHeaderField()

void treelite::Model::SetHeaderField ( std::string const &  name,
PyBufferFrame  frame 
)

Set a field in the header.

◆ SetTreeField()

void treelite::Model::SetTreeField ( std::uint64_t  tree_id,
std::string const &  name,
PyBufferFrame  frame 
)

Set a field in a tree.

◆ SetTreeLimit()

void treelite::Model::SetTreeLimit ( std::size_t  limit)
inline

Friends And Related Function Documentation

◆ detail::serializer::Deserializer

template<typename MixIn >
friend class detail::serializer::Deserializer
friend

◆ detail::serializer::Serializer

template<typename MixIn >
friend class detail::serializer::Serializer
friend

Member Data Documentation

◆ attributes

std::string treelite::Model::attributes

◆ average_tree_output

bool treelite::Model::average_tree_output {false}

whether to average tree outputs

◆ base_scores

ContiguousArray<double> treelite::Model::base_scores

◆ class_id

ContiguousArray<std::int32_t> treelite::Model::class_id

◆ leaf_vector_shape

ContiguousArray<std::int32_t> treelite::Model::leaf_vector_shape

◆ num_class

ContiguousArray<std::int32_t> treelite::Model::num_class

◆ num_feature

std::int32_t treelite::Model::num_feature {0}

Number of features used for the model. It is assumed that all feature indices are between 0 and [num_feature]-1.

◆ num_target

std::int32_t treelite::Model::num_target

◆ postprocessor

std::string treelite::Model::postprocessor

◆ ratio_c

float treelite::Model::ratio_c {1.0f}

◆ sigmoid_alpha

float treelite::Model::sigmoid_alpha {1.0f}

◆ target_id

ContiguousArray<std::int32_t> treelite::Model::target_id

◆ task_type

TaskType treelite::Model::task_type

Task type.

◆ variant_

ModelPresetVariant treelite::Model::variant_

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