In shadow deployment (also called dark launching), a candidate model runs alongside the production model on identical inputs. Only the production model's predictions are served to users. The shadow model's outputs are logged for offline comparison.
Given prediction logs from both models and evaluation criteria, determine if the shadow model is ready to replace production.
P95 latency uses the nearest-rank method:
index=⌈0.95×n⌉−1Sort shadow latencies ascending and select the element at this index.
Agreement Rate=ninputs where both models predict the same valueThe shadow model is promoted only when all criteria are satisfied simultaneously:
accuracy_gain >= min_accuracy_gain
shadow_latency_p95 <= max_latency_p95
agreement_rate >= min_agreement_rate
Input:
production_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 15}, {"input_id": 2, "prediction": 0, "actual": 1, "latency_ms": 20}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 18}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 22}, ] shadow_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 10}, {"input_id": 2, "prediction": 1, "actual": 1, "latency_ms": 25}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 20}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 30}, ] criteria = {"min_accuracy_gain": 0.0, "max_latency_p95": 50.0, "min_agreement_rate": 0.5}
Output:
{"promote": True, "metrics": {"shadow_accuracy": 1.0, "production_accuracy": 0.75, "accuracy_gain": 0.25, "shadow_latency_p95": 30, "agreement_rate": 0.75}}
Shadow is more accurate (1.0 vs 0.75), P95 latency is 30ms (within 50ms limit), and agreement rate is 0.75 (above 0.5 threshold).
Input:
production_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 15}, {"input_id": 2, "prediction": 0, "actual": 1, "latency_ms": 20}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 18}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 22}, ] shadow_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 40}, {"input_id": 2, "prediction": 1, "actual": 1, "latency_ms": 45}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 50}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 200}, ] criteria = {"min_accuracy_gain": 0.0, "max_latency_p95": 100.0, "min_agreement_rate": 0.5}
Output:
{"promote": False, "metrics": {"shadow_accuracy": 1.0, "production_accuracy": 0.75, "accuracy_gain": 0.25, "shadow_latency_p95": 200, "agreement_rate": 0.75}}
Shadow is more accurate and has high agreement, but P95 latency is 200ms which exceeds the 100ms limit. Promotion blocked.
For P95 with nearest-rank, sort the latencies ascending and pick the element at index ceil(0.95 * n) - 1.
Agreement rate compares what the two models predicted, not whether they were correct.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: any
In shadow deployment (also called dark launching), a candidate model runs alongside the production model on identical inputs. Only the production model's predictions are served to users. The shadow model's outputs are logged for offline comparison.
Given prediction logs from both models and evaluation criteria, determine if the shadow model is ready to replace production.
P95 latency uses the nearest-rank method:
index=⌈0.95×n⌉−1Sort shadow latencies ascending and select the element at this index.
Agreement Rate=ninputs where both models predict the same valueThe shadow model is promoted only when all criteria are satisfied simultaneously:
accuracy_gain >= min_accuracy_gain
shadow_latency_p95 <= max_latency_p95
agreement_rate >= min_agreement_rate
Input:
production_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 15}, {"input_id": 2, "prediction": 0, "actual": 1, "latency_ms": 20}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 18}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 22}, ] shadow_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 10}, {"input_id": 2, "prediction": 1, "actual": 1, "latency_ms": 25}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 20}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 30}, ] criteria = {"min_accuracy_gain": 0.0, "max_latency_p95": 50.0, "min_agreement_rate": 0.5}
Output:
{"promote": True, "metrics": {"shadow_accuracy": 1.0, "production_accuracy": 0.75, "accuracy_gain": 0.25, "shadow_latency_p95": 30, "agreement_rate": 0.75}}
Shadow is more accurate (1.0 vs 0.75), P95 latency is 30ms (within 50ms limit), and agreement rate is 0.75 (above 0.5 threshold).
Input:
production_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 15}, {"input_id": 2, "prediction": 0, "actual": 1, "latency_ms": 20}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 18}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 22}, ] shadow_log = [ {"input_id": 1, "prediction": 1, "actual": 1, "latency_ms": 40}, {"input_id": 2, "prediction": 1, "actual": 1, "latency_ms": 45}, {"input_id": 3, "prediction": 1, "actual": 1, "latency_ms": 50}, {"input_id": 4, "prediction": 0, "actual": 0, "latency_ms": 200}, ] criteria = {"min_accuracy_gain": 0.0, "max_latency_p95": 100.0, "min_agreement_rate": 0.5}
Output:
{"promote": False, "metrics": {"shadow_accuracy": 1.0, "production_accuracy": 0.75, "accuracy_gain": 0.25, "shadow_latency_p95": 200, "agreement_rate": 0.75}}
Shadow is more accurate and has high agreement, but P95 latency is 200ms which exceeds the 100ms limit. Promotion blocked.
For P95 with nearest-rank, sort the latencies ascending and pick the element at index ceil(0.95 * n) - 1.
Agreement rate compares what the two models predicted, not whether they were correct.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Accepts: any