This tutorial shows how to integrate RESON into Python workflows and scripts.
For a full class and method reference (Manifest, RESON, RESONRun, providers, reports), see docs/api.md.
from reson import RESON, RESONRun, Manifestmanifest = Manifest.load_from("tutorials/data/candidate.json")
print(manifest.summary)normalized = manifest.normalize(
fields=["text", "prediction"],
remove_punct=True,
lowercase=True,
replace_yo=True,
)To apply a substitution dictionary, pass an explicit CSV path:
normalized = manifest.normalize(
fields=["text", "prediction"],
remove_punct=True,
lowercase=True,
replace_yo=True,
subst_table="tutorials/data/subst_table/example.csv",
)reson = RESON(
name="candidate_model",
metrics=("WER", "CER"),
meta={"model_version": "candidate_v1"},
)
run = reson.analyze(normalized, artifacts_dir="artifacts/python_api/candidate")
run.to_json("artifacts/python_api/candidate.json")Inspect generated structures:
print(run.metrics)
print(run.summary)
print(run.vocab.data.head())
print(run.alphabet.data.head())Ready-made reports you can open in a browser before running this step: single, compare, leaderboard.
html_path = run.report(output_html="artifacts/python_api/candidate_report.html")
print(html_path)baseline_manifest = Manifest.load_from("tutorials/data/baseline.json")
baseline_run = RESON(name="baseline_model", metrics=("WER", "CER")).analyze(
baseline_manifest.normalize(["text", "prediction"]),
artifacts_dir="artifacts/python_api/baseline",
)
comparison = reson.compare(baseline=baseline_run, candidate=run)
print(comparison.metrics_delta_records())reson.compare_report(
runs=[run, baseline_run],
model_names=["candidate_model", "baseline_model"],
output_html="artifacts/python_api/compare_report.html",
base_model="baseline_model",
target_model="candidate_model",
num_bootstraps=2000,
alpha=0.05,
)restored = RESONRun.from_json("artifacts/python_api/candidate.json")
print(restored.name)
print(restored.metrics.head())- Keep one
RESONinstance per model configuration. - Store run metadata in
metato make reports self-descriptive. - Persist every important run as JSON (
RESONRun.to_json) for reproducible comparisons.