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
- Host: GitHub
- URL: https://github.com/seznam/xgboostpredictor
- Owner: seznam
- License: apache-2.0
- Created: 2020-08-19T09:58:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-24T06:06:24.000Z (over 5 years ago)
- Last Synced: 2025-03-27T23:41:50.785Z (about 1 year ago)
- Topics: cpp, predictor, xgboost
- Language: C++
- Homepage:
- Size: 142 KB
- Stars: 6
- Watchers: 11
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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;
}
```