Transpile BDTs to C++ code.
Project description
# Generate C++ representations of boosted decision trees
This project tries to provide a generic functionality to transpile trained BDTs
into minimal, efficient C++ functions to evaluate single vectors of features.
While many frameworks exist to train, evaluate and store BDTs, its often hard
to use the results in a productive manner.
## Installation
So far there is only python3 support. Run
```
pip install bdt2cpp
```
to install the latest tagged version or
```
pip install git+https://github.com/bixel/bdt2cpp.git
```
for the current master version.
### lxplus
If you want to use bdt2cpp on CERNs lxplus machines, you need to get hold of
minimum python3.6. According to [CERNs Service Article
KB0000730](https://cern.service-now.com/service-portal/article.do?n=KB0000730),
one way to install the tool is:
```sh
# On lxplus
scl enable rh-python36
# this will install bdt2cpp to your `~/.local/` directory
pip install --user bdt2cpp
```
## Usage
To generate a minimal Makefile together with the C++ code inside a `build/`
directory from a given XGBoost dump or TMVA `.xml` file, simply run
```
bdt2cpp my-bdt-dump.xgb
```
You will find the corresponding files within the `build/` directory and if you
have installed `clang`, you can simply
```
cd build
make
```
*Note for CERN Users*: Currently, the Makefile uses clang as the default
compiler. You might need to adjust that in the generated file (inside the
`build/` directory)
The generated executable is essentially a very minimal placeholder, if you had
3 input features you could quickly cross-check the predictions against the
original training framework:
```
cd build
./main 1 2 3
```
should give the same output as received within the training framework if a
feature vector `f = (1, 2, 3)` is evaluated.
To see the complete list of features with some explanations, run
```
bdt2cpp -h
```
This project tries to provide a generic functionality to transpile trained BDTs
into minimal, efficient C++ functions to evaluate single vectors of features.
While many frameworks exist to train, evaluate and store BDTs, its often hard
to use the results in a productive manner.
## Installation
So far there is only python3 support. Run
```
pip install bdt2cpp
```
to install the latest tagged version or
```
pip install git+https://github.com/bixel/bdt2cpp.git
```
for the current master version.
### lxplus
If you want to use bdt2cpp on CERNs lxplus machines, you need to get hold of
minimum python3.6. According to [CERNs Service Article
KB0000730](https://cern.service-now.com/service-portal/article.do?n=KB0000730),
one way to install the tool is:
```sh
# On lxplus
scl enable rh-python36
# this will install bdt2cpp to your `~/.local/` directory
pip install --user bdt2cpp
```
## Usage
To generate a minimal Makefile together with the C++ code inside a `build/`
directory from a given XGBoost dump or TMVA `.xml` file, simply run
```
bdt2cpp my-bdt-dump.xgb
```
You will find the corresponding files within the `build/` directory and if you
have installed `clang`, you can simply
```
cd build
make
```
*Note for CERN Users*: Currently, the Makefile uses clang as the default
compiler. You might need to adjust that in the generated file (inside the
`build/` directory)
The generated executable is essentially a very minimal placeholder, if you had
3 input features you could quickly cross-check the predictions against the
original training framework:
```
cd build
./main 1 2 3
```
should give the same output as received within the training framework if a
feature vector `f = (1, 2, 3)` is evaluated.
To see the complete list of features with some explanations, run
```
bdt2cpp -h
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bdt2cpp-0.1.3.tar.gz
(7.1 kB
view hashes)
Built Distributions
Close
Hashes for bdt2cpp-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b893b95e1b27c9b9c21a25f282e94c2c7a0b4a197d148ce1caf9f0f5d0239aae |
|
MD5 | c1d5658197899b9ae3e4728d48cf8ecf |
|
BLAKE2b-256 | c31d9e0519abad7bff1350a3e22ed446c6da10f6d3253257a8e3e0bcf86ea11a |