Simple wrapper around XGBoost C API. More...
#include <XGBoostPredictor.h>
Public Member Functions | |
XGBoostPredictor (std::string const &path, int numFeatures) | |
Constructor. | |
float | Predict (float const *x) const |
Computes prediction of the XGBoost model for a single example. | |
Static Private Member Functions | |
static void | CheckCall (std::string const &functionName, int exitCode) |
Throws XGBoostPredictorException if the exit code is not 0. | |
Private Attributes | |
BoosterHandle | booster_ |
Pointer to XGBoost model. | |
int | numFeatures_ |
Number of input features specified in the constructor. |
Simple wrapper around XGBoost C API.
This class loads a saved XGBoost model from a file and computes its predictions, for one example at a time. The predictions require memory allocation and deallocation for each example, which is not optimal. Unfortunately, in XGBoost 0.90 API this is the only way to compute predictions per example.
XGBoostPredictor::XGBoostPredictor | ( | std::string const & | path, | |
int | numFeatures | |||
) |
Constructor.
[in] | path | Path to a file with XGBoost model. |
[in] | numFeatures | Number of input features. |
static void XGBoostPredictor::CheckCall | ( | std::string const & | functionName, | |
int | exitCode | |||
) | [static, private] |
Throws XGBoostPredictorException if the exit code is not 0.
Arguments are forwarded to XGBoostPredictorException.
float XGBoostPredictor::Predict | ( | float const * | x | ) | const |
Computes prediction of the XGBoost model for a single example.
[in] | x | Array of features describing the example. Starting from the given position, numFeatures_ elements will be read. |