pub struct TreeConfig {Show 17 fields
pub max_depth: usize,
pub n_bins: usize,
pub lambda: f64,
pub gamma: f64,
pub grace_period: usize,
pub delta: f64,
pub feature_subsample_rate: f64,
pub seed: u64,
pub leaf_decay_alpha: Option<f64>,
pub split_reeval_interval: Option<usize>,
pub feature_types: Option<Vec<FeatureType>>,
pub gradient_clip_sigma: Option<f64>,
pub monotone_constraints: Option<Vec<i8>>,
pub max_leaf_output: Option<f64>,
pub adaptive_leaf_bound: Option<f64>,
pub min_hessian_sum: Option<f64>,
pub leaf_model_type: LeafModelType,
}alloc only.Expand description
Configuration for a single streaming decision tree.
These parameters control tree growth, regularization, and the statistical confidence required before committing a split decision.
§Defaults
| Parameter | Default |
|---|---|
max_depth | 6 |
n_bins | 64 |
lambda | 1.0 |
gamma | 0.0 |
grace_period | 200 |
delta | 1e-7 |
feature_subsample_rate | 1.0 |
Fields§
§max_depth: usizeMaximum tree depth. Deeper trees capture more interactions but risk overfitting on streaming data. Default: 6.
n_bins: usizeNumber of histogram bins per feature. More bins give finer split resolution at the cost of memory and slower convergence. Default: 64.
lambda: f64L2 regularization parameter (lambda). Penalizes large leaf weights, helping prevent overfitting. Appears in the denominator of the leaf weight formula: w = -G / (H + lambda). Default: 1.0.
gamma: f64Minimum split gain threshold (gamma). A candidate split must achieve gain > gamma to be accepted. Higher values produce more conservative trees. Default: 0.0.
grace_period: usizeMinimum number of samples a leaf must accumulate before evaluating potential splits. Also controls when bin edges are computed from observed feature values. Default: 200.
delta: f64Hoeffding bound confidence parameter (delta). Smaller values require more statistical evidence before committing a split, producing more conservative but more reliable trees. The bound guarantees that the chosen split is within epsilon of optimal with probability 1-delta. Default: 1e-7.
feature_subsample_rate: f64Fraction of features to consider at each split evaluation. 1.0 means all features are evaluated; smaller values introduce randomness (similar to random forest feature bagging). Default: 1.0.
seed: u64Random seed for feature subsampling. Default: 42.
Set by the ensemble orchestrator to ensure deterministic, diverse
behavior across trees (typically config.seed ^ step_index).
leaf_decay_alpha: Option<f64>Per-sample decay factor for leaf statistics.
Computed from leaf_half_life as exp(-ln(2) / half_life).
When Some(alpha), leaf gradient/hessian sums and histogram bins
are decayed by alpha before each new accumulation.
None (default) means no decay.
split_reeval_interval: Option<usize>Re-evaluation interval for max-depth leaves.
When Some(n), leaves at max depth will re-evaluate potential splits
every n samples, allowing the tree to adapt its structure over time.
None (default) disables re-evaluation.
feature_types: Option<Vec<FeatureType>>Per-feature type declarations (continuous vs categorical).
When Some, categorical features use one-bin-per-category binning and
Fisher optimal binary partitioning. None (default) treats all features
as continuous.
gradient_clip_sigma: Option<f64>Per-leaf gradient clipping threshold in standard deviations.
When Some(sigma), leaf-level EWMA gradient statistics are tracked and
incoming gradients are clamped to mean ± sigma * std_dev.
None (default) disables clipping.
monotone_constraints: Option<Vec<i8>>Per-feature monotonic constraints: +1 = increasing, -1 = decreasing, 0 = free.
Candidate splits violating monotonicity are rejected.
None (default) means no constraints.
max_leaf_output: Option<f64>Maximum absolute leaf output value.
When Some(max), leaf predictions are clamped to [-max, max].
Prevents runaway leaf weights from causing prediction explosions
in feedback loops. None (default) means no clamping.
adaptive_leaf_bound: Option<f64>Per-leaf adaptive output bound (sigma multiplier).
When Some(k), each leaf tracks EWMA of its own output weight and
clamps predictions to |output_mean| + k * output_std.
None (default) disables adaptive bounds.
min_hessian_sum: Option<f64>Minimum hessian sum before a leaf produces non-zero output.
When Some(min_h), leaves with hess_sum < min_h return 0.0.
Prevents post-replacement spikes from fresh leaves with insufficient
samples. None (default) means all leaves contribute immediately.
leaf_model_type: LeafModelTypeLeaf prediction model type.
Controls how each leaf computes its prediction:
ClosedForm(default): constant leaf weightw = -G / (H + lambda).Linear: online ridge regression with AdaGrad optimization, learning a localw . x + bsurface. Optionaldecayfor concept drift. Recommended for low-depth trees (depth 2–4).MLP: single hidden layer neural network per leaf. Optionaldecayfor concept drift.Adaptive: starts as closed-form, auto-promotes to a more complex model when the Hoeffding bound (usingdelta) confirms it is statistically superior. No arbitrary thresholds.
Implementations§
Source§impl TreeConfig
impl TreeConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new TreeConfig with default parameters.
Equivalent to TreeConfig::default(), but provided as a named
constructor for clarity in builder chains.
Sourcepub fn grace_period(self, grace_period: usize) -> Self
pub fn grace_period(self, grace_period: usize) -> Self
Set the grace period (minimum samples before evaluating splits).
Sourcepub fn feature_subsample_rate(self, rate: f64) -> Self
pub fn feature_subsample_rate(self, rate: f64) -> Self
Set the feature subsample rate.
Sourcepub fn leaf_decay_alpha(self, alpha: f64) -> Self
pub fn leaf_decay_alpha(self, alpha: f64) -> Self
Set the per-sample decay factor for leaf statistics.
Sourcepub fn leaf_decay_alpha_opt(self, alpha: Option<f64>) -> Self
pub fn leaf_decay_alpha_opt(self, alpha: Option<f64>) -> Self
Optionally set the per-sample decay factor for leaf statistics.
Sourcepub fn split_reeval_interval(self, interval: usize) -> Self
pub fn split_reeval_interval(self, interval: usize) -> Self
Set the re-evaluation interval for max-depth leaves.
Sourcepub fn split_reeval_interval_opt(self, interval: Option<usize>) -> Self
pub fn split_reeval_interval_opt(self, interval: Option<usize>) -> Self
Optionally set the re-evaluation interval for max-depth leaves.
Sourcepub fn feature_types(self, types: Vec<FeatureType>) -> Self
pub fn feature_types(self, types: Vec<FeatureType>) -> Self
Set the per-feature type declarations.
Sourcepub fn feature_types_opt(self, types: Option<Vec<FeatureType>>) -> Self
pub fn feature_types_opt(self, types: Option<Vec<FeatureType>>) -> Self
Optionally set the per-feature type declarations.
Sourcepub fn gradient_clip_sigma(self, sigma: f64) -> Self
pub fn gradient_clip_sigma(self, sigma: f64) -> Self
Set the gradient clipping threshold in standard deviations.
Sourcepub fn gradient_clip_sigma_opt(self, sigma: Option<f64>) -> Self
pub fn gradient_clip_sigma_opt(self, sigma: Option<f64>) -> Self
Optionally set the gradient clipping threshold.
Sourcepub fn monotone_constraints(self, constraints: Vec<i8>) -> Self
pub fn monotone_constraints(self, constraints: Vec<i8>) -> Self
Set per-feature monotonic constraints.
Sourcepub fn monotone_constraints_opt(self, constraints: Option<Vec<i8>>) -> Self
pub fn monotone_constraints_opt(self, constraints: Option<Vec<i8>>) -> Self
Optionally set per-feature monotonic constraints.
Sourcepub fn max_leaf_output(self, max: f64) -> Self
pub fn max_leaf_output(self, max: f64) -> Self
Set the maximum absolute leaf output value.
Sourcepub fn max_leaf_output_opt(self, max: Option<f64>) -> Self
pub fn max_leaf_output_opt(self, max: Option<f64>) -> Self
Optionally set the maximum absolute leaf output value.
Sourcepub fn adaptive_leaf_bound_opt(self, k: Option<f64>) -> Self
pub fn adaptive_leaf_bound_opt(self, k: Option<f64>) -> Self
Optionally set per-leaf adaptive output bound.
Sourcepub fn min_hessian_sum(self, min_h: f64) -> Self
pub fn min_hessian_sum(self, min_h: f64) -> Self
Set the minimum hessian sum for leaf output.
Sourcepub fn min_hessian_sum_opt(self, min_h: Option<f64>) -> Self
pub fn min_hessian_sum_opt(self, min_h: Option<f64>) -> Self
Optionally set the minimum hessian sum for leaf output.
Sourcepub fn leaf_model_type(self, lmt: LeafModelType) -> Self
pub fn leaf_model_type(self, lmt: LeafModelType) -> Self
Set the leaf prediction model type.
LeafModelType::Linear is recommended for low-depth configurations
(depth 2–4) where per-leaf linear models significantly reduce
approximation error compared to constant leaves.
LeafModelType::Adaptive automatically selects between closed-form and
a trainable model per leaf, using the Hoeffding bound for promotion.
Trait Implementations§
Source§impl Clone for TreeConfig
impl Clone for TreeConfig
Source§fn clone(&self) -> TreeConfig
fn clone(&self) -> TreeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more