Skip to main content

TreeConfig

Struct TreeConfig 

Source
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,
}
Available on crate feature 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

ParameterDefault
max_depth6
n_bins64
lambda1.0
gamma0.0
grace_period200
delta1e-7
feature_subsample_rate1.0

Fields§

§max_depth: usize

Maximum tree depth. Deeper trees capture more interactions but risk overfitting on streaming data. Default: 6.

§n_bins: usize

Number of histogram bins per feature. More bins give finer split resolution at the cost of memory and slower convergence. Default: 64.

§lambda: f64

L2 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: f64

Minimum 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: usize

Minimum 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: f64

Hoeffding 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: f64

Fraction 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: u64

Random 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: LeafModelType

Leaf prediction model type.

Controls how each leaf computes its prediction:

  • ClosedForm (default): constant leaf weight w = -G / (H + lambda).
  • Linear: online ridge regression with AdaGrad optimization, learning a local w . x + b surface. Optional decay for concept drift. Recommended for low-depth trees (depth 2–4).
  • MLP: single hidden layer neural network per leaf. Optional decay for concept drift.
  • Adaptive: starts as closed-form, auto-promotes to a more complex model when the Hoeffding bound (using delta) confirms it is statistically superior. No arbitrary thresholds.

Implementations§

Source§

impl TreeConfig

Source

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.

Source

pub fn max_depth(self, max_depth: usize) -> Self

Set the maximum tree depth.

Source

pub fn n_bins(self, n_bins: usize) -> Self

Set the number of histogram bins per feature.

Source

pub fn lambda(self, lambda: f64) -> Self

Set the L2 regularization parameter (lambda).

Source

pub fn gamma(self, gamma: f64) -> Self

Set the minimum split gain threshold (gamma).

Source

pub fn grace_period(self, grace_period: usize) -> Self

Set the grace period (minimum samples before evaluating splits).

Source

pub fn delta(self, delta: f64) -> Self

Set the Hoeffding bound confidence parameter (delta).

Source

pub fn feature_subsample_rate(self, rate: f64) -> Self

Set the feature subsample rate.

Source

pub fn seed(self, seed: u64) -> Self

Set the random seed for feature subsampling.

Source

pub fn leaf_decay_alpha(self, alpha: f64) -> Self

Set the per-sample decay factor for leaf statistics.

Source

pub fn leaf_decay_alpha_opt(self, alpha: Option<f64>) -> Self

Optionally set the per-sample decay factor for leaf statistics.

Source

pub fn split_reeval_interval(self, interval: usize) -> Self

Set the re-evaluation interval for max-depth leaves.

Source

pub fn split_reeval_interval_opt(self, interval: Option<usize>) -> Self

Optionally set the re-evaluation interval for max-depth leaves.

Source

pub fn feature_types(self, types: Vec<FeatureType>) -> Self

Set the per-feature type declarations.

Source

pub fn feature_types_opt(self, types: Option<Vec<FeatureType>>) -> Self

Optionally set the per-feature type declarations.

Source

pub fn gradient_clip_sigma(self, sigma: f64) -> Self

Set the gradient clipping threshold in standard deviations.

Source

pub fn gradient_clip_sigma_opt(self, sigma: Option<f64>) -> Self

Optionally set the gradient clipping threshold.

Source

pub fn monotone_constraints(self, constraints: Vec<i8>) -> Self

Set per-feature monotonic constraints.

Source

pub fn monotone_constraints_opt(self, constraints: Option<Vec<i8>>) -> Self

Optionally set per-feature monotonic constraints.

Source

pub fn max_leaf_output(self, max: f64) -> Self

Set the maximum absolute leaf output value.

Source

pub fn max_leaf_output_opt(self, max: Option<f64>) -> Self

Optionally set the maximum absolute leaf output value.

Source

pub fn adaptive_leaf_bound_opt(self, k: Option<f64>) -> Self

Optionally set per-leaf adaptive output bound.

Source

pub fn min_hessian_sum(self, min_h: f64) -> Self

Set the minimum hessian sum for leaf output.

Source

pub fn min_hessian_sum_opt(self, min_h: Option<f64>) -> Self

Optionally set the minimum hessian sum for leaf output.

Source

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

Source§

fn clone(&self) -> TreeConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TreeConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TreeConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.