Home

Awesome

EvoTrees <a href="https://evovest.github.io/EvoTrees.jl/dev/"><img src="figures/hex-evotrees-2.png" align="right" height="160"/></a>

DocumentationCI StatusDOI

A Julia implementation of boosted trees with CPU and GPU support. Efficient histogram based algorithms with support for multiple loss functions (notably multi-target objectives such as max likelihood methods).

R binding available.

Installation

Latest:

julia> Pkg.add(url="https://github.com/Evovest/EvoTrees.jl")

From General Registry:

julia> Pkg.add("EvoTrees")

Performance

Data consists of randomly generated Matrix{Float64}. Training is performed on 200 iterations.
Code to reproduce is availabe in benchmarks/regressor.jl.

Training:

Dimensions / AlgoXGBoost CPUEvoTrees CPUXGBoost GPUEvoTrees GPU
100K x 1002.34s1.01s0.90s2.61s
500K x 10010.7s3.95s1.84s3.41s
1M x 10021.1s6.57s3.10s4.47s
5M x 100108s36.1s12.9s12.5s
10M x 100218s72.6s25.5s23.0s

Inference:

Dimensions / AlgoXGBoost CPUEvoTrees CPUXGBoost GPUEvoTrees GPU
100K x 1000.151s0.058sNA0.045s
500K x 1000.647s0.248sNA0.172s
1M x 1001.26s0.573sNA0.327s
5M x 1006.04s2.87sNA1.66s
10M x 10012.4s5.71sNA3.40s

MLJ Integration

See official project page for more info.

Quick start with internal API

A model configuration must first be defined, using one of the model constructor:

Model training is performed using fit_evotree. It supports additional keyword arguments to track evaluation metric and perform early stopping. Look at the docs for more details on available hyper-parameters for each of the above constructors and other options training options.

Matrix features input

using EvoTrees

config = EvoTreeRegressor(
    loss=:mse, 
    nrounds=100, 
    max_depth=6,
    nbins=32,
    eta=0.1)

x_train, y_train = rand(1_000, 10), rand(1_000)
m = fit_evotree(config; x_train, y_train)
preds = m(x_train)

DataFrames input

When using a DataFrames as input, features with elements types Real (incl. Bool) and Categorical are automatically recognized as input features. Alternatively, fnames kwarg can be used to specify the variables to be used as features.

Categorical features are treated accordingly by the algorithm: ordered variables are treated as numerical features, using split rule, while unordered variables are using ==. Support is currently limited to a maximum of 255 levels. Bool variables are treated as unordered, 2-levels categorical variables.

dtrain = DataFrame(x_train, :auto)
dtrain.y .= y_train
m = fit_evotree(config, dtrain; target_name="y");
m = fit_evotree(config, dtrain; target_name="y", fnames=["x1", "x3"]);

Feature importance

Returns the normalized gain by feature.

features_gain = EvoTrees.importance(m)

Plot

Plot a given tree of the model:

plot(m, 2)

Note that 1st tree is used to set the bias so the first real tree is #2.

Save/Load

EvoTrees.save(m, "data/model.bson")
m = EvoTrees.load("data/model.bson");