v2026.6.4
All Bundles
Bundle Core machine learning types: the seedable Random generator, Matrix2D linear algebra and activations, matrix reference holders, the NeuralNetwork and CSV-backed MatrixReader. Compile with -lib ml.

Metrics

Model evaluation metrics for classification tasks

Operations

Accuracy # native

Calculates accuracy: (TP + TN) / Total

function : native : Accuracy(predictions:Bool[], actuals:Bool[]) ~ Float

Parameters

NameTypeDescription
predictionsBoolpredicted boolean values
actualsBoolactual boolean values

Return

TypeDescription
Floataccuracy score between 0.0 and 1.0

ConfusionMatrix # native

Creates a confusion matrix

function : native : ConfusionMatrix(predictions:Bool[], actuals:Bool[]) ~ Int[,]

Parameters

NameTypeDescription
predictionsBoolpredicted boolean values
actualsBoolactual boolean values

Return

TypeDescription
Int2x2 confusion matrix [[TN, FP], [FN, TP]]

F1Score # native

Calculates F1 score: 2 * (Precision * Recall) / (Precision + Recall)

function : native : F1Score(predictions:Bool[], actuals:Bool[]) ~ Float

Parameters

NameTypeDescription
predictionsBoolpredicted boolean values
actualsBoolactual boolean values

Return

TypeDescription
FloatF1 score between 0.0 and 1.0

MCC # native

Calculates Matthews Correlation Coefficient (MCC)

function : native : MCC(predictions:Bool[], actuals:Bool[]) ~ Float

Parameters

NameTypeDescription
predictionsBoolpredicted boolean values
actualsBoolactual boolean values

Return

TypeDescription
FloatMCC score between -1.0 and 1.0

Precision # native

Calculates precision: TP / (TP + FP)

function : native : Precision(predictions:Bool[], actuals:Bool[]) ~ Float

Parameters

NameTypeDescription
predictionsBoolpredicted boolean values
actualsBoolactual boolean values

Return

TypeDescription
Floatprecision score between 0.0 and 1.0

PrintConfusionMatrix # native

Prints a formatted confusion matrix

function : native : PrintConfusionMatrix(matrix:Int[,]) ~ Nil

Parameters

NameTypeDescription
matrixInt2x2 confusion matrix

Recall # native

Calculates recall (sensitivity): TP / (TP + FN)

function : native : Recall(predictions:Bool[], actuals:Bool[]) ~ Float

Parameters

NameTypeDescription
predictionsBoolpredicted boolean values
actualsBoolactual boolean values

Return

TypeDescription
Floatrecall score between 0.0 and 1.0