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 TreeliteLoadXGBoostJSON (const char *filename, ModelHandle *out)
 load a json model file generated by XGBoost (dmlc/xgboost). The model file must contain a decision tree ensemble. More...
 
int TreeliteLoadXGBoostJSONString (const char *json_str, size_t length, ModelHandle *out)
 load a model stored as JSON stringby XGBoost (dmlc/xgboost). The model json 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 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 TreeliteQueryNumClass (ModelHandle handle, size_t *out)
 Query the number of classes of the model. (1 if the model is binary classifier or regressor) 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

◆ TreeliteFreeModel()

int TreeliteFreeModel ( ModelHandle  handle)

delete model from memory

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

Definition at line 179 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 144 of file c_api.cc.

◆ TreeliteLoadXGBoostJSON()

int TreeliteLoadXGBoostJSON ( const char *  filename,
ModelHandle out 
)

load a json 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 158 of file c_api.cc.

◆ TreeliteLoadXGBoostJSONString()

int TreeliteLoadXGBoostJSONString ( const char *  json_str,
size_t  length,
ModelHandle out 
)

load a model stored as JSON stringby XGBoost (dmlc/xgboost). The model json must contain a decision tree ensemble.

Parameters
json_strthe string containing the JSON model specification
lengththe length of the JSON string
outloaded model
Returns
0 for success, -1 for failure

Definition at line 165 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 151 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 172 of file c_api.cc.

◆ TreeliteQueryNumClass()

int TreeliteQueryNumClass ( ModelHandle  handle,
size_t *  out 
)

Query the number of classes of the model. (1 if the model is binary classifier or regressor)

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

Definition at line 199 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 192 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 185 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 206 of file c_api.cc.