Treelite
c_api_runtime.h
Go to the documentation of this file.
1 
9 /* Note: Make sure to use slash-asterisk form of comments in this file
10  (like this one). Do not use double-slash (//). */
11 
12 #ifndef TREELITE_C_API_RUNTIME_H_
13 #define TREELITE_C_API_RUNTIME_H_
14 
15 #include "c_api_common.h"
16 
23 typedef void* PredictorHandle;
25 typedef void* PredictorOutputHandle;
26 
44 TREELITE_DLL int TreelitePredictorLoad(
45  const char* library_path, int num_worker_thread, PredictorHandle* out);
75 TREELITE_DLL int TreelitePredictorPredictBatch(
76  PredictorHandle handle, DMatrixHandle batch, int verbose, int pred_margin,
77  PredictorOutputHandle out_result, size_t* out_result_size);
99  PredictorHandle handle, DMatrixHandle batch, PredictorOutputHandle* out_output_vector);
100 
107 TREELITE_DLL int TreeliteDeletePredictorOutputVector(
108  PredictorHandle handle, PredictorOutputHandle output_vector);
109 
118 TREELITE_DLL int TreelitePredictorQueryResultSize(
119  PredictorHandle handle, DMatrixHandle batch, size_t* out);
128 TREELITE_DLL int TreelitePredictorQueryNumClass(PredictorHandle handle, size_t* out);
136 TREELITE_DLL int TreelitePredictorQueryNumFeature(PredictorHandle handle, size_t* out);
137 
145 TREELITE_DLL int TreelitePredictorQueryPredTransform(PredictorHandle handle, const char** out);
153 TREELITE_DLL int TreelitePredictorQuerySigmoidAlpha(PredictorHandle handle, float* out);
154 
161 TREELITE_DLL int TreelitePredictorQueryGlobalBias(PredictorHandle handle, float* out);
162 
163 TREELITE_DLL int TreelitePredictorQueryThresholdType(PredictorHandle handle, const char** out);
164 TREELITE_DLL int TreelitePredictorQueryLeafOutputType(PredictorHandle handle, const char** out);
170 TREELITE_DLL int TreelitePredictorFree(PredictorHandle handle);
173 #endif // TREELITE_C_API_RUNTIME_H_
int TreeliteCreatePredictorOutputVector(PredictorHandle handle, DMatrixHandle batch, PredictorOutputHandle *out_output_vector)
Convenience function to allocate an output vector that is able to hold the prediction result for a gi...
int TreelitePredictorPredictBatch(PredictorHandle handle, DMatrixHandle batch, int verbose, int pred_margin, PredictorOutputHandle out_result, size_t *out_result_size)
Make predictions on a batch of data rows (synchronously). This function internally divides the worklo...
void * PredictorOutputHandle
handle to output from predictor
Definition: c_api_runtime.h:25
int TreelitePredictorQueryPredTransform(PredictorHandle handle, const char **out)
Get name of post prediction transformation used to train the loaded model.
int TreelitePredictorQueryNumFeature(PredictorHandle handle, size_t *out)
Get the width (number of features) of each instance used to train the loaded model.
void * DMatrixHandle
handle to a data matrix
Definition: c_api_common.h:30
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 com...
C API of Treelite, used for interfacing with other languages This header is used by both the runtime ...
void * PredictorHandle
handle to predictor class
Definition: c_api_runtime.h:23
int TreeliteDeletePredictorOutputVector(PredictorHandle handle, PredictorOutputHandle output_vector)
De-allocate an output vector.
int TreelitePredictorFree(PredictorHandle handle)
delete predictor from memory
int TreelitePredictorQueryNumClass(PredictorHandle handle, size_t *out)
Get the number classes in the loaded model The number is 1 for most tasks; it is greater than 1 for m...
int TreelitePredictorQueryResultSize(PredictorHandle handle, DMatrixHandle batch, size_t *out)
Given a batch of data rows, query the necessary size of array to hold predictions for all data points...
int TreelitePredictorQuerySigmoidAlpha(PredictorHandle handle, float *out)
Get alpha value of sigmoid transformation used to train the loaded model.
int TreelitePredictorQueryGlobalBias(PredictorHandle handle, float *out)
Get global bias which adjusting predicted margin scores.