Well known datasets
Load Iris, Wine, Titanic and Diabetes by name without preparing CSV files; inspect features and class labels, then split before fitting preprocessing.
Implementedaner.dataset lets you load well known datasets by name without finding, downloading or preparing a CSV file. The bundled catalogue is available offline through one module API, with immutable row views, reproducible splits and explicit feature scaling. Each dataset retains its source identity, label mapping and applicable license.
Start with dataset.load(id) or a named helper, discover available IDs with dataset.count() and dataset.id(index), and split before fitting preprocessing. Use the separate aner.data module when you need to read your own external CSV files with typed columns and explicit missingness.
Module guide and API map
Use this page for source loading, metadata, extraction and scaling. The partition reference supplies the complete role, group, fold and lazy batch APIs; the MNIST protocol covers the separately prepared local IDX source. These are references for aner.dataset, rather than additional importable submodules.
| Workflow | Entry points | Detailed reference |
|---|---|---|
| Discover and load offline teaching sources | dataset.count, dataset.id, dataset.load, named helpers | Included datasets and loading below |
| Build a local numerical classification source | dataset.from_tensors, dataset.synthetic | Custom sources below |
| Inspect identity, schema and numerical values | Metadata accessors, features, targets, one_hot, row_ids | Loading and extraction below |
| Separate fitting, selection and final evaluation | split, partition, kfold, with_groups, audit | Partitions, groups and folds |
| Visit source rows in bounded batches | batches, batch, overloaded count | Lazy schedules |
| Fit and reuse population scaling | fit_standardizer, transform, center, scale | Scaling below and Dataset overload |
| Fit a model and evaluate its predictions | ml.classifier, ml.fit_knn, metrics.* | Machine learning, Neural networks, Metrics |
Quick start: inspect, partition and batch
The online partition example includes downloadable source and instructions. Run the complete partition example from the folder containing the distributed examples directory:
aner check examples/dataset_partitions.aner
aner run examples/dataset_partitions.anerIt loads offline Iris, creates 90 training, 30 validation and 30 test rows, checks disjointness, fits training only scaling, visits six batches of 16/16/16/16/16/10 rows, and inspects one of five folds. Its exact output is recorded in the partition guide. No network, credentials or accelerator is required. For source attribution and every feature/class name, also check and run the catalogue program.
Included datasets
| ID / helper | Rows | Features | Classification target | Source details |
|---|---|---|---|---|
iris / dataset.iris() | 150 | 4 flower measurements (cm) | 3 species, 50 rows each | Iris |
wine / dataset.wine() | 178 | 13 chemical measurements | 3 cultivar codes: 59, 71, 48 rows | Wine |
titanic / dataset.titanic() | 1,309 | 4 selected passenger predictors | Survival: 809 died, 500 survived | Titanic |
diabetes / dataset.diabetes() | 768 | 8 original numeric predictors | Binary outcome: 500 negative, 268 positive | Diabetes |
All four datasets provide numeric feature tables with categorical targets for supervised learning. Loading preserves the declared feature representation; it does not standardize data or fit a model. Named dataset helpers belong to aner.dataset, not separate dataset modules.
Titanic is a declared numeric teaching subset of the Vanderbilt 1,309 passenger source. It retains every source row and selects pclass, sex (female = 0, male = 1), sibsp and parch. It excludes age and fare, which contain missing values, and post outcome fields such as boat and body. No imputation or complete case row deletion occurs. This is a different source variant from the 891 row competition training file; the complete original CSV remains in the source assets.
Diabetes is the traditional Pima Indians Diabetes binary classification dataset, with all 768 rows and eight original numeric predictors. The source uses zero placeholders in several physiological fields. Aner preserves these as numeric zeros, without a missingness mask, automatic replacement or imputation. Declare an appropriate missing value and preprocessing fitted on training data policy for your experiment. This ID does not refer to the separate 442 row Diabetes regression dataset or a synthetic replacement; the source details explain the historical source and current distribution status.
Load and inspect data
import aner.dataset;
fn main() -> Unit {
let flowers: Dataset = dataset.iris();
print(dataset.name(flowers));
print(dataset.rows(flowers));
print(dataset.feature_name(flowers, 0));
print(dataset.feature_unit(flowers, 0));
print(dataset.citation(flowers));
print(dataset.sha256(flowers));
let passengers = dataset.load("titanic");
let diabetes = dataset.diabetes();
print(dataset.rows(passengers)); // 1309
print(dataset.classes(diabetes)); // 2
}dataset.load("iris") and dataset.iris() return the same dataset; every catalogue ID supports the same named loading pattern. Catalogue discovery uses dataset.count() and zero based dataset.id(index). Run examples/dataset_catalog.aner to inspect every bundled dataset and all feature/class names.
| Function | Result |
|---|---|
dataset.load(name: String), dataset.iris(), dataset.wine(), dataset.titanic(), dataset.diabetes() | Dataset |
dataset.count() | Int64 catalogue size |
dataset.id(index: Int64) | String catalogue ID |
dataset.name(data: Dataset), dataset.description(data: Dataset) | String source name and description |
dataset.citation(data: Dataset), dataset.license(data: Dataset) | String attribution and source specific distribution terms |
dataset.source(data: Dataset), dataset.version(data: Dataset), dataset.sha256(data: Dataset) | String immutable source identity; SHA256 is a lowercase hexadecimal content fingerprint |
dataset.rows(data: Dataset), dataset.cols(data: Dataset), dataset.classes(data: Dataset) | Int64 dimensions of the current view and its declared class vocabulary |
dataset.feature_name(data: Dataset, index: Int64), dataset.feature_unit(data: Dataset, index: Int64) | String metadata at a zero based feature index |
dataset.class_name(data: Dataset, index: Int64) | String class meaning at a zero based class index |
dataset.features(data: Dataset) | Detached Tensor of shape rows × features, in original units |
dataset.targets(data: Dataset) | Detached rows × 1 Tensor of zero based class IDs |
dataset.one_hot(data: Dataset) | Detached rows × classes Tensor with exactly one 1 per row |
dataset.row_ids(data: Dataset) | Detached rows × 1 Tensor of original zero based source row IDs |
Current tensors store Float64, including exactly represented integer class and row IDs. The dataset's class name mapping defines target meaning. A model must never treat class IDs as continuous measurements or append targets to its input features.
Dataset, DatasetSplit, DatasetPartition, DatasetFolds, DatasetBatches, and Standardizer are immutable built in value types. Copies share immutable backing storage; tensor extraction produces detached data. They can be function parameters and return values, with local type inference as usual. Import aner.dataset to use these types. It also exposes Tensor for its data APIs; neutral inspection uses import aner.tensor;, while calls to nn.* still require import aner.nn;. Composite values cannot be printed or compared directly: inspect their fields through the API.
Custom sources
| Native signature | Result and contract |
|---|---|
dataset.from_tensors(features: Tensor, targets: Tensor) | Dataset; finite N × D features and matching N × 1 integer class IDs from 0 through 1023; retains detached numerical copies. |
dataset.synthetic(rows: Int64, inputs: Int64, classes: Int64, seed: Int64) | Dataset; seeded finite synthetic classification with a linear teacher, 1 to 1,000,000 rows, 1 to 4096 inputs and 2 to 256 declared classes. |
dataset.mnist(directory: String, partition: String) | Dataset; locally verified canonical IDX source, with partition exactly "train" or "test"; official roles are protected. |
from_tensors derives class names class_0 through the highest observed ID, feature names feature_0 onward and unknown feature units. Sparse supplied labels leave unused entries in that declared class vocabulary. The source's content derived identity records the numerical values and labels; its attribution remains caller supplied. This constructor does not recover source row identities or experiment authorization previously discarded during Tensor extraction. Attach real observed group IDs before partitioning when appropriate.
synthetic generates uniform dimensionless features and argmax labels from a seeded linear teacher. It is a numerical fixture rather than real world data or a performance benchmark. Its declared class count does not guarantee that every class occurs in a small sample. Source features are capped at 8,000,000 values and generation at 500,000,000 estimated teacher work units; materializing a Tensor still enforces the separate 1,000,000 cell limit. Prefer lazy batches for a larger source. MNIST requires the local files and hashes described in the MNIST protocol; dataset.count() enumerates only the four bundled teaching sources.
Split before fitting preprocessing
Inside main() after loading flowers, use this sequence; the complete partition and classifier downloads include their own imports and source declarations.
let parts: DatasetSplit = dataset.split(flowers, 0.2, 2026);
let training = dataset.train(parts);
let testing = dataset.test(parts);
let scaler: Standardizer = dataset.fit_standardizer(dataset.features(training));
let x_train = dataset.transform(scaler, dataset.features(training));
let x_test = dataset.transform(scaler, dataset.features(testing));dataset.split(data: Dataset, test: Float64, seed: Int64) stratifies by class. The fraction must be finite and strictly between zero and one. Each class needs at least two rows. For each class of size n, the test count is floor(n * fraction + 0.5), clamped to 1 through n−1. The actual overall test fraction can differ from the requested fraction, especially for small views. Iris at 0.2 yields 120/30; Wine yields 142/36. Titanic yields 1047/262 and Diabetes yields 614/154.
SplitMix64, classes in ascending ID order and rejection sampled Fisher and Yates define the permutation without standard library distribution differences. Returned views keep their selected rows in original source order. Train/test views are disjoint by source row ID and cover the input view. Repeating the seed and source version reproduces membership; dataset.row_ids makes it inspectable. Splitting a view again follows the same rules.
The original two way row split does not deduplicate observations or infer group identity. Iris's repeated records can occur on opposite sides. This teaching example is not a rigorous generalization benchmark. Use explicitly supplied group identity and the audited partition/fold APIs when rows share a sampling unit. Time based separation requires a separately declared policy. Class stratification does not infer statistical independence. See dataset partitions.
dataset.fit_standardizer(train_features) computes each column's population mean and standard deviation. Constant columns use scale 1. dataset.transform(scaler, features) applies those fixed statistics and never refits. dataset.center(scaler) and dataset.scale(scaler) expose 1 × feature count tensors. Wrong shapes, invalid handles, nonfinite fractions, and unrepresentable finite results produce diagnostics. Preprocessing is detached from automatic differentiation.
Scaling signatures and failure handling
Parameter names below are the actual native named argument labels. Both overloads use features, including the Dataset overload.
| Native signature | Result and contract |
|---|---|
dataset.fit_standardizer(features: Tensor) | Standardizer; population mean and standard deviation across finite feature rows, without Dataset role identity. |
dataset.fit_standardizer(features: Dataset) | Standardizer; stream source rows and reject validation/test fitting roles. |
dataset.transform(scaler: Standardizer, features: Tensor) | Detached Tensor of the same shape; feature width must match the fitted statistics. |
dataset.center(scaler: Standardizer) | Detached CPU Float64 1 × D Tensor of fitted means. |
dataset.scale(scaler: Standardizer) | Detached CPU Float64 1 × D Tensor of positive fitted population scales. |
Loading accepts known case sensitive catalogue IDs; discovery and feature/class indexing are zero based and bounded. Unknown IDs, out of range indices, invalid splits or groups, wrong shapes, invalid class IDs, held out fitting and nonrepresentable results report source located R2201 errors. Tensor construction can fail first under its own Tensor diagnostic. Source extraction is detached CPU Float64 storage and keeps the view's row order. Extraction requires rows × features or rows × classes to fit the Tensor limit, so use batches when a complete extraction would exceed it.
No call in this module imputes missing values or automatically changes feature meaning. The partition reference documents admission bounds, protected roles and exact membership checks; the Tensor reference documents numerical allocation and graph bounds.
Train the Iris classifier
Follow the one time installation guide to put aner on your PATH. Run these commands from the folder containing the binary bundle's examples directory:
aner run examples/dataset_catalog.aner
aner check examples/neural_iris.aner
aner run examples/neural_iris.anerThe same commands work on macOS, Linux, and Windows. Aner interprets the .aner source and performs native CPU Float64 computation; the example does not invoke another ML framework.
The runnable example fixes the split seed at 2026 and initialization seeds at 42 and 43. Its architecture is four standardized inputs → eight tanh hidden units → three linear logits, with 67 trainable scalars. It trains for 2000 full batch epochs using SGD at learning rate 0.1. Here one optimizer step processes the entire training set, so completed steps and completed epochs coincide. No test accuracy is used for updates, early stopping, or hyperparameter selection.
nn.cross_entropy(logits, one_hot_targets) computes the stable mean multiclass loss over rows directly from raw logits. Do not pass softmax probabilities to that function. Targets must be exact one hot constant tensors. nn.softmax(logits) produces row wise probabilities for inspection, nn.argmax(scores) returns class IDs, and nn.accuracy(scores, class_ids) returns a fraction between 0 and 1. The example evaluates the same class IDs through shared metrics.accuracy(nn.argmax(scores), class_ids) from aner.metrics; the older nn.accuracy API remains available. Argmax breaks ties at the first class index. Accuracy uses all rows supplied by the caller and does not create a test split itself.
The program prints source identity, seeds, partition sizes, training settings, training loss, and final train/test accuracy. A single 30 row test result is a teaching sanity check with substantial sampling uncertainty. Bitwise floating point equality across different hardware/compiler/library versions is not promised.
Train Titanic and Diabetes classifiers
The Titanic survival classifier and Pima Diabetes classifier show the same five steps: load a bundled dataset by name, create a seeded stratified split, configure the network and preprocessing, fit only on training rows, and evaluate the held out test once.
aner check examples/neural_titanic_concise.aner
aner run examples/neural_titanic_concise.aner
aner check examples/neural_diabetes_concise.aner
aner run examples/neural_diabetes_concise.anerStep through the same workflow in the Titanic VS Code notebook or Pima Diabetes VS Code notebook. Both open in Shared variables and Dev modes, with separate cells for loading, splitting, configuration, fitting, learned preprocessing and evaluation. Use Inspector after a cell finishes, or open its Development Training Report. See notebook setup and inspection.
Neither example needs CSV files or a network connection. Use an Aner runtime with the Titanic and Diabetes loaders. Titanic uses the four selected numeric predictors described above and a 4 → 8 → 2 network. Diabetes uses eight original predictors and an 8 → 12 → 2 network. Both select CPU Float64, fix the split seed at 2026 and network seed at 42, and use Adam for 400 full batch epochs at rate 0.01.
ml.classifier(network, standardize: true) declares preprocessing. The call to pipeline.fit(training, ...) learns feature means and population standard deviations from those training rows and fits the classifier. The fitted model owns those statistics; evaluate(testing) reuses them without refitting or updating parameters. Each example prints partition counts, the first feature's learned mean and scale, and the held out evaluation summary. Test outcomes do not select the training settings or epoch count.
The Titanic split does not infer family groups. The Diabetes example preserves zero measurement placeholders and does not impute them; standardization is the only preprocessing in this tutorial. Refer to each dataset's source details before changing its representation or evaluation protocol.
Create a visual training report
aner run examples/neural_iris.aner --debug-viz reports/iris --debug-valuesUse a new output directory. Open reports/iris/index.html in a browser or read summary.txt from a terminal. The trace stores 23 training captures: 0, 1, 2, each subsequent hundred, and 2000. It includes only training graph observations; the test set is evaluated after training. In the output layer, the captured values are logits, not probabilities. Cross entropy gradients refer to the full training batch loss.
--debug-values exports bounded raw cells, including standardized features and model derived tensors. Omit it for statistics. Loaded dataset attribution is retained in the report; this records which datasets were loaded, not complete per tensor data lineage. See visual capture limits before expecting every cell of a larger network to appear. VS Code also provides Aner: Debug Iris.
Reuse the data for other algorithms
Neural classification uses features, one_hot, and class IDs for evaluation. CPU KNN and K means are now implemented in aner.ml. KNN Iris fits feature/class-ID tensors and uses shared label accuracy and a confusion matrix. K means Iris fits feature tensors without labels and evaluates held out cluster assignments using adjusted Rand index; cluster IDs are not species IDs. Both reuse the neural example's split and training only scaler. See classical ML. SVMs and decision trees remain future algorithms.
Dataset source details and attribution
The module reference above explains how to load and use the catalogue. The Iris, Wine, Titanic and Diabetes dataset details are supplemental references for the exact source variants, feature definitions and label mappings. They describe dataset sources, not additional modules.
The selected source files are hash verified, embedded in Aner and ready to use offline. The dataset assets retain upstream files, source notes, applicable license text and SHA-256 hashes. Read the third party dataset notices and asset manifest for attribution, exact feature order, class mappings, missing value counts, source dates and representation changes. Run aner --data-notices to print attribution and bundled license text from the executable. Dataset licenses are separate from Aner's software license.
Aner preserves original UCI iris.data. UCI documents corrections for records 35 and 38 in another variant; Aner does not silently apply them. The source also has duplicate complete records. Wine's source does not provide feature units or cultivar names: the API returns unknown units and class_1, class_2, class_3. Unknown metadata is not inferred from feature names.
External sources and table to model conversion
The well known dataset catalogue is built into Aner. Its manifest describes provenance; it is not a third party dataset loader. Use aner.data for your own external CSV files. DataSchema declares types and nullability; DataScan builds a deferred plan; summaries use native batches; DataTable is an explicitly bounded collection. The existing catalogue Dataset and its class metadata remain separate types. CSV files do not automatically acquire target labels, class vocabularies, unit semantics, or stratified splits.
data.to_tensor(table, max_bytes) converts a complete numeric table explicitly, enforcing the current Tensor limit and rejecting missing or nonnumeric columns and Int64 values outside ±2^53. Dataset scalers and ML functions may then consume the result. This allocates new numerical storage; the original table can remain alive. KNN and K means retain their bounded complete Tensor interfaces. The neural classifier can train through a lazy Dataset mini batch schedule; that does not turn a CSV scan into a Dataset automatically.
For your own data, retain a source identifier, version and content hash, applicable license and notices, feature order and units, missing value policy, target/task description, and label mapping. Keep original source files and record conversions separately. Aner does not automatically create this metadata for external files.
Local MNIST and audited mini batches
dataset.mnist(directory, partition) loads locally verified canonical IDX bytes with protected official training/test roles. A training/validation partition and lazy mini batch schedules retain compact source pixels without materializing a complete feature Tensor. MNIST uses verified local IDX files; the four bundled catalogue datasets require no file preparation. See the MNIST protocol and dataset partition reference for hashes, role and group safeguards, seeded folds, streaming preprocessing, and time/space complexity.
See the complete callable index for the native module and method name catalogue.