All examples
Machine learning

Review a building energy prediction

Ask a local language model to propose row 401 and let a scientist review, pause and resume the fitted energy prediction after restarting Aner.

agent_energy.aner
// Run once in a project containing the synthetic fixture. Use a fresh run path.
// The script leaves observation 401 awaiting the scientist's decision.
import aner.agent
import aner.llm
import aner.data
import aner.ml
import aner.tensor

let schema = data.schema()
    .column("row_id", "Int64", false)
    .column("building_id", "String", false)
    .column("temperature", "Float64", false)
    .column("occupancy", "Float64", false)
    .column("energy", "Float64", false)
let table = data.scan_csv("examples/fixtures/contextual/energy.csv", schema, "NA").collect(16, 1048576, 4)
let frame = data.frame(table, "row_id", "building_id", "energy", List("", "", "degC", "1", "kWh"))
let split = frame.partition_groups(List("B0", "B1", "B2", "B3"), List("B4", "B5"), List("B6", "B7"))
let scaler = ml.fit_standardizer(split.train())
let fit = ml.fit_linear(scaler.transform(split.train()).batch(1048576))
let local = llm.client(provider: "ollama", model: "qwen2.5:14b-instruct", endpoint: "http://127.0.0.1:11434")
let proposal = llm.prediction_turn(local, "Predict energy for validation observation 401.")
let run = agent.start_run("energy-401.run", proposal, 401, fit, scaler, split.validation())
print(proposal.model())
print(proposal.text())
print(run.row_id())
print(run.state())

Run step by step in VS Code.

The notebook separates loading, splitting, model configuration, training, and evaluation into cells. It opens with empty outputs, shared variables, and Development inspection enabled.

  1. Install a compatible native Aner executable and VS Code extension using the editor guide. These datasets and fitted classifier pipelines require the Aner 0.0.3 or newer runtime.
  2. Download the .anernb notebook and open it in your VS Code project. If it appears as JSON, choose Reopen Editor With… → Aner Notebook.
  3. Select the Aner — notebook kernel and keep Shared variables active. Run code cells from top to bottom, or choose Run All. Later cells reuse the datasets, network, and fitted model from earlier cells.
  4. Read the results below each cell. Open Inspector to inspect native variables. Use Aner: Open Development Training Report to inspect the recorded loss, topology, and available gradients after the fitting cell completes.

After changing an earlier cell, rerun its dependent cells. Use Aner: Restart Notebook Session, then Run All, for a clean experiment. Saved outputs are historical; reopening the file starts without live variables. The notebook guide explains session state, inspection, and runtime controls.

Make it your experiment.

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

Terminal
aner check examples/agent_energy.aner
aner run examples/agent_energy.aner

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

Use Aner 0.1.2 on macOS or Linux and a running local Ollama service for the initial proposal. Use the installed model named in the example. The scientist notebook can reopen the saved run with Ollama offline. Save the CSV as examples/fixtures/contextual/energy.csv and run from the project root.

Credential setup
ollama show qwen2.5:14b-instruct
aner run examples/agent_energy.aner --prod

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