Released under the MIT License.
Or to get the latest development version:
sklearn-compiledtrees has been tested to work on OS X, Linux and Windows.
Installing on Windows requires GCC compiler and dlfcn-win32, setting CXX environment variable (set "CXX=gcc -pthread" for CMD), and manual installation from source directory. Using msys2 distribution in conda is strongly recommended.
In some use cases, predicting given a model is in the hot-path, so speeding up decision tree evaluation is very useful.
An effective way of speeding up evaluation of decision trees can be to generate code representing the evaluation of the tree, compile that to optimized object code, and dynamically load that file via dlopen/dlsym or equivalent.
See https://courses.cs.washington.edu/courses/cse501/10au/compile-machlearn.pdf for a detailed discussion, and http://tullo.ch/articles/decision-tree-evaluation/ for a more pedagogical explanation and more benchmarks in C++.
This package implements compiled decision tree evaluation for the simple case of a single-output regression tree or ensemble.
For random forests, we see 5x to 8x speedup in evaluation. For gradient boosted ensembles, it's between a 1.5x and 3x speedup in evaluation. This is due to the fact that gradient boosted trees already have an optimized prediction implementation.
There is a benchmark script attached that allows us to examine the performance of evaluation across a range of ensemble configurations and datasets.
In the graphs attached, GB
is Gradient Boosted, RF
is Random Forest, D1
, etc correspond to setting max-depth=1
, and B10
corresponds to setting max_leaf_nodes=10
.