gbt-quantile
Pure-Rust gradient-boosted trees with quantile regression. No BLAS, no C++ bindings, no Python.
The first Rust GBT crate with pinball loss for probabilistic prediction intervals.
Features
- Quantile regression — train P10, P25, P50, P75, P90 models with pinball loss
- Early stopping — monitors validation loss, stops when overfitting
- JSON serialization — save and load models as human-readable JSON
- Quantile ensemble — train multiple quantile models in one call with monotonicity enforcement
- Evaluation metrics — MAE, RMSE, R², MAPE, pinball loss
- Zero dependencies beyond serde — no BLAS, LAPACK, or C++ libraries
- Schema versioned — forward-compatible model format
Quick Start
use ;
use trainer;
// Prepare data: x = feature matrix (row-major), y = targets
let x = vec!;
let y = vec!;
// Train a single model (L2 loss)
let config = default;
let model = train;
let prediction = model.predict;
// Train a quantile ensemble (P10-P90)
let ensemble = train;
let intervals = ensemble.predict;
println!;
// Save and load
let json = model.to_json.unwrap;
let restored = from_json.unwrap;
Quantile Regression
Train separate models for different quantiles using pinball loss:
let config = GBTConfig ;
let p10_model = train;
let config = GBTConfig ;
let p90_model = train;
Or use QuantileEnsemble to train all quantiles at once with automatic monotonicity enforcement (P10 <= P25 <= ... <= P90).
Early Stopping
Pass validation data to prevent overfitting:
let model = train_with_validation;
// Model automatically stops when validation loss plateaus
println!;
Evaluation
use metrics;
let preds = model.predict_batch;
let m = evaluate.unwrap;
println!;
let loss = pinball_loss.unwrap;
println!;
Algorithm
- Split finding: Percentile-based thresholds (configurable bins per feature)
- Gain: Variance reduction
- Quantile loss: Pinball gradient —
if error >= 0 { q } else { q - 1 } - Early stopping: Validation loss checked every 5 rounds
- Base score: mean(y) for L2, quantile(y, q) for pinball
License
MIT OR Apache-2.0