# Guardrails and pre-deployment checks
A 55-year-old woman walks into an emergency department with jaw pain and fatigue. The triage algorithm scores her as low acuity. She has a heart attack. Post-mortem review finds the model was trained mostly on male presentations of cardiac events, where chest pain dominates. This is not hypothetical: sex and race bias in clinical algorithms is documented, most famously in a 2019 *Science* study showing a widely used US care-management algorithm systematically underestimated the needs of Black patients (Obermeyer et al., 2019).
Guardrails are the difference between an algorithm that helps a clinician and one that quietly harms a subgroup. This lesson walks the concrete checklist a medtech team runs before releasing a triage algorithm.
A triage algorithm ranks or classifies patients by urgency to guide care decisions. Examples: sepsis early-warning scores in hospital EHRs (electronic health records), symptom-checker apps that route patients to ERERThe ratio of interactions (likes, comments, shares) to reach for a given piece of content, used to gauge how well audiences respond relative to how many people saw it.View full definition → versus telehealth, and radiology "worklist prioritization" tools that push suspected strokes to the top of a radiologist's queue.
Legally, most of these are medical devices. In the US they fall under the FDA (Food and Drug Administration), typically as SaMD (Software as a Medical Device). In Europe they are regulated under the MDR (Medical Device Regulation, EU 2017/745), and separately as high-risk AI under the EU AI Act, which entered into force in 2024 with obligations phasing in through 2026 and 2027.
That regulatory status sets the floor. Good guardrails go above it.
Run these gates in order. A failure at any gate blocks release.
Before anything else, prove the model works on the population that will actually use it.
Concrete threshold example: a stroke-triage tool might require sensitivity above a pre-registered floor (say 0.90) because a missed stroke is catastrophic, accepting more false positives as the trade.
Aggregate accuracy hides harm. Break performance down by subgroup and check the gaps.
Report metrics per group: age band, sex, race and ethnicity, insurance status, primary language. Look at both false negative rate (missed urgent cases) and false positive rate (unnecessary escalation) per group.
Here is a minimal audit in code:
import pandas as pd
def subgroup_report(df, group_col, y_true="label", y_pred="pred"):
rows = []
for g, sub in df.groupby(group_col):
fn = ((sub[y_true]==1) & (sub[y_pred]==0)).sum()
pos = (sub[y_true]==1).sum()
fnr = fn / pos if pos else float("nan")
rows.append({"group": g, "n": len(sub), "false_neg_rate": round(fnr,3)})
return pd.DataFrame(rows)
# flag any subgroup whose FNR exceeds the best group by > 5 pointsThe rule matters more than the code: define, before you look, what gap is unacceptable. A common approach is to require that no protected subgroup's false negative rate exceeds the best-performing group by more than a set margin. If it does, you retrain, reweight, or restrict the intended-use population, and you document why.
The EU AI Act requires this kind of data governancedata governanceData governance is the set of policies, roles, and processes that ensure data is accurate, secure, well-defined, and used responsibly across an organization.View full definition → and bias examination for high-risk systems. The FDA's Good Machine Learning Practice principles, issued jointly with UK and Canadian regulators, name representativeness of data as a core expectation.
"Human-in-the-loop" means a person reviews or approves the model's output before it affects care. The design question is *when*.
Set thresholds by risk, not convenience:
A trap here is automation bias: clinicians rubber-stamp the model because it is usually right. Counter it by showing the model's confidence, surfacing the top drivers of the score, and periodically injecting cases where the model is wrong to keep reviewers alert (used in some radiology QA programs).
Ask: what happens when the model is unavailable, uncertain, or fed garbage?
Write the fallback into the clinical workflow and *test it* by deliberately taking the model offline during a drill.
Regulators and your own risk team need a paper trail.
The EU AI Act mandates technical documentation and logging for high-risk systems. Treat it as a design requirement, not paperwork bolted on at the end.
Knowledge check
1. In the opening scenario, a woman's heart attack is missed because the triage algorithm scored her as low acuity. What is the underlying conceptual failure this illustrates?
2. Why does the lesson describe regulatory status (FDA SaMD, MDR, EU AI Act) as setting 'the floor' rather than the standard for good guardrails?
3. Why is retrospective validation on held-out historical data the model never saw during training a meaningful test of performance?
4. Select ALL correct answers. Which of the following would qualify as a 'triage algorithm' as defined in the lesson?
Select all the correct answers.
5. Select ALL correct answers. What does the pre-deployment checklist design imply about how the gates should be run?
Select all the correct answers.
Passing pre-deployment gates is necessary but not sufficient. Models decay.
Data drift is when the incoming patient population shifts away from the training data (a new variant, a new referral pattern, a merged hospital system). Performance drift is when accuracy degrades over time. Track both.
Practical setup: monitor input feature distributions weekly, and where outcomes are available (did the flagged patient actually deteriorate?), track false negative rate on a rolling window. Set an alert threshold. If the rolling FNR breaches it, the model auto-reverts to shadow mode and pages the responsible clinician-owner.
Every deployed model needs a named accountable owner, usually a clinician plus a data scientist. Under both FDA and EU frameworks, post-market surveillance is not optional. Someone has to watch the dashboards and have authority to pull the model.
Models get retrained. The FDA supports a Predetermined Change Control Plan (PCCP): you specify in advance what kinds of updates you may make (retraining on new data, threshold tweaks) and how you will validate them, so routine improvements do not require a fresh submission each time. Define your PCCP before launch.
Suppose a sepsis-warning tool is deployed across 20,000 ED visits per year, with a true sepsis rate of 2 percent, so 400 real cases. At 0.90 sensitivity the model catches 360 and misses 40. If a subgroup audit shows sensitivity for non-English-speaking patients is only 0.75, then within that subgroup the model misses one in four true cases. That gap, not the headline 0.90, is what your guardrail must catch. (Illustrative figures.)
*This lesson is educational and not legal, regulatory, or medical advice.*