All examplesNeural networks Install Aner
Iris with mean squared error
Fit a classifier using squared softmax probability errors, training fitted preprocessing, and a held out evaluation.
Download .aner source// Iris: Fisher (1936), UCI, CC BY 4.0. See THIRD_PARTY_DATA.md.
// MSE averages squared softmax-probability errors over rows × classes.
// Split first; the fitted pipeline learns preprocessing only from training rows.
import aner.dataset
import aner.nn
import aner.ml
let flowers = dataset.iris()
let split = flowers.split(test: 0.2, seed: 2026)
let network = nn.sequential(seed: 42)
.dense(inputs: 4, outputs: 8)
.tanh()
.dense(inputs: 8, outputs: 3)
let pipeline = ml.classifier(network, standardize: true, loss: "mse")
let fitted = pipeline.fit(split.train(), epochs: 2000, rate: 0.1)
print(fitted.evaluate(split.test()).summary())
Make it your experiment.
With Aner installed, save this program as examples/neural_iris_mse.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.
aner check examples/neural_iris_mse.aner
aner run examples/neural_iris_mse.anerThe aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.
Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.
Dataset sources & attribution