Docs · Machine learning

gbtc: gradient-boosted tree classifier.

Binary classification with gradient-boosted trees, the equivalent of Spark MLlib's GBTClassifier. It is the gbt engine with logistic set: histograms hold gradient and Hessian sums, splits maximise G^2 / (H + l2), and leaves take Newton steps.

Module
ml_gbtc
Header
clio_ml/gbt.h
Rows
features, then 0/1 label

What it does

The logistic path computes its exponentials with an exact routine built from IEEE operations only, so host and device agree bit for bit and near-tied split choices do not flip between them. The regression path is unchanged by this flag.

Rows

n_features feature columns followed by a 0/1 label. clio_ml.COLUMNS["gbtc"] is 1.

Python

python
import numpy as np, clio_ml as cm
rng = np.random.default_rng(1)
X = rng.normal(size=(4096, 7)).astype(np.float32)
y = ((X[:, 0] > 0) ^ (X[:, 1] > 0)).astype(np.float32)   # XOR-like
data = np.column_stack([X, y]).astype(np.float32)

r = cm.fit_gbtc(data, num_trees=3, max_depth=3)
margin = cm.predict("gbtc", r, data[0, :7])              # raw margin
p = 1 / (1 + np.exp(-margin))                             # probability of class 1
  • fit_gbtc(X, **options) is fit_gbt with logistic=True preset.
  • Options (GbtOptions): num_trees (20), max_depth (3), num_bins (32), learning_rate (0.3), l2 (0.0; the Hessian regulariser), min_hessian (1.0; minimum child Hessian sum), threads (256).
  • Result GbtResult, as for gbt.
  • predict("gbtc", r, x) returns the raw margin from GbtPredict; apply a sigmoid for the probability. GbtPredictProba is C++ only.

C++

cpp
clio_ml::GbtOptions opt;
opt.logistic = true;        // labels must be 0/1
opt.num_trees = 20;
clio_ml::GbtResult r = clio_ml::FitGbt(ds, opt);
float p = clio_ml::GbtPredictProba(r.model, x);   // 1 / (1 + exp(-GbtPredict(m, x)))

Types and signatures are on the gbt page. The ChiMod is module ml_gbtc.

Related: logistic regression, random forest.