← Back to the chapter · Previous detail
Technical detail · Edge AI Fundamentals: Why and When
A guarded inference path
The application should keep inference and safety policy separate. This makes it easier to update thresholds, evidence collection, and fallback behavior without hiding model uncertainty.
def evaluate_edge_sample(sample, model, policy, device):
features = device.preprocess(sample)
result = model.predict(features)
event = {
"model_version": model.version,
"label": result.label,
"confidence": result.confidence,
"device_id": device.id,
}
if not device.sensor_is_healthy():
device.store_evidence(sample, reason="sensor_fault")
return device.safe_fallback("sensor_fault", event)
if result.confidence < policy.minimum_confidence:
device.store_evidence(sample, reason="low_confidence")
return device.safe_fallback("needs_review", event)
if result.label in policy.local_action_labels:
device.act(result.label)
device.report_event(event)
return event
The important design choice is not the exact Python API. It is the structure: consistent preprocessing, model version reporting, health checks, uncertainty handling, compact event reporting, and explicit fallback behavior.