An outlier is unusual relative to a comparison group; it may be a measurement error, a valid rare case or a process change.
Outlier investigation: impossible values, rare events and quarantines
Compare like with like
A delivery time of 930 minutes is extreme for same-day urban orders and ordinary for a remote route with overnight handoff. Define the route, service promise and clock boundary before choosing a threshold. Use distribution displays and resistant summaries to locate candidates. A distribution view exposes heavy tails and subgroup mixtures better than one global cutoff.
Distinguish invalidity from rarity
An arrival time earlier than dispatch violates chronology and should be quarantined pending correction. A late but chronologically valid delivery may be operationally important, especially when a customer asks why it occurred. Do not delete it merely because it shifts the mean. Record status as valid, invalid, unresolved or excluded-by-policy, with evidence and rule version for each decision.
Measure policy effects
Compute a summary with all valid records and a second summary under any declared exclusion rule. Report how many records moved, which routes they belong to and how the decision changes. If a threshold is tuned after seeing the target metric, the cleaned estimate is selected to look favorable. Resistant statistics can describe the middle without erasing tail events.
Test a disputed case
Create 47 shipments: 45 ordinary arrivals, one valid overnight delay and one negative duration from an event-order bug. Quarantine only the negative duration. Keep the overnight delay in the valid set and in a tail-case investigation queue. If the KPI excludes it under a service rule, publish both the rule and the count of excluded valid records.
Implementation
def triage_delivery(record, review_threshold_minutes=480):
arrival = record["arrival_minute"]
dispatch = record["dispatch_minute"]
if arrival is None:
return "unresolved"
duration = arrival - dispatch
if duration < 0:
return "invalid"
if duration > review_threshold_minutes:
return "investigate"
return "valid"Performance and operating cost
The rule is O(1) per record and O(N) for N records. Investigations have human cost that grows with the flagged queue; threshold choice should account for that capacity and the harm of missed cases.
Common Mistakes
- Do not equate a high anomaly score with an invalid record.
- Do not tune an exclusion threshold to improve a published KPI.
- Do not lose a valid rare case from incident analysis.
Read next
- Column profiles and domain constraints before analysis
- Resistant summaries: median, trimmed mean and median absolute deviation
- Subgroup distributions and aggregation reversal
- Distribution plots: keep the tail, missing values and bin policy visible
Continue the workflow: Calibration drift: compare sensor readings with a reference.
