kumulant

DecisionTreeRegressionStat

class DecisionTreeRegressionStat(val featureSize: Int, val splitCandidates: List<SerializableSplit>, val config: RegressionTreeConfig = RegressionTreeConfig(), val concurrency: Concurrency = Concurrency.None, leafArmFactory: (Concurrency) -> SeriesStat<WeightedVarianceResult>? = null, randomSeed: Int = StatDefaults.TREE_RANDOM_SEED) : RegressionStat<TreeRegressionResult> (source)

Online VFDT decision-tree regressor; a piecewise-constant predictor over the feature space, growing on the fly via the Hoeffding bound. Wraps a RegressionTree in the kumulant RegressionStat contract so it composes with everything that consumes regressors (the bandit family, schemas, op pipelines).

Snapshots are immutable TreeRegressionResults carrying the frozen split structure and per-node weighted-variance aggregates; bandits pair this with a tree-aware com.eignex.kumulant.stat.regression.RegressionPosterior (e.g. MeanTreePosterior or ThompsonTreePosterior) to score arms at choose time.

Reward encoding lives at the call site; pre-transform y (e.g. ln(y)) before update. The internal leaf accumulator is fixed to VarianceStat's WeightedVarianceResult so the VarianceReduction split metric applies.

Use cases: non-linear regression where the relationship between context and target is piecewise constant or step-like; bandit reward modelling, contextual stratification, anything where linear regression would miss the structure. Reach for RandomForestRegressionStat for ensembled diversity.

Memory: O(nodes · splitCandidates); a VarianceStat per node plus per-audit-leaf candidate accumulators. Bounded by RegressionTreeConfig.maxNodes.

Update: O(depth) per observation; a tree walk to the destination leaf, then an arm update at that leaf. Splits fire at most once every RegressionTreeConfig.splitPeriod observations per audit leaf.

Concurrency: The hot update path touches exactly one accumulator; the leaf the observation routes to. Internal split nodes carry no live arm; subtree aggregates (rootSnapshot, TreeSplitResult.value) are derived by combining descendants at snapshot time. Each leaf arm is a VarianceStat honouring Concurrency, so multiple threads landing in different leaves never contend. Split conversion takes a per-tree lock fired only at split decisions. Predictions (the load-bearing consumer for bandits) are race-free; the root-level aggregate TreeRegressionResult.totalWeights / rootMean is best-effort under concurrent growth and may drift by a few ULPs of the workload; single-threaded runs are exact. See RegressionTree for the full concurrency design.

Constructors

DecisionTreeRegressionStat

constructor(featureSize: Int, splitCandidates: List<SerializableSplit>, config: RegressionTreeConfig = RegressionTreeConfig(), concurrency: Concurrency = Concurrency.None, leafArmFactory: (Concurrency) -> SeriesStat<WeightedVarianceResult>? = null, randomSeed: Int = StatDefaults.TREE_RANDOM_SEED)(source)

Properties

concurrency

open override val concurrency: Concurrency(source)

Thread-safety mode fixed at construction. See Concurrency for the shared contract and the implementation's KDoc for its cell and lock strategy.

config

Tunables shared with the underlying RegressionTree.

featureSize

open override val featureSize: Int(source)

Number of features expected in x on each update. Mismatched lengths throw.

splitCandidates

Candidate splits considered at every audit leaf. Pass an empty list to disable growth; the regressor then degenerates to a single global accumulator.

Functions

create

open override fun create(concurrency: Concurrency? = null): DecisionTreeRegressionStat(source)

Create an independent accumulator at the configured baseline. A null concurrency preserves this accumulator's mode; a non-null value overrides it. Modality subtypes narrow the return type to preserve the input shape.

merge

open override fun merge(values: TreeRegressionResult, timestampNanos: Long = currentTimeNanos())(source)

Fold a compatible snapshot values into this accumulator at timestampNanos. Implementations document whether the combine is exact or approximate and which state the snapshot omits. The source accumulator is unaffected.

Time-dependent statistics, such as windows, place the snapshot at timestampNanos, which must share the clock the caller uses for updates and reads. Time-independent statistics ignore it.

read

open override fun read(timestampNanos: Long = currentTimeNanos()): TreeRegressionResult(source)

Return the current result evaluated at timestampNanos. Time-independent statistics ignore the timestamp. Reading does not add an observation.

Snapshot consistency depends on the implementation's synchronisation. Locks protect coupled state under Concurrency.Strict and Concurrency.HighWrite; independently updated cells and JVM striped adders can still yield a best-effort snapshot. Concurrency.Relaxed permits drift across coupled cells.

reset

open override fun reset()(source)

Restores empty state and restarts the seed streams for reproducible growth.

tree

fun tree(): RegressionTree<Vector>(source)

Live underlying tree. Use for inspection / pretty-printing.

Link copied to clipboard
open fun update(x: Vector, y: Double, weight: Double = 1.0)

Record the pair (x, y) with weight at the current monotonic time.

open fun update(x: DoubleArray, y: Double, weight: Double = 1.0)

Convenience overload that wraps x as a DenseVector.

open fun update(x: DoubleArray, y: Double, timestampNanos: Long, weight: Double = 1.0)

Timestamped convenience overload that wraps x as a DenseVector.

open override fun update(x: Vector, y: Double, timestampNanos: Long, weight: Double = 1.0)

Record the pair (x, y) with weight at timestampNanos.

Link copied to clipboard

Validate values for merge without changing accumulator state. Containers validate every child before merging any of them. Successful validation checks compatibility; it does not make a concurrent merge transactional.

update

open override fun update(x: Vector, y: Double, timestampNanos: Long, weight: Double = 1.0)(source)

Record the pair (x, y) with weight at timestampNanos.