Skip to content

Models & types ​

All request and response types are Pydantic models exported from the package top level:

python
from humanbaselines import (
    GeofenceSelections, RouteSelections, DepotSelections, DepotPin,
    ComputeResult, PerCellResult, BatchComputeResult, BatchItemResult,
    RouteComputeResult, PerSegmentResult,
    DepotComputeResult, FiltersResponse, FilterDef, FilterOption,
    RegionsResponse, RegionInfo,
)

Generated from the API

These types are generated from the server's OpenAPI schema. The server's Pydantic models are the single source of truth, so the client cannot drift from the API. filters() is the authoritative runtime source for valid values and defaults.

Request models (selections) ​

One per mode. Pass an instance via selections=, or use keyword args. All use extra="forbid", so an unknown field raises locally before any request.

ModelUsed byNotable fields
GeofenceSelectionscomputeoutcome, severity, ego_vehicle, road_type, weather, light_condition, crash_year, desk_reports, denominator_vmt, operator_weighting, operator_weight, …
RouteSelectionscompute_routeoutcome, ego_vehicle (defaults ["combination"]), weather, driver_impairment, ci_method, …
DepotSelectionscompute_depot_routesame shape as RouteSelections
DepotPincompute_depot_routelat, lon
python
from humanbaselines import GeofenceSelections, Outcome
sel = GeofenceSelections(outcome=Outcome.fatal, road_type=["interstate"])
hb.compute(selections=sel)

Response models ​

ModelReturned byKey fields
ComputeResultcomputeN, D_miles, D_billions, rate, rate_low/high, rate_non_dyn, rate_dyn, multiplier, cells (empty when summary_only)
PerCellResultComputeResult.cellss2_cell, count, vmt, mult_contrib
BatchComputeResultcompute_batchresults: list[BatchItemResult] (same order as requested regions)
BatchItemResultBatchComputeResult.resultsregion, result (ComputeResult | None), error (str | None)
RouteComputeResultcompute_routeN, trip_miles, rate, rate_low/high, variance, segments
PerSegmentResultRouteComputeResult.segmentsroute, milepost, count, vmt, length_mi
DepotComputeResultcompute_depot_routeaccess_a, interstate, access_b, total, depot_a/b, vertices (permissive)
FiltersResponsefiltersmodes: dict[str, list[FilterDef]]
RegionsResponseregionsregions: list[RegionInfo], default_region

Enums ​

String enums for filter values. They accept the enum member or its string value interchangeably:

Outcome, VehicleClass, RoadGroup, SpeedBand, Tier3Mode, InTransport, OperatorWeighting, MultiplierVmt, UnderReporting, WeatherFilter, LightFilter, DriverImpairment, CiMethod.

python
from humanbaselines import Outcome
hb.compute(outcome=Outcome.fatal)   # same as outcome="fatal"

The newest filters (desk_reports, day_type, time_of_day) have no exported enum yet, so pass their values as strings.

posted_speed_max is not a wire field. The client turns the cap into the posted_speed band list with speed_bands_up_to(), which is also exported:

python
from humanbaselines import speed_bands_up_to
speed_bands_up_to(45)   # ['le15', 's20', 's25', 's30', 's35', 's40', 's45']

The live option lists and per-mode defaults are on the Discovery page.

Derived statistics only. Attribute every published figure. Maintained by Valgo.