kumulant

RegressionStat

interface RegressionStat<R : Result> : Stat<R> (source)

Accumulator over vector-covariate / scalar-response observations (x, y, weight), where x is a fixed-dimensional feature vector and y is the scalar target. The multivariate generalisation of PairedStat and the input shape for every linear / non-linear regressor.

Implementations cover the full spread from a one-pass SGD weight tracker (StochasticRegressionStat) to a full Bayesian linear regression with a joint posterior (BayesianRegressionStat) to a non-linear decision tree (DecisionTreeRegressionStat). They share the update shape and differ in what they expose on read.

Inputs are passed as Vector so callers can submit sparse feature vectors without materialising them into dense arrays first. The DoubleArray convenience overloads wrap the array in a DenseVector; the sparse path goes through com.eignex.koblas.SparseVector.

The K-way classifiers (SoftmaxRegressionStat, GaussianNaiveBayesStat) also use this interface; y is the class index in [0, numClasses).

Inheritors

Properties

featureSize

abstract val featureSize: Int(source)

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

Link copied to clipboard
abstract val concurrency: Concurrency

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

Functions

create

abstract override fun create(concurrency: Concurrency? = null): RegressionStat<R>(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.

update

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

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


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

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


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

Convenience overload that wraps x as a DenseVector.


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

Timestamped convenience overload that wraps x as a DenseVector.

Link copied to clipboard
abstract fun merge(values: R, timestampNanos: Long = currentTimeNanos())

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.

Link copied to clipboard
abstract fun read(timestampNanos: Long = currentTimeNanos()): R

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

Link copied to clipboard
abstract fun reset()

Restore the configured baseline, including any prior seed. Preserves the configuration and concurrency.

Link copied to clipboard
open fun validateMerge(values: R)

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.