|
int | TreeliteGTILParseConfig (char const *config_json, TreeliteGTILConfigHandle *out) |
| Load a configuration for GTIL predictor from a JSON string. More...
|
|
int | TreeliteGTILDeleteConfig (TreeliteGTILConfigHandle handle) |
| Delete a GTIL configuration from memory. More...
|
|
int | TreeliteGTILGetOutputShape (TreeliteModelHandle model, uint64_t num_row, TreeliteGTILConfigHandle config, uint64_t const **out, uint64_t *out_ndim) |
| Given a data matrix, query the necessary shape of array to hold predictions for all data points. More...
|
|
int | TreeliteGTILPredict (TreeliteModelHandle model, void const *input, char const *input_type, uint64_t num_row, void *output, TreeliteGTILConfigHandle config) |
| Predict with a 2D dense array. More...
|
|
int | TreeliteGTILPredictSparse (TreeliteModelHandle model, void const *data, char const *input_type, uint64_t const *col_ind, uint64_t const *row_ptr, uint64_t num_row, void *output, TreeliteGTILConfigHandle config) |
| Predict with sparse data with CSR (compressed sparse row) layout. More...
|
|
GTIL provides a reference implementation for predicting with decision trees.
◆ TreeliteGTILDeleteConfig()
Delete a GTIL configuration from memory.
- Parameters
-
handle | Handle to the GTIL configuration to be deleted |
- Returns
- 0 for success; -1 for failure
◆ TreeliteGTILGetOutputShape()
Given a data matrix, query the necessary shape of array to hold predictions for all data points.
- Parameters
-
model | Treelite Model object |
num_row | Number of rows in the input |
config | Configuration of GTIL predictor. Set this by calling TreeliteGTILParseConfig. |
out_shape | Array of dimensions |
out_ndim | Number of dimensions in out_shape |
- Returns
- 0 for success; -1 for failure
◆ TreeliteGTILParseConfig()
Load a configuration for GTIL predictor from a JSON string.
- Parameters
-
config_json | a JSON string with the following fields:
- "nthread" (optional): Number of threads used for initializing DMatrix. Set <= 0 to use all CPU cores.
- "predict_type" (required): Must be one of the following.
- "default": Sum over trees and apply post-processing
- "raw": Sum over trees, but don't apply post-processing; get raw margin scores instead.
- "leaf_id": Output one (integer) leaf ID per tree.
- "score_per_tree": Output one or more margin scores per tree.
|
out | Parsed configuration |
- Returns
- 0 for success; -1 for failure
◆ TreeliteGTILPredict()
Predict with a 2D dense array.
- Parameters
-
model | Treelite Model object |
input | The 2D data array, laid out in row-major layout |
input_type | Data type of the data matrix |
num_row | Number of rows in the data matrix. |
output | Pointer to buffer to store the output. Call TreeliteGTILGetOutputShape to get the amount of buffer you should allocate for this parameter. |
config | Configuration of GTIL predictor. Set this by calling TreeliteGTILParseConfig. |
- Returns
- 0 for success; -1 for failure
◆ TreeliteGTILPredictSparse()
int TreeliteGTILPredictSparse |
( |
TreeliteModelHandle |
model, |
|
|
void const * |
data, |
|
|
char const * |
input_type, |
|
|
uint64_t const * |
col_ind, |
|
|
uint64_t const * |
row_ptr, |
|
|
uint64_t |
num_row, |
|
|
void * |
output, |
|
|
TreeliteGTILConfigHandle |
config |
|
) |
| |
Predict with sparse data with CSR (compressed sparse row) layout.
In the CSR layout, data[row_ptr[i]:row_ptr[i+1]] store the nonzero entries of row i, and col_ind[row_ptr[i]:row_ptr[i+1]] stores the corresponding column indices.
- Parameters
-
model | Treelite Model object |
data | Nonzero elements in the data matrix |
input_type | Data type of the data matrix |
col_ind | Feature indices. col_ind[i] indicates the feature index associated with data[i]. |
row_ptr | Pointer to row headers. Length is [num_row] + 1. |
num_row | Number of rows in the data matrix. |
output | Pointer to buffer to store the output. Call GetOutputShape to get the amount of buffer you should allocate for this parameter. |
config | Configuration of GTIL predictor. Set this by calling TreeliteGTILParseConfig. |
- Returns
- 0 for success; -1 for failure