kumulant

SoftmaxRegressionResult

@Serializable
@SerialName(value = "SoftmaxRegressionResult")
data class SoftmaxRegressionResult(val featureSize: Int, val numClasses: Int, val weights: DenseMatrix, val biases: DenseVector, val totalWeights: Double, val step: Long, val crossEntropy: Double) : HasObservationCount(source)

Snapshot from SoftmaxRegressionStat: per-class linear-model parameters plus cumulative bookkeeping. The K-by-p weights matrix and length-K biases vector define the linear predictors eta[k] = biases[k] + weights[k] . x; the predicted class probability is the softmax over the K logits.

Constructors

SoftmaxRegressionResult

constructor(featureSize: Int, numClasses: Int, weights: DenseMatrix, biases: DenseVector, totalWeights: Double, step: Long, crossEntropy: Double)(source)

Properties

biases

val biases: DenseVector(source)

Per-class intercept; length numClasses.

crossEntropy

Accumulated weighted negative log-likelihood (cross-entropy) over the stream.

featureSize

Number of input features (columns of weights).

numClasses

Number of classes (rows of weights and length of biases).

step

Number of update calls absorbed.

totalWeights

open override val totalWeights: Double(source)

Cumulative weight of observations folded into this result.

weights

val weights: DenseMatrix(source)

K-by-p weight matrix; weights[k][i] is the coefficient on feature i for class k.

Link copied to clipboard
open val isEmpty: Boolean

True when totalWeights is not positive, including zero, negative values, and NaN.

Functions

logit

fun logit(x: Vector, k: Int): Double(source)

Linear predictor for class k: biases[k] + weights[k] . x.

logitsInto

fun logitsInto(x: Vector, destination: DoubleArray)(source)

Writes the per-class logits for x into destination.

predict

fun predict(x: Vector): Int(source)

Finds the argmax for x.

All numClasses logits come from one pass over x rather than a pass per class. Scoring a class at a time re-reads the whole context K times, and on a sparse x each of those reads is a search through its stored indices. The single pass costs one length-numClasses buffer, which is the cheaper side of that trade.

probabilities

Softmax probabilities across all classes for x; length numClasses.

probabilitiesInto

fun probabilitiesInto(x: Vector, destination: DoubleArray)(source)

Writes softmax probabilities for x into caller-owned destination.