XGBoostPredictor
C++ header-only thread-safe library of XGBoost predictor without dependency on xgboost library.
Requirements
- C++17 compiler
- RapidJSON library installed
- XGBoost model saved to json format (requires xgboost >= 1.0)
Using library in C++
#include "xgboostpredictor.h"
#include <iostream>
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;
}On this page
Languages
C++98.2%Makefile1.8%
Contributors
Latest Release
v0.1.0August 19, 2020Apache License 2.0
Created August 19, 2020
Updated February 10, 2026