treelite
Functions
Model_loader

Functions

int TreeliteLoadLightGBMModel (const char *filename, ModelHandle *out)
 load a model file generated by LightGBM (Microsoft/LightGBM). The model file must contain a decision tree ensemble. More...
 
int TreeliteLoadXGBoostModel (const char *filename, ModelHandle *out)
 load a model file generated by XGBoost (dmlc/xgboost). The model file must contain a decision tree ensemble. More...
 
int TreeliteLoadXGBoostModelFromMemoryBuffer (const void *buf, size_t len, ModelHandle *out)
 load an XGBoost model from a memory buffer. More...
 
int TreeliteLoadProtobufModel (const char *filename, ModelHandle *out)
 load a model in Protocol Buffers format. Protocol Buffers (google/protobuf) is a language- and platform-neutral mechanism for serializing structured data. See tree.proto for format spec. More...
 
int TreeliteExportProtobufModel (const char *filename, ModelHandle model)
 export a model in Protocol Buffers format. Protocol Buffers (google/protobuf) is a language- and platform-neutral mechanism for serializing structured data. See src/tree.proto for format spec. More...
 
int TreeliteQueryNumTree (ModelHandle handle, size_t *out)
 Query the number of trees in the model. More...
 
int TreeliteQueryNumFeature (ModelHandle handle, size_t *out)
 Query the number of features used in the model. More...
 
int TreeliteQueryNumOutputGroups (ModelHandle handle, size_t *out)
 Query the number of output groups of the model. More...
 
int TreeliteSetTreeLimit (ModelHandle handle, size_t limit)
 keep first N trees of model, limit must smaller than number of trees. More...
 
int TreeliteFreeModel (ModelHandle handle)
 delete model from memory More...
 

Detailed Description

Model loader interface: read trees from the disk

Function Documentation

◆ TreeliteExportProtobufModel()

int TreeliteExportProtobufModel ( const char *  filename,
ModelHandle  model 
)

export a model in Protocol Buffers format. Protocol Buffers (google/protobuf) is a language- and platform-neutral mechanism for serializing structured data. See src/tree.proto for format spec.

Parameters
filenamename of model file
modelmodel to export
Returns
0 for success, -1 for failure

Definition at line 338 of file c_api.cc.

◆ TreeliteFreeModel()

int TreeliteFreeModel ( ModelHandle  handle)

delete model from memory

Parameters
handlemodel to remove
Returns
0 for success, -1 for failure

Definition at line 346 of file c_api.cc.

◆ TreeliteLoadLightGBMModel()

int TreeliteLoadLightGBMModel ( const char *  filename,
ModelHandle out 
)

load a model file generated by LightGBM (Microsoft/LightGBM). The model file must contain a decision tree ensemble.

Parameters
filenamename of model file
outloaded model
Returns
0 for success, -1 for failure

Definition at line 306 of file c_api.cc.

◆ TreeliteLoadProtobufModel()

int TreeliteLoadProtobufModel ( const char *  filename,
ModelHandle out 
)

load a model in Protocol Buffers format. Protocol Buffers (google/protobuf) is a language- and platform-neutral mechanism for serializing structured data. See tree.proto for format spec.

Parameters
filenamename of model file
outloaded model
Returns
0 for success, -1 for failure

Definition at line 330 of file c_api.cc.

◆ TreeliteLoadXGBoostModel()

int TreeliteLoadXGBoostModel ( const char *  filename,
ModelHandle out 
)

load a model file generated by XGBoost (dmlc/xgboost). The model file must contain a decision tree ensemble.

Parameters
filenamename of model file
outloaded model
Returns
0 for success, -1 for failure

Definition at line 314 of file c_api.cc.

◆ TreeliteLoadXGBoostModelFromMemoryBuffer()

int TreeliteLoadXGBoostModelFromMemoryBuffer ( const void *  buf,
size_t  len,
ModelHandle out 
)

load an XGBoost model from a memory buffer.

Parameters
bufmemory buffer
lensize of memory buffer
outloaded model
Returns
0 for success, -1 for failure

Definition at line 322 of file c_api.cc.

◆ TreeliteQueryNumFeature()

int TreeliteQueryNumFeature ( ModelHandle  handle,
size_t *  out 
)

Query the number of features used in the model.

Parameters
handlemodel to query
outnumber of features
Returns
0 for success, -1 for failure

Definition at line 359 of file c_api.cc.

◆ TreeliteQueryNumOutputGroups()

int TreeliteQueryNumOutputGroups ( ModelHandle  handle,
size_t *  out 
)

Query the number of output groups of the model.

Parameters
handlemodel to query
outnumber of output groups
Returns
0 for success, -1 for failure

Definition at line 366 of file c_api.cc.

◆ TreeliteQueryNumTree()

int TreeliteQueryNumTree ( ModelHandle  handle,
size_t *  out 
)

Query the number of trees in the model.

Parameters
handlemodel to query
outnumber of trees
Returns
0 for success, -1 for failure

Definition at line 352 of file c_api.cc.

◆ TreeliteSetTreeLimit()

int TreeliteSetTreeLimit ( ModelHandle  handle,
size_t  limit 
)

keep first N trees of model, limit must smaller than number of trees.

Parameters
handlemodel
limitnumber of trees to keep
Returns
0 for success, -1 for failure

Definition at line 373 of file c_api.cc.