{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "concise-iris-intro",
      "metadata": {},
      "source": "# Aner: a concise Iris classifier\n\nUse your installed Aner executable and the compatible VS Code extension (**0.1.16** for this example). Follow the versions recommended together by your release; see `docs/INSTALLATION.md` and `docs/VSCODE.md`. Run these cells in order, or choose **Run All**. The notebook uses shared native variables. The workflow trains a small CPU Float64 dense classifier using full batch SGD and cross entropy.\n\nThe configuration and fitted model are separate values: `fit` creates a new fitted snapshot. Test rows never fit the standardizer.\n"
    },
    {
      "cell_type": "code",
      "id": "concise-iris-data",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": "import aner.dataset\nimport aner.nn\nimport aner.ml\n\nlet flowers = dataset.iris()\nlet split = flowers.split(test: 0.2, seed: 2026)\n"
    },
    {
      "cell_type": "markdown",
      "id": "concise-iris-topology-note",
      "metadata": {},
      "source": "## Define the topology\n\nFour input features → eight dense units → tanh → three output logits. Layer dimensions are explicit and checked. The network initialization seed is separate from the data split seed.\n\nThe fit cell prints the final training loss. The evaluation cell prints the full training configuration, provenance, and held out results.\n"
    },
    {
      "cell_type": "code",
      "id": "concise-iris-topology",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": "let network = nn.sequential(seed: 42)\n    .dense(inputs: 4, outputs: 8)\n    .tanh()\n    .dense(inputs: 8, outputs: 3)\nlet pipeline = ml.classifier(network, standardize: true)\n"
    },
    {
      "cell_type": "code",
      "id": "concise-iris-fit",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": "let fitted = pipeline.fit(split.train(), epochs: 2000, rate: 0.1)\nprint(fitted.training_loss())\n"
    },
    {
      "cell_type": "code",
      "id": "concise-iris-evaluate",
      "metadata": {},
      "execution_count": null,
      "outputs": [],
      "source": "print(fitted.evaluate(split.test()).summary())\n"
    },
    {
      "cell_type": "markdown",
      "id": "concise-iris-provenance",
      "metadata": {},
      "source": "## Dataset attribution and experiment state\n\nFisher, R. (1936). **Iris** [Dataset]. UCI Machine Learning Repository. [DOI: 10.24432/C56C76](https://doi.org/10.24432/C56C76). Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Original observations from `iris.data` are preserved; source class names map to IDs 0 to 2. UCI's documented alternative corrections are not applied. See `THIRD_PARTY_DATA.md` and `datasets/iris/README.md` supplied with the examples for retained notices, source variant, hashes, and transformation details.\n\nThis experiment selects a stratified training/test partition and fits feature standardization to training rows only. Reports retain the source hash, row IDs, and dataset attribution. The source above records the split seed; the dataset view does not retain that seed automatically. Keep the source together with results. A fixed seed does not promise bitwise equality across platforms.\n\nSaved outputs are historical content, not live variables or a model checkpoint. Restarting or reloading clears native state; **Run All** recreates it. Re running the fit cell trains a fresh snapshot from the same configuration. Live loss charts and a variable inspector are future work.\n"
    }
  ],
  "metadata": {
    "kernelspec": {
      "name": "aner",
      "display_name": "Aner",
      "language": "aner"
    },
    "language_info": {
      "name": "aner",
      "file_extension": ".aner",
      "mimetype": "text/x-aner"
    },
    "aner": {
      "status": "example",
      "execution_mode": "persistent-session"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}
