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 covariance (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 VectorView 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.kumulant.math.SparseVector.

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

Inheritors

Properties

Link copied to clipboard
abstract val concurrency: Concurrency

The thread-safety contract this stat was constructed with. Each stat picks the cell-encoding and lock strategy that honours this contract for its mathematical structure:

Link copied to clipboard
abstract val featureSize: Int

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

Functions

Link copied to clipboard
abstract override fun create(concurrency: Concurrency? = null): RegressionStat<R>

Spawn a fresh accumulator with the same configuration. Optionally override the Concurrency; useful for materialising a wire spec at a different concurrency level than the source.

Link copied to clipboard
abstract fun merge(values: R)

Fold another accumulator's snapshot into this one. The unit of merge is the immutable Result; not a live Stat; which is what lets the merge cross a process boundary. Many workers track slices of the same stream, call read periodically, ship snapshots to a coordinator, and the coordinator merges them in.

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

Materialise the current state as an immutable Result. Reads never mutate, so the caller can read as often as it likes without affecting the stream.

Link copied to clipboard
abstract fun reset()

Reset the stat to its prior-seeded baseline. Equivalent to constructing a fresh stat with the same configuration, but in place; keeps the same Concurrency and any per-stat tunables.

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

Record an (x, y) observation with the given weight at the current time.

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

Convenience overload that wraps x as a DenseVector.

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

Record an (x, y) observation at timestampNanos with the given weight.

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

Timestamped convenience overload that wraps x as a DenseVector.

create

abstract override fun create(concurrency: Concurrency? = null): RegressionStat<R>(source)

Spawn a fresh accumulator with the same configuration. Optionally override the Concurrency; useful for materialising a wire spec at a different concurrency level than the source.

The returned stat is independent: its state starts at the configured baseline, not at the source's current state. Each modality subtype narrows the return type so chaining doesn't lose the modality.

featureSize

abstract val featureSize: Int(source)

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

update

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

Record an (x, y) observation with the given weight at the current time.


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

Record an (x, y) observation at timestampNanos with the given weight.


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.