All examples
Machine learning

Call an approved energy prediction through MCP

Connect an external notebook to the native prediction for an approved observation.

agent_energy_mcp.aner
// The notebook launches this script with its own standard streams.
// The scientist first inspects and approves the private energy-401.run in a separate Aner process.
import aner.agent
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 run = agent.open_run("energy-401.run")
// Record scoped prediction responses so the scientist can export them for offline review.
agent.serve_mcp(run, fit, scaler, split.validation(), true)

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_mcp.aner inside a folder for your experiment. Check the source from that directory. The notebook starts the server on its own standard streams.

Terminal
aner check examples/agent_energy_mcp.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. Save the CSV as examples/fixtures/contextual/energy.csv. Approve energy 401.run in the project root. The notebook launches the service with telemetry enabled.

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