Stochastic gradient-boosted decision trees for binary classification, with interfaces for Python, C++ and C. FastBDT is a speed-optimised, cache-friendly implementation that is about an order of magnitude faster than general-purpose implementations such as TMVA, scikit-learn and XGBoost, at both training and application. It is used extensively in high-energy physics by the Belle II Collaboration.
Check the paper on arXiv: FastBDT: A speed-optimized and cache-friendly implementation of stochastic gradient-boosted decision trees for multivariate classification
This repository is a fork maintained by the Belle II Collaboration. It is guaranteed to compile with modern compilers and the unit tests and main examples are fully functional, unless stated otherwise.
The original repository can be found at: https://github.com/thomaskeck/FastBDT
FastBDT is packaged on conda-forge, which ships the Python bindings together with the pre-compiled C++ and C libraries, so no manual build is required.
Two packages are available, differing only in the internal weight precision (see Weight type and numerical precision):
| Package | Weight | Downloads | Version | Platforms |
|---|---|---|---|---|
fastbdt |
float |
|||
fastbdt-double-weight |
double |
Using conda:
conda install -c conda-forge fastbdt
# or, for the double-precision build:
conda install -c conda-forge fastbdt-double-weightUsing pixi inside a project (conda-forge is the default channel):
pixi add fastbdt
# or, for the double-precision build:
pixi add fastbdt-double-weightTo install it into a global pixi environment instead of a project, use
pixi global install fastbdt
# or, for the double-precision build:
pixi global install fastbdt-double-weightTo build and install FastBDT from source, use the following commands:
mkdir -p build install && cd build
cmake ..
make
make installThis will also install the Python bindings automatically if CMake detects a valid python3 interpreter during the configuration step.
To build the double-precision variant from source, see Weight type and numerical precision.
Typically, you will want to use FastBDT as a library integrated directly into your application. Available interfaces:
- the Python library
PyFastBDT/FastBDT.py(seeexamples/iris_example.pyandexamples/generic_example.py) - the C++ shared/static library (see
examples/IRISExample.cxx) - the C shared library
For a broader description of how FastBDT works, its configuration options, and the Python, C++ and C APIs, see DOCS.md.
By default, FastBDT uses single-precision floating point (float) as type for internal weights in the C++ implementation. This choice is made for performance reasons and is sufficient for most use cases.
If higher numerical precision is required, a double-precision floating point (double) build is available in two ways:
-
from
conda-forge: install thefastbdt-double-weightpackage instead offastbdt(see Installation). -
from source: enable the corresponding CMake option at configuration time:
cmake .. -DUSE_DOUBLE_WEIGHT=ON
Either way, this changes the internal weight type used throughout the FastBDT codebase.
The Python interface automatically handles the internal weight type and requires no user action. Switching between single and double precision is entirely transparent to Python users.
When working with FastBDT in C++, it is strongly recommended to use the type alias FastBDT::Weight, which is available via the header FastBDT.h, for all weight-related variables, rather than explicitly using float or double.
This ensures that user code remains compatible regardless of whether FastBDT is built with single or double precision.
This work is mostly based on the papers by Jerome H. Friedman
FastBDT also implements the uniform gradient boosting techniques to boost to flatness: