An open API service indexing awesome lists of open source software.

https://github.com/seznam/xgboostpredictor

C++ header-only thread-safe XGBoost predictor
https://github.com/seznam/xgboostpredictor

cpp predictor xgboost

Last synced: 12 months ago
JSON representation

C++ header-only thread-safe XGBoost predictor

Awesome Lists containing this project

README

          

# XGBoostPredictor
C++ header-only thread-safe library of [XGBoost](https://github.com/dmlc/xgboost/) predictor without dependency on xgboost library.

## Requirements
* C++17 compiler
* [RapidJSON](https://rapidjson.org/) library installed
* XGBoost model saved to [json format](https://xgboost.readthedocs.io/en/latest/tutorials/saving_model.html) (requires xgboost >= 1.0)

## Using library in C++

```cpp
#include "xgboostpredictor.h"
#include

using namespace xgboost::predictor;

int main()
{
// load xgboost json model
XGBoostPredictor predictor("model.json");

// prepare features (3 features total)
XGBoostPredictor::Data data(3);

// set features
// NOTE: feature 0 is set to 1.2, feature 1 is missing and feature 2 is set to 3.4
data[0] = 1.2f;
data[2] = 3.4f;

// make prediction
const auto prediction = predictor.predict(data);

// print predicted value
std::cout << prediction[0] << std::endl;
}
```