kumulant

GaussianNaiveBayesResult

@Serializable
@SerialName(value = "GaussianNaiveBayesResult")
data class GaussianNaiveBayesResult(val featureSize: Int, val numClasses: Int, val means: DenseMatrix, val variances: DenseMatrix, val classWeights: DenseVector, val totalWeights: Double, val varianceFloor: Double) : HasObservationCount(source)

Snapshot from GaussianNaiveBayesStat: per-class feature statistics and class priors. Each row of means and variances holds the running mean / variance of every feature conditioned on a given class.

Prediction uses the standard Gaussian-NB log-posterior: log p(c | x) proportional to log prior[c] - 0.5 * Sum_i [log(2 pi var) + (x_i - mu)^2 / var] with varianceFloor applied to each per-class variance to keep the log term finite.

Constructors

GaussianNaiveBayesResult

constructor(featureSize: Int, numClasses: Int, means: DenseMatrix, variances: DenseMatrix, classWeights: DenseVector, totalWeights: Double, varianceFloor: Double)(source)

Properties

classWeights

val classWeights: DenseVector(source)

Cumulative observation weight per class; length numClasses.

featureSize

Number of input features.

means

val means: DenseMatrix(source)

K-by-p matrix of per-class running means; means[c][i] is the mean of feature i given class c.

numClasses

Number of classes.

totalWeights

open override val totalWeights: Double(source)

Total cumulative observation weight across all classes.

varianceFloor

Lower bound applied to per-class variances at predict time.

variances

val variances: DenseMatrix(source)

K-by-p matrix of per-class running variances (population, weight-normalised).

Link copied to clipboard
open val isEmpty: Boolean

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

Functions

logPosterior

fun logPosterior(x: VectorView, c: Int): Double(source)

Unnormalised log-posterior log prior[c] + Sum_i log N(x_i | mu_c, var_c).

predict

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

Argmax class index for x.

prior

Class prior, computed from accumulated class weights.

probabilities

fun probabilities(x: VectorView): DoubleArray(source)

Normalised class probabilities via log-sum-exp on the log-posterior.