compute
Compute a county-wide geofence crash rate, aggregated over S2 cells.
python
HumanBaselines.compute(
selections: GeofenceSelections | dict | None = None,
*,
county: str | None = None,
**filters,
) -> ComputeResultPass filters as keyword args, a GeofenceSelections model, or a dict; see filters three ways. You can't pass both selections and kwargs. Omitted filters use the API defaults; a bound config is inherited and overridden per call.
Example
python
from humanbaselines import HumanBaselines
hb = HumanBaselines()
r = hb.compute(
county="travis",
outcome="police_reported",
severity=1,
ego_vehicle=["cars", "light_trucks"],
road_type=["arterial", "collector_local"],
weather="any",
crash_year=[2022],
)
print(r.rate, r.rate_low, r.rate_high)Returns: ComputeResult
| Field | Type | Description |
|---|---|---|
N | float | Weighted crash count (numerator). |
D_miles | float | Calibrated VMT (denominator). |
D_billions | float | D_miles in billions. |
rate | float | Incidents per million miles. |
rate_low / rate_high | float | None | 95% CI bounds. |
rate_non_dyn | float | Plain Σ/Σ rate (always present). |
rate_dyn | float | None | Operator-weighted rate, or None if not applicable. |
multiplier | float | None | Chen 2024 spatial multiplier, or None. |
cells | list[PerCellResult] | Per-S2-cell {s2_cell, count, vmt, mult_contrib}. |
python
print(r.N, r.D_billions)
for c in r.cells[:3]:
print(c.s2_cell, c.count, c.vmt)See Methodology for how the rate and CI are derived, and Errors for failure handling.