Building an Ontology Schema for a Small Supply Network
说明与用途
为一个小型供应网络构建了单一的 YAML 本体架构,确保了诸如准时率、装载率、停留时间和延误时间等指标的一致性,并输出了 57.1% 的准时率和车道级洞察。
问题
Different notebooks defined the same operational word inconsistently, leading to conflicting metrics such as on‑time rates.
结果
The ontology schema enforces consistent metric definitions, preventing duplicate or misspelled columns, and produces a 57.1% on‑time rate with clear lane‑level insights.
工作流
- Define the question and cutoff (on‑time < 50%)
- Choose fact grain (Shipment) and dimensions (Node, Lane, Carrier, Sku)
- Define properties (actual_hours, planned_hours, etc.) and metrics (OnTime, FillPercent, DwellHours, LateHours)
- Write YAML schema in schema/inland_network.yaml
- Load schema with PyYAML and validate with ontology.py
- Bind data from data/network.json with bind.py
- Score shipments with metrics.py using rules from ontology
- Generate brief table via main.py and FastAPI endpoint
- Run tests with pytest to ensure correctness
证据
I wanted one place that says what a shipment is, which lane it used, and what "on time" means, before any table or brief was allowed to invent a second meaning.
LaneSchema is that place, as a personal experiment on a laptop.
The ontology lives in schema/inland_network.yaml.
The fact grain is Shipment. The dimensions are Node, Lane, Carrier, and Sku.
A metric that points at a property the grain does not have dies in load_ontology with a SchemaError.
python main.py prints that table. FastAPI serves the same build_report function.
- 记录日期: 2026-10-16T03:41:25.792Z