kumulant

DecisionTreeClassifierStat

class DecisionTreeClassifierStat(val featureSize: Int, val numClasses: Int, val splitCandidates: List<SerializableSplit>, val config: ClassificationTreeConfig = ClassificationTreeConfig(), val concurrency: Concurrency = Concurrency.None, leafArmFactory: (Concurrency) -> SeriesStat<ClassCountsResult>? = null, randomSeed: Int = StatDefaults.TREE_RANDOM_SEED) : RegressionStat<TreeClassificationResult> (source)

Online VFDT decision-tree classifier; the classification counterpart of DecisionTreeRegressionStat. Each leaf carries a ClassCountsResult (per-class weighted counts); splits fire when a candidate beats the runner-up by the Hoeffding bound on Gini reduction or information gain.

Input is fed through RegressionStat: x is the feature vector, y is the class index in [0, numClasses), resolved by asClassLabel.

Use cases: online classification where the decision boundary is axis-aligned and piecewise constant, and the model must grow with the stream rather than be refit. Reach for RandomForestClassifierStat for ensembled diversity, or DecisionTreeRegressionStat when the target is continuous.

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

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

Concurrency: Inherits DecisionTreeRegressionStat's concurrency model, with ClassCountsStat leaf arms in place of variance accumulators. The update path touches exactly one leaf, so threads landing in different leaves never contend; split conversion takes a per-tree lock fired only at split decisions. See ClassificationTree for the full design.

Constructors

DecisionTreeClassifierStat

constructor(featureSize: Int, numClasses: Int, splitCandidates: List<SerializableSplit>, config: ClassificationTreeConfig = ClassificationTreeConfig(), concurrency: Concurrency = Concurrency.None, leafArmFactory: (Concurrency) -> SeriesStat<ClassCountsResult>? = 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 ClassificationTree.

featureSize

open override val featureSize: Int(source)

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

numClasses

Number of classes; the input y must round to [0, numClasses).

splitCandidates

Candidate splits considered at every audit leaf.

Functions

create

open override fun create(concurrency: Concurrency? = null): DecisionTreeClassifierStat(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: TreeClassificationResult, 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()): TreeClassificationResult(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

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

validateMerge

open override fun validateMerge(values: TreeClassificationResult)(source)

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.

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.

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.