kumulant

UnivariateRegressionResult

@Serializable
@SerialName(value = "UnivariateRegressionResult")
data class UnivariateRegressionResult(val penalty: Penalty, val totalWeights: Double, val slope: Double, val intercept: Double, val sse: Double, val sxy: Double, val x: VarianceResult, val y: VarianceResult) : Result, HasSlope, HasRegression(source)

Fitted univariate least-squares regression y = slope * x + intercept. Carries the marginal x / y variances and the raw weighted cross-deviation sxy so the result round-trips losslessly under merge regardless of penalty.

Constructors

UnivariateRegressionResult

constructor(penalty: Penalty, totalWeights: Double, slope: Double, intercept: Double, sse: Double, sxy: Double, x: VarianceResult, y: VarianceResult)(source)

Properties

correlation

Pearson correlation of the x and y streams, sxy / sqrt(sxx * syy).

Computed from the raw cross-deviation rather than from 1 - sse/sst, because sse is evaluated at the penalised slope: under Penalty.L1 with a lambda above the soft-thresholding cut the slope is exactly zero, making sse == sst and yielding a correlation of zero for perfectly correlated data. This is a property of the two streams and so is independent of penalty.

covariance

Weighted covariance sxy / totalWeights.

intercept

open override val intercept: Double(source)

Fitted intercept c.

penalty

slope

open override val slope: Double(source)

Fitted slope coefficient m.

sse

open override val sse: Double(source)

Sum of squared errors (residuals). Under non-identity GLMs this is the deviance.

sst

open override val sst: Double(source)

Sum of squared deviations from the running mean: Sum (x - mean)^2 * weight.

Implementors must override this or variance; the two are defined in terms of each other, so overriding neither recurses until the stack runs out. Every Result in the library overrides sst, which is the cheaper of the two to carry.

sxy

Raw weighted cross-deviation Sum((x - meanX)(y - meanY) * w) from the underlying accumulator. Stored explicitly so merge round-trips losslessly even when slope has been soft-thresholded to zero or shrunk away from sxy / sxx.

totalWeights

open override val totalWeights: Double(source)

Cumulative weight of observations folded into this result.

x

Marginal statistics of the x stream.

y

Marginal statistics of the y stream.

Link copied to clipboard
open override val bias: Double

Fitted bias / intercept term.

Link copied to clipboard
open override val featureSize: Int

Number of features in weights.

Link copied to clipboard
open val isEmpty: Boolean

True when no observation has been folded in, so every other field is a placeholder.

Link copied to clipboard
open val mse: Double

Mean squared error: sse / totalWeights. Zero on an empty stream.

Link copied to clipboard
open val rmse: Double

Root mean squared error: sqrt([mse]).

Link copied to clipboard
open val rSquared: Double

Coefficient of determination 1 - sse/sst. Zero when sst is zero.

Link copied to clipboard

Unbiased sample standard deviation: sqrt([sampleVariance]).

Link copied to clipboard

Unbiased sample variance: [sst] / ([totalWeights] - 1). Zero when totalWeights <= 1.

Link copied to clipboard
open val ssr: Double

Sum of squares due to regression: sst - sse.

Link copied to clipboard
open val stdDev: Double

Population standard deviation: sqrt([variance]).

Link copied to clipboard
open val variance: Double

Population variance: [sst] / [totalWeights]. Zero on an empty stream.

Link copied to clipboard
open override val weights: F64VectorView

Fitted weight per feature, indexed by the same i as the input x[i].

Functions

Link copied to clipboard
open fun predict(x: F64VectorView): Double

Evaluate the linear predictor at x: bias + Sum_i weights[i] * x[i]. For Gaussian regression this is the prediction; for non-identity GLMs this is the linear predictor pre-link.

open fun predict(x: Double): Double

Evaluate the fitted line at x: slope * x + intercept.