kumulant

ConfusionMatrixResult

@Serializable
@SerialName(value = "ConfusionMatrixResult")
data class ConfusionMatrixResult(val numClasses: Int, val counts: DoubleArray) : Result(source)

Snapshot of a weighted K-by-K confusion matrix indexed as counts[predicted][truth].

Exposes the family of confusion-matrix metrics as derived getters: per-class precision/recall/F1, macro and micro averages, accuracy, and Matthews correlation coefficient (defined for any K). Empty rows or columns yield 0 for the corresponding rate rather than NaN, which keeps macro averages well-defined while a stream is warming up.

Constructors

Link copied to clipboard
constructor(numClasses: Int, counts: DoubleArray)

Properties

Link copied to clipboard

Fraction of correctly classified weight; 0 on an empty stream.

Link copied to clipboard

Sum of the diagonal (correctly classified weight).

Link copied to clipboard

Row-major numClasses * numClasses weights: counts[pred * numClasses + truth].

Link copied to clipboard

Macro F1: unweighted mean of per-class F1.

Link copied to clipboard

Macro precision: unweighted mean of per-class precision.

Link copied to clipboard

Macro recall: unweighted mean of per-class recall.

Link copied to clipboard
val mcc: Double

Matthews correlation coefficient generalised to K classes (Gorodkin 2004). Returns 0 when either margin is degenerate.

Link copied to clipboard

Number of classes.

Link copied to clipboard

Total weight across all cells.

Functions

Link copied to clipboard

True-class total: weight of all columns where truth = c.

Link copied to clipboard
fun count(predicted: Int, truth: Int): Double

counts[pred][truth].

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun f1(c: Int): Double

Per-class F1: harmonic mean of precision and recall; 0 when both are 0.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Per-class precision: TP / (TP + FP); 0 when no predictions for class c.

Link copied to clipboard

Predicted-class total: weight of all rows where prediction = c.

Link copied to clipboard
fun recall(c: Int): Double

Per-class recall: TP / (TP + FN); 0 when no truth observations for class c.

ConfusionMatrixResult

constructor(numClasses: Int, counts: DoubleArray)(source)

accuracy

Fraction of correctly classified weight; 0 on an empty stream.

actualTotal

True-class total: weight of all columns where truth = c.

correct

Sum of the diagonal (correctly classified weight).

count

fun count(predicted: Int, truth: Int): Double(source)

counts[pred][truth].

counts

Row-major numClasses * numClasses weights: counts[pred * numClasses + truth].

equals

open operator override fun equals(other: Any?): Boolean(source)

f1

fun f1(c: Int): Double(source)

Per-class F1: harmonic mean of precision and recall; 0 when both are 0.

hashCode

open override fun hashCode(): Int(source)

macroF1

Macro F1: unweighted mean of per-class F1.

macroPrecision

Macro precision: unweighted mean of per-class precision.

macroRecall

Macro recall: unweighted mean of per-class recall.

mcc

Matthews correlation coefficient generalised to K classes (Gorodkin 2004). Returns 0 when either margin is degenerate.

numClasses

Number of classes.

precision

Per-class precision: TP / (TP + FP); 0 when no predictions for class c.

predictedTotal

Predicted-class total: weight of all rows where prediction = c.

recall

Per-class recall: TP / (TP + FN); 0 when no truth observations for class c.

totalWeights

Total weight across all cells.