XGBoostPredictor Class Reference

Simple wrapper around XGBoost C API. More...

#include <XGBoostPredictor.h>

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

XGBoostPredictor::XGBoostPredictor ( std::string const &  path,
int  numFeatures 
)

Constructor.

Parameters:
[in] path Path to a file with XGBoost model.
[in] numFeatures Number of input features.

Member Function Documentation

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.

Parameters:
[in] x Array of features describing the example. Starting from the given position, numFeatures_ elements will be read.
Returns:
Prediction of the model.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator

Generated on 30 Oct 2020 for H→ZZ→2ℓ2ν analysis by  doxygen 1.6.1