treelite
|
Functions | |
int | TreeliteAssembleSparseBatch (const float *data, const uint32_t *col_ind, const size_t *row_ptr, size_t num_row, size_t num_col, CSRBatchHandle *out) |
assemble a sparse batch More... | |
int | TreeliteDeleteSparseBatch (CSRBatchHandle handle) |
delete a sparse batch from memory More... | |
int | TreeliteAssembleDenseBatch (const float *data, float missing_value, size_t num_row, size_t num_col, DenseBatchHandle *out) |
assemble a dense batch More... | |
int | TreeliteDeleteDenseBatch (DenseBatchHandle handle) |
delete a dense batch from memory More... | |
int | TreeliteBatchGetDimension (void *handle, int batch_sparse, size_t *out_num_row, size_t *out_num_col) |
get dimensions of a batch More... | |
int | TreelitePredictorLoad (const char *library_path, int num_worker_thread, PredictorHandle *out) |
load prediction code into memory. This function assumes that the prediction code has been already compiled into a dynamic shared library object (.so/.dll/.dylib). More... | |
int | TreelitePredictorPredictBatch (PredictorHandle handle, void *batch, int batch_sparse, int verbose, int pred_margin, float *out_result, size_t *out_result_size) |
Make predictions on a batch of data rows (synchronously). This function internally divides the workload among all worker threads. More... | |
int | TreelitePredictorPredictInst (PredictorHandle handle, union TreelitePredictorEntry *inst, int pred_margin, float *out_result, size_t *out_result_size) |
Make predictions on a single data row (synchronously). The work will be scheduled to the calling thread. More... | |
int | TreelitePredictorQueryResultSize (PredictorHandle handle, void *batch, int batch_sparse, size_t *out) |
Given a batch of data rows, query the necessary size of array to hold predictions for all data points. More... | |
int | TreelitePredictorQueryResultSizeSingleInst (PredictorHandle handle, size_t *out) |
Query the necessary size of array to hold the prediction for a single data row. More... | |
int | TreelitePredictorQueryNumOutputGroup (PredictorHandle handle, size_t *out) |
Get the number of output groups in the loaded model The number is 1 for most tasks; it is greater than 1 for multiclass classifcation. More... | |
int | TreelitePredictorQueryNumFeature (PredictorHandle handle, size_t *out) |
Get the width (number of features) of each instance used to train the loaded model. More... | |
int | TreelitePredictorQueryPredTransform (PredictorHandle handle, char **out) |
Get name of post prediction transformation used to train the loaded model. More... | |
int | TreelitePredictorQuerySigmoidAlpha (PredictorHandle handle, float *out) |
Get alpha value of sigmoid transformation used to train the loaded model. More... | |
int | TreelitePredictorQueryGlobalBias (PredictorHandle handle, float *out) |
Get global bias which adjusting predicted margin scores. More... | |
int | TreelitePredictorFree (PredictorHandle handle) |
delete predictor from memory More... | |
Predictor interface
int TreeliteAssembleDenseBatch | ( | const float * | data, |
float | missing_value, | ||
size_t | num_row, | ||
size_t | num_col, | ||
DenseBatchHandle * | out | ||
) |
assemble a dense batch
data | feature values |
missing_value | value to represent the missing value |
num_row | number of data rows in the batch |
num_col | number of columns (features) in the batch |
out | handle to sparse batch |
Definition at line 38 of file c_api_runtime.cc.
int TreeliteAssembleSparseBatch | ( | const float * | data, |
const uint32_t * | col_ind, | ||
const size_t * | row_ptr, | ||
size_t | num_row, | ||
size_t | num_col, | ||
CSRBatchHandle * | out | ||
) |
assemble a sparse batch
data | feature values |
col_ind | feature indices |
row_ptr | pointer to row headers |
num_row | number of data rows in the batch |
num_col | number of columns (features) in the batch |
out | handle to sparse batch |
Definition at line 16 of file c_api_runtime.cc.
int TreeliteBatchGetDimension | ( | void * | handle, |
int | batch_sparse, | ||
size_t * | out_num_row, | ||
size_t * | out_num_col | ||
) |
get dimensions of a batch
handle | a batch of rows (must be of type SparseBatch or DenseBatch) |
batch_sparse | whether the batch is sparse (true) or dense (false) |
out_num_row | used to set number of rows |
out_num_col | used to set number of columns |
Definition at line 57 of file c_api_runtime.cc.
int TreeliteDeleteDenseBatch | ( | DenseBatchHandle | handle | ) |
delete a dense batch from memory
handle | dense batch |
Definition at line 51 of file c_api_runtime.cc.
int TreeliteDeleteSparseBatch | ( | CSRBatchHandle | handle | ) |
delete a sparse batch from memory
handle | sparse batch |
Definition at line 32 of file c_api_runtime.cc.
int TreelitePredictorFree | ( | PredictorHandle | handle | ) |
delete predictor from memory
handle | predictor to remove |
Definition at line 184 of file c_api_runtime.cc.
int TreelitePredictorLoad | ( | const char * | library_path, |
int | num_worker_thread, | ||
PredictorHandle * | out | ||
) |
load prediction code into memory. This function assumes that the prediction code has been already compiled into a dynamic shared library object (.so/.dll/.dylib).
library_path | path to library object file containing prediction code |
num_worker_thread | number of worker threads (-1 to use max number) |
out | handle to predictor |
Definition at line 74 of file c_api_runtime.cc.
int TreelitePredictorPredictBatch | ( | PredictorHandle | handle, |
void * | batch, | ||
int | batch_sparse, | ||
int | verbose, | ||
int | pred_margin, | ||
float * | out_result, | ||
size_t * | out_result_size | ||
) |
Make predictions on a batch of data rows (synchronously). This function internally divides the workload among all worker threads.
handle | predictor |
batch | a batch of rows (must be of type SparseBatch or DenseBatch) |
batch_sparse | whether batch is sparse (1) or dense (0) |
verbose | whether to produce extra messages |
pred_margin | whether to produce raw margin scores instead of transformed probabilities |
out_result | resulting output vector; use TreelitePredictorQueryResultSize() to allocate sufficient space |
out_result_size | used to save length of the output vector, which is guaranteed to be less than or equal to TreelitePredictorQueryResultSize() |
Definition at line 84 of file c_api_runtime.cc.
int TreelitePredictorPredictInst | ( | PredictorHandle | handle, |
union TreelitePredictorEntry * | inst, | ||
int | pred_margin, | ||
float * | out_result, | ||
size_t * | out_result_size | ||
) |
Make predictions on a single data row (synchronously). The work will be scheduled to the calling thread.
handle | predictor |
inst | single data row |
pred_margin | whether to produce raw margin scores instead of transformed probabilities |
out_result | resulting output vector; use TreelitePredictorQueryResultSizeSingleInst() to allocate sufficient space |
out_result_size | used to save length of the output vector, which is guaranteed to be at most TreelitePredictorQueryResultSizeSingleInst() |
Definition at line 112 of file c_api_runtime.cc.
int TreelitePredictorQueryGlobalBias | ( | PredictorHandle | handle, |
float * | out | ||
) |
Get global bias which adjusting predicted margin scores.
handle | predictor |
out | global bias value |
Definition at line 177 of file c_api_runtime.cc.
int TreelitePredictorQueryNumFeature | ( | PredictorHandle | handle, |
size_t * | out | ||
) |
Get the width (number of features) of each instance used to train the loaded model.
handle | predictor |
out | number of features |
Definition at line 154 of file c_api_runtime.cc.
int TreelitePredictorQueryNumOutputGroup | ( | PredictorHandle | handle, |
size_t * | out | ||
) |
Get the number of output groups in the loaded model The number is 1 for most tasks; it is greater than 1 for multiclass classifcation.
handle | predictor |
out | length of prediction array |
Definition at line 147 of file c_api_runtime.cc.
int TreelitePredictorQueryPredTransform | ( | PredictorHandle | handle, |
char ** | out | ||
) |
Get name of post prediction transformation used to train the loaded model.
handle | predictor |
out | name of post prediction transformation |
Definition at line 161 of file c_api_runtime.cc.
int TreelitePredictorQueryResultSize | ( | PredictorHandle | handle, |
void * | batch, | ||
int | batch_sparse, | ||
size_t * | out | ||
) |
Given a batch of data rows, query the necessary size of array to hold predictions for all data points.
handle | predictor |
batch | a batch of rows (must be of type SparseBatch or DenseBatch) |
batch_sparse | whether batch is sparse (1) or dense (0) |
out | used to store the length of prediction array |
Definition at line 123 of file c_api_runtime.cc.
int TreelitePredictorQueryResultSizeSingleInst | ( | PredictorHandle | handle, |
size_t * | out | ||
) |
Query the necessary size of array to hold the prediction for a single data row.
handle | predictor |
out | used to store the length of prediction array |
Definition at line 139 of file c_api_runtime.cc.
int TreelitePredictorQuerySigmoidAlpha | ( | PredictorHandle | handle, |
float * | out | ||
) |
Get alpha value of sigmoid transformation used to train the loaded model.
handle | predictor |
out | alpha value of sigmoid transformation |
Definition at line 170 of file c_api_runtime.cc.