All examplesMachine learning Install Aner
Evaluate predictions and partitions
Run accuracy, confusion matrix, mean squared error and adjusted Rand index on complete deterministic inputs.
// Native classification, numerical-error and partition metrics on synthetic values.
import aner.metrics;
import aner.tensor;
fn main() -> Unit {
let predicted: Tensor = [[1.0], [1.0], [2.0], [0.0]];
let actual: Tensor = [[0.0], [1.0], [1.0], [2.0]];
print(metrics.accuracy(predicted: predicted, actual: actual));
let counts = metrics.confusion_matrix(predicted, actual, classes: 3);
print(tensor.value(counts, row: 0, column: 1));
print(tensor.value(counts, row: 1, column: 2));
let prediction: Tensor = [[1.0, 3.0], [4.0, 8.0]];
let truth: Tensor = [[0.0, 1.0], [4.0, 4.0]];
print(metrics.mean_squared_error(prediction, truth));
let groups: Tensor = [[0.0], [0.0], [1.0], [1.0]];
let same_partition: Tensor = [[9.0], [9.0], [8.0], [8.0]];
let crossed_partition: Tensor = [[0.0], [1.0], [0.0], [1.0]];
print(metrics.adjusted_rand_index(groups, same_partition));
print(metrics.adjusted_rand_index(groups, crossed_partition));
}
Make it your experiment.
With Aner installed, save this program as examples/metrics_demo.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/metrics_demo.aner
aner run examples/metrics_demo.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Use a compatible current native Aner executable. This complete example runs locally with the declared inputs; the guide explains exact shapes, expected results and resource limits.
Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution