All examples
Machine learning

Fit native e-means clusters

Fit moving centroid statistics on complete synthetic tensors and inspect final labels, inertia and bounded CPU workers.

emeans_native.aner
// Requires the matching 0.0.10-dev.3 development runtime.
import aner.ml
import aner.tensor
import aner.parallel

let x = [[0.0, 0.0], [0.0, 2.0], [10.0, 10.0], [10.0, 12.0]]
let execution = parallel.local(workers: 2)
let model: CentroidModel = ml.fit_emeans(features: x, clusters: 2,
    epochs: 3.0, seed: 42, execution: execution)
print(model.summary())
print(model.inertia())
let predicted = model.predict(input: [[0.0, 1.0], [10.0, 11.0]],
    execution: execution)
print(tensor.value(predicted, 0, 0))
print(tensor.value(predicted, 1, 0))
// IDs are arbitrary center indices. Inspect coordinates to interpret them.
let centers = model.centers()
print(tensor.value(centers, 0, 0))
print(tensor.value(centers, 1, 0))

Make it your experiment.

Use Aner 0.1.0 or newer. Save this program as examples/emeans_native.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/emeans_native.aner
aner run examples/emeans_native.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Requires Aner 0.1.0 or newer. Complete synthetic tensors are included; no download, credentials, external service or output file is needed. Uses CPU Float64 and a bounded local worker context.

Credential setup
aner check examples/emeans_native.aner
aner run examples/emeans_native.aner

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner