Building occupancy
occupancy.py loads the UCI Occupancy Detection training split with Polars, a dataframe library for Python. It defines rolling sensor baselines, anomaly candidates, a transparent occupancy score, and a threshold sweep.
Compare the views
Building occupancy
A reactive scope updates one room-sensor model across a live monitor, model review, and A4 field report.
In Monitor, choose an observation scope and signal. The controls resolve 12 prepared combinations while ECharts renders the trend, baseline, anomalies, and current summary together.
In Model review, choose one of three prepared scopes and move the threshold across 17 notebook-computed operating points. Threshold changes update accuracy, precision, recall, the curve marker, confusion counts, and error evidence in the browser. Recharts renders the threshold curve as a React component.
In PDF report, choose one of the three prepared scopes. The React view composes the notebook-owned room profile and model evidence into an A4 report, then generates the downloadable PDF in the browser.
Open Notebook to inspect the rolling calculations, room profiles, and threshold evaluation that all three views present.
Run locally
From the repository root:
uv run marimo edit examples/occupancy.py --sandboxOpen Studio from the marimo editor, then switch among monitor, model-review, and pdf-report. The notebook fetches the pinned occupancy CSV from raw.githubusercontent.com. The Browser runtime also needs Pyodide, the Python distribution that runs in the browser, and its Python packages on an uncached run.
Read the source
All three views keep statistical definitions in the notebook. Their component code formats and presents those results for separate decisions.