Cyber Anomaly Detection & Dependency Risk: detection, baselines, robustness across seeds, base rates, attribution, and drift

All results on this page come from the simulated test set: 8,064 normal windows from 2 unseen hosts, plus 3,120 attack windows. Alerts use the held-out EVT thresholds from the Thresholds page: \(\tau_{0.99} = 1.854\) and \(\tau_{0.999} = 3.559\). Single-run figures use the main seed (42). The robustness section repeats the whole pipeline over 30 seeds.

Reconstruction loss by attack and intensity

It shows how far each kind of attack pushes the loss above normal traffic, and whether it clears the alert line.

Display code
normals <- test |> filter(!is_att) |> select(attack_type, recon_loss)
plot_df <- bind_rows(
  map(tier_levels, \(t) mutate(normals, tier = t)) |> bind_rows(),
  test |> filter(is_att) |> mutate(tier = as.character(tier)) |> select(attack_type, recon_loss, tier)
) |>
  mutate(tier = factor(str_to_title(tier), levels = c("Low", "Medium", "High")),
         attack_type = fct_rev(factor(attack_type, levels = names(attack_colors))))
ggplot(plot_df, aes(recon_loss, attack_type, fill = attack_type)) +
  geom_boxplot(outlier.size = 0.6, outlier.alpha = 0.4, width = 0.6, colour = "#52514e") +
  geom_vline(xintercept = tau[["q0.999"]], linetype = "dashed", colour = "#0b0b0b") +
  geom_vline(xintercept = tau[["q0.99"]], linetype = "dotted", colour = "#52514e") +
  scale_x_log10(breaks = c(0.1, 1, 10), labels = c("0.1", "1", "10")) +
  scale_fill_manual(values = attack_colors, guide = "none") +
  facet_wrap(~tier, nrow = 1) +
  labs(title = "Reconstruction Loss by Attack Type and Intensity Tier",
       subtitle = "Log scale; dashed = 99.9% threshold, dotted = 99% threshold; normal windows repeated in each panel",
       x = "Reconstruction loss (log scale)", y = NULL)
Figure 1

How to read the plot. Each panel is one attack intensity tier. Each box shows the spread of reconstruction loss for one attack type: the middle line is the median, the box spans the middle half of windows, and the dots are unusual values. Grey is normal traffic, repeated in every panel. The horizontal axis is logarithmic. Anything to the right of the dashed line triggers an alert at the 99.9% threshold, and the dotted line is the 99% threshold.

What the plot tells you. Normal windows have a median loss of 0.506 and a 99th percentile of 1.728. Low-intensity attacks look exactly like normal traffic. At high intensity, credential stuffing, privilege escalation, ransomware staging and lateral movement clear the alert line. Exfiltration does not, even at the high tier, because large changes to a few features are diluted in a 19-feature average. Low-and-slow exfiltration sits wholly inside the normal range.

Detection scorecard

This is the operational answer: what share of each attack the detector catches, and how often it raises false alarms, with uncertainty attached.

Display code
score <- test |>
  summarise(n = n(), x990 = sum(flag_990), x999 = sum(flag_999), .by = c(label, attack_type, tier)) |>
  mutate(
    kind = if_else(label == "Normal", "False-alarm rate (normal)", "Detection rate (attacks)"),
    tier = if_else(is.na(tier), "–", str_to_title(as.character(tier))),
    r990 = x990 / n, r999 = x999 / n,
    ci = map2(x999, n, wilson)
  ) |>
  unnest_wider(ci) |>
  arrange(kind == "Detection rate (attacks)", attack_type, factor(tier, levels = c("–", "Low", "Medium", "High"))) |>
  select(kind, attack_type, tier, n, r990, r999, lower, upper)
score |>
  gt(groupname_col = "kind") |>
  tab_header(title = "Detection Scorecard by Attack Type and Intensity",
             subtitle = "Main seed; 95% Wilson interval for the 99.9% rate") |>
  cols_label(attack_type = "Class", tier = "Intensity", n = "Windows", r990 = "Rate at 99.0%",
             r999 = "Rate at 99.9%", lower = "95% CI low", upper = "95% CI high") |>
  fmt_percent(c(r990, r999, lower, upper), decimals = 1) |>
  fmt_integer(n) |>
  data_color(columns = c(r990, r999), rows = kind == "Detection rate (attacks)",
             palette = c("#f0efec", "#7fc8a9", "#008300"), domain = c(0, 1)) |>
  data_color(columns = c(r990, r999), rows = kind == "False-alarm rate (normal)",
             palette = c("#008300", "#f0efec"), domain = c(0, 0.02)) |>
  tab_options(table.font.size = 12, row_group.font.weight = "bold")
Table 1
Detection Scorecard by Attack Type and Intensity
Main seed; 95% Wilson interval for the 99.9% rate
Class Intensity Windows Rate at 99.0% Rate at 99.9% 95% CI low 95% CI high
False-alarm rate (normal)
Normal (benign) – 8,064 0.8% 0.2% 0.1% 0.3%
Detection rate (attacks)
Data Exfiltration Low 150 0.0% 0.0% 0.0% 2.5%
Data Exfiltration Medium 150 4.7% 0.7% 0.1% 3.7%
Data Exfiltration High 150 13.3% 0.7% 0.1% 3.7%
Low-and-Slow Exfiltration Low 870 0.6% 0.1% 0.0% 0.6%
Credential Stuffing Low 150 2.0% 0.0% 0.0% 2.5%
Credential Stuffing Medium 150 16.0% 0.0% 0.0% 2.5%
Credential Stuffing High 150 100.0% 100.0% 97.5% 100.0%
Privilege Escalation Low 150 2.7% 0.0% 0.0% 2.5%
Privilege Escalation Medium 150 66.0% 4.7% 2.3% 9.3%
Privilege Escalation High 150 100.0% 100.0% 97.5% 100.0%
Ransomware Staging Low 150 6.7% 0.0% 0.0% 2.5%
Ransomware Staging Medium 150 100.0% 93.3% 88.2% 96.3%
Ransomware Staging High 150 100.0% 100.0% 97.5% 100.0%
Lateral Movement Low 150 5.3% 2.0% 0.7% 5.7%
Lateral Movement Medium 150 21.3% 2.0% 0.7% 5.7%
Lateral Movement High 150 100.0% 100.0% 97.5% 100.0%

How to read the table. The top block shows how often normal windows were wrongly flagged, where lower is better. The bottom block shows the share of each attack caught, by type and intensity, where higher is better. Greener cells are better in both blocks. The two rate columns use the 99% and 99.9% thresholds. The interval columns give the plausible range for the 99.9% rate, given how many windows were tested.

What the table tells you. At 99.9%, high-intensity credential stuffing, privilege escalation, ransomware staging and lateral movement are caught almost every time. At medium intensity only ransomware staging is caught reliably, and low-intensity attacks are essentially never caught. Exfiltration is missed at every tier. Only 1 of 30 low-and-slow campaigns raised any alert, while normal stretches of the same length raise one 4.6% of the time: no better than chance.

Detection frontiers

The curves show detection against false alarms at every possible threshold, for the autoencoder and for simpler alternatives.

Display code
truth <- factor(if_else(is_att, "Anomaly", "Normal"), levels = c("Anomaly", "Normal"))
curves <- imap(main$scores_test, \(s, m) {
  df <- tibble(truth = truth, score = s)
  list(
    roc = yardstick::roc_curve(df, truth, score, event_level = "first") |> mutate(method = m),
    pr = yardstick::pr_curve(df, truth, score, event_level = "first") |> mutate(method = m)
  )
})
method_colors <- setNames(c("#2a78d6", "#eb6834", "#1baf7a", "#eda100", "#e87ba4", "#008300"), names(main$scores_test))
p_roc <- map(curves, "roc") |> bind_rows() |>
  ggplot(aes(1 - specificity, sensitivity, colour = method)) +
  geom_abline(linetype = "dashed", colour = "#c3c2b7") +
  geom_line(linewidth = 0.8) +
  scale_colour_manual(values = method_colors, name = NULL) +
  labs(title = "ROC Frontier", x = "False-positive rate", y = "True-positive rate")
p_pr <- map(curves, "pr") |> bind_rows() |>
  ggplot(aes(recall, precision, colour = method)) +
  geom_hline(yintercept = mean(is_att), linetype = "dashed", colour = "#c3c2b7") +
  geom_line(linewidth = 0.8) +
  scale_colour_manual(values = method_colors, name = NULL) +
  labs(title = "Precision-Recall Frontier", x = "Recall", y = "Precision")
(p_roc + p_pr) + plot_layout(guides = "collect") & theme(legend.position = "bottom")
Figure 2

How to read the plots. Left: the share of attacks caught against the share of normal windows wrongly flagged, as the threshold slides from strict to loose. Curves nearer the top-left are better, and the dashed diagonal is random guessing. Right: the share of alerts that are real (precision) against the share of attacks caught (recall). The dashed line marks the attack share in this test set, 27.9%, far above any real environment.

What the plots tell you. All six methods trace almost the same curves. The autoencoder’s ROC AUC is 0.792, and the best method on this run is Mahalanobis distance at 0.819. Every ROC curve rises steeply and then flattens, because low-intensity attacks look like normal traffic to every method. Precision looks respectable only because attacks make up 27.9% of this test set. The base-rate table below shows realistic prevalence.

Baselines

A neural network is only worth its complexity if it beats simple statistics on the same data.

Display code
auc_seeds <- rob |>
  filter(group == "ROC AUC by method") |>
  transmute(method = metric, auc_seeds = sprintf("%.3f [%.3f–%.3f]", mean, lo, hi))
mm |>
  left_join(auc_seeds, by = join_by(method)) |>
  select(method, roc_auc, auc_seeds, pr_auc, false_alarm_rate, det_low, det_medium, det_high, det_low_slow) |>
  gt() |>
  tab_header(title = "Autoencoder vs Baseline Detectors",
             subtitle = "Each method thresholded at its own 99.9% held-out quantile (0.1% nominal false-positive rate)") |>
  cols_label(method = "Method", roc_auc = "ROC AUC", auc_seeds = sprintf("ROC AUC, %d seeds", n_seeds),
             pr_auc = "PR AUC", false_alarm_rate = "False-alarm rate", det_low = "Low", det_medium = "Medium",
             det_high = "High", det_low_slow = "Low-and-slow") |>
  tab_spanner("Main seed", c(roc_auc, pr_auc, false_alarm_rate)) |>
  tab_spanner("Detection at 0.1% FPR by tier", c(det_low, det_medium, det_high, det_low_slow)) |>
  fmt_number(c(roc_auc, pr_auc), decimals = 3) |>
  fmt_percent(c(false_alarm_rate, det_low, det_medium, det_high, det_low_slow), decimals = 1) |>
  tab_options(table.font.size = 12)
Table 2
Autoencoder vs Baseline Detectors
Each method thresholded at its own 99.9% held-out quantile (0.1% nominal false-positive rate)
Method
Main seed
ROC AUC, 30 seeds
Detection at 0.1% FPR by tier
ROC AUC PR AUC False-alarm rate Low Medium High Low-and-slow
Autoencoder (shallow, k = 4) 0.792 0.704 0.1% 0.794 [0.734–0.824] 0.3% 18.3% 80.0% 0.1%
Sum of squared z-scores 0.800 0.727 0.1% 0.798 [0.749–0.824] 0.3% 20.7% 80.4% 0.1%
Max |z| 0.800 0.719 0.0% 0.799 [0.748–0.823] 0.0% 12.9% 80.1% 0.1%
PCA reconstruction (k = 4) 0.790 0.698 0.1% 0.791 [0.732–0.818] 0.3% 18.0% 60.5% 0.1%
Mahalanobis distance 0.819 0.752 0.1% 0.817 [0.765–0.843] 0.4% 21.7% 80.3% 0.1%
Isolation Forest 0.802 0.708 0.2% 0.802 [0.738–0.832] 1.7% 13.9% 28.8% 0.1%

How to read the table. Each row is a detector applied to the same data. The two z-score methods measure how far a window sits from average, feature by feature. PCA is the linear equivalent of the autoencoder. Mahalanobis distance measures distance from average while allowing for correlations. Isolation Forest is a standard tree-based detector. Every method gets the same 0.1% false-alarm budget, so the detection columns compare like with like.

What the table tells you. The autoencoder does not beat the simple baselines. Mahalanobis distance has the highest ROC AUC on this run and across seeds (0.817 [0.765–0.843] against 0.794 [0.734–0.824] for the autoencoder) and catches more medium-intensity attacks. When normal data are correlated and roughly bell-shaped, a classical covariance model is hard to beat, and the autoencoder is in effect a learned approximation of one.

Robustness across seeds

Any single run is one random draw. This table repeats the full pipeline (new data, new training, new EVT fit) 30 times.

Display code
rob |>
  filter(group %in% c("Model", "Detection at 99.9% by intensity", "Detection at 99.9% by attack")) |>
  mutate(
    is_pct = group != "Model" | str_detect(metric, "campaign"),
    across(c(mean, lo, hi), \(x) if_else(is_pct, f_pct(x), if_else(str_detect(metric, "False alarms|epoch"), f_num(x, 1), f_num(x, 3)))),
    metric = if_else(group == "Detection at 99.9% by intensity", paste(str_to_title(metric), "tier"), metric),
    group = recode(group, Model = "Model, threshold and false alarms")
  ) |>
  select(group, metric, mean, lo, hi) |>
  gt(groupname_col = "group") |>
  tab_header(title = sprintf("Pipeline Results across %d Seeds", n_seeds),
             subtitle = sprintf("False alarms are counts out of about %s normal test windows (expected about %.0f at 99.9%%)",
                                f_int(n_normal_test), n_normal_test * 0.001)) |>
  cols_label(metric = "Quantity", mean = "Mean", lo = "2.5%", hi = "97.5%") |>
  tab_options(table.font.size = 12, row_group.font.weight = "bold")
Table 3
Pipeline Results across 30 Seeds
False alarms are counts out of about 8,064 normal test windows (expected about 8 at 99.9%)
Quantity Mean 2.5% 97.5%
Model, threshold and false alarms
Training MSE (best epoch) 0.6 0.6 0.6
Validation MSE (best epoch) 0.6 0.5 0.7
Best epoch 49.0 33.0 59.3
ROC AUC (all attacks) 0.794 0.734 0.824
GPD shape xi 0.237 0.097 0.379
GPD scale sigma 0.283 0.179 0.496
tau 0.99 1.838 1.405 2.466
tau 0.999 3.134 2.038 4.376
False alarms at 99.0% 75.1 9.7 204.9
False alarms at 99.9% 14.1 1.5 52.2
Low-and-slow campaigns detected 4.6% 0.0% 15.2%
Null campaign alert rate 5.0% 0.4% 17.1%
Detection at 99.9% by attack
Data Exfiltration 0.9% 0.0% 3.9%
Credential Stuffing 28.3% 6.6% 36.3%
Privilege Escalation 39.0% 34.6% 49.0%
Ransomware Staging 65.2% 60.2% 67.6%
Lateral Movement 37.2% 34.4% 46.3%
Low-and-Slow Exfiltration 0.2% 0.0% 0.5%
Detection at 99.9% by intensity
Low tier 0.8% 0.2% 2.1%
Medium tier 24.6% 19.1% 34.3%
High tier 77.0% 63.8% 82.0%

How to read the table. Each row summarises one result across 30 independent repeats of the whole analysis, each with fresh simulated data, a newly trained model and a newly fitted threshold. “Mean” is the average, and the 2.5% and 97.5% columns bracket the middle 95% of repeats. False alarms are counts out of about 8,064 normal windows. Detection rates are the shares of attack windows that raised an alert.

What the table tells you. False alarms at 99.9% averaged 14.1 against about 8 expected and ranged from 1 to 52. Zero false alarms occurred in only 3% of repeats, so the original single-run claim of none was luck. The tail shape ranged from 0.10 to 0.38 and the 99.9% threshold from 2.04 to 4.38, so any single threshold is one draw from a wide range. Detection by intensity is stable: about 0.8% at low, 24.6% at medium and 77.0% at high intensity.

Base rates: what an analyst would see

Attacks make up 27.9% of the test set. In production they are far rarer, and that changes what an alert means.

Display code
vol <- cfg$operations$windows_per_day
win_att <- is_att & test$attack_type != "Low-and-Slow Exfiltration"
rates <- tibble(
  q = c(0.99, 0.999),
  fpr = c(mean(test$flag_990[!is_att]), mean(test$flag_999[!is_att])),
  tpr = c(mean(test$flag_990[win_att]), mean(test$flag_999[win_att]))
)
tidyr::expand_grid(rates, prevalence = unlist(cfg$operations$prevalence)) |>
  mutate(
    fp_day = fpr * vol * (1 - prevalence),
    tp_day = tpr * vol * prevalence,
    precision = tp_day / (tp_day + fp_day),
    q = paste0(formatC(100 * q, format = "f", digits = 1), "% threshold")
  ) |>
  select(q, prevalence, fpr, tpr, fp_day, tp_day, precision) |>
  gt(groupname_col = "q") |>
  tab_header(title = "Alerts per Day and Precision at Realistic Prevalence",
             subtitle = sprintf("Assumed %s scored windows per day; rates observed on the main-seed test set", f_int(vol))) |>
  cols_label(prevalence = "Attack prevalence", fpr = "False-alarm rate", tpr = "Detection rate",
             fp_day = "False alarms / day", tp_day = "True alerts / day", precision = "Precision") |>
  fmt_scientific(prevalence, decimals = 0) |>
  fmt_percent(c(fpr, tpr), decimals = 2) |>
  fmt_number(c(fp_day, tp_day), decimals = 0) |>
  fmt_percent(precision, decimals = 1) |>
  tab_options(table.font.size = 12, row_group.font.weight = "bold")
Table 4
Alerts per Day and Precision at Realistic Prevalence
Assumed 1,000,000 scored windows per day; rates observed on the main-seed test set
Attack prevalence False-alarm rate Detection rate False alarms / day True alerts / day Precision
99.0% threshold
1 × 10−5 0.76% 42.53% 7,564 4 0.1%
1 × 10−4 0.76% 42.53% 7,564 43 0.6%
1 × 10−3 0.76% 42.53% 7,557 425 5.3%
99.9% threshold
1 × 10−5 0.20% 33.56% 1,984 3 0.2%
1 × 10−4 0.20% 33.56% 1,984 34 1.7%
1 × 10−3 0.20% 33.56% 1,982 336 14.5%

How to read the table. Each row assumes a share of windows that are truly malicious, the prevalence (1e-4 means 1 in 10,000), and a volume of 1,000,000 windows a day. False and true alerts per day follow from the false-alarm and detection rates observed in testing. Precision is the share of alerts that are real attacks. The upper block uses the 99% threshold and the lower block the stricter 99.9% threshold.

What the table tells you. At one attack per 100,000 windows, even the 99.9% threshold produces about 1,984 false alarms a day, and fewer than 1% of alerts are real. The near-ideal precision in the original report came entirely from a test set that was 27.9% attacks. Deeper thresholds, which only the fitted tail can supply, and corroboration from other signals are both needed before these alerts could drive action.

Root-cause attribution

An alert is only actionable if the analyst can see which telemetry caused it.

Display code
set.seed(cfg$seeds$main)
resid <- main$residuals
colnames(resid) <- feature_cols
sample_rows <- test |>
  mutate(row_id = row_number()) |>
  filter(is_att, flag_999) |>
  slice_sample(n = 6, by = attack_type) |>
  arrange(attack_type, tier) |>
  mutate(incident = paste0(attack_type, " (", tier, ") #", row_number()), .by = attack_type)
as_tibble(resid[sample_rows$row_id, , drop = FALSE]) |>
  mutate(incident = factor(sample_rows$incident, levels = rev(sample_rows$incident))) |>
  pivot_longer(-incident, names_to = "feature", values_to = "residual") |>
  mutate(feature = factor(feature, levels = feature_cols)) |>
  ggplot(aes(feature, incident, fill = residual)) +
  geom_tile(colour = "white", linewidth = 0.4) +
  scale_fill_gradient(low = "#f0efec", high = "#1f4e8c", name = "|x − x̂|") +
  labs(title = "Feature-Level Reconstruction Error for Detected Attacks",
       subtitle = "Random sample of up to 6 detected windows per attack type (99.9% threshold)",
       x = NULL, y = NULL) +
  theme(axis.text.x = element_text(angle = 60, hjust = 1, size = 9), axis.text.y = element_text(size = 9),
        panel.grid = element_blank())
Figure 3

How to read the plot. Each row is one detected attack window, chosen at random and labelled with its attack type and intensity. Each column is one telemetry feature. Darker blue means the model reconstructed that feature badly in that window, which marks it as a likely cause of the alert. Pale cells are features the model reproduced well. An analyst would use this view to see at a glance why an alert fired.

What the plot tells you. Most attack types light up a feature the attack actually changed: source IPs for credential stuffing, privilege escalations for privilege escalation, DNS queries and file writes for ransomware staging, and new service creations for lateral movement. The few exfiltration windows that were detected are different. Their darkest cell is an unrelated spike, not bytes or session length, so they were flagged for the wrong reason. The sample is drawn only from detected, mostly high-intensity windows.

Display code
analysis$attribution |>
  gt() |>
  tab_header(title = "Does the Top-3 Attribution Point at the Injected Features?",
             subtitle = "Share of detected attack windows whose 3 largest contributors include an injected feature") |>
  cols_label(attack_type = "Attack type", n = "Detected windows", ae_top3 = "Autoencoder residuals",
             z_top3 = "Plain |z|-scores") |>
  fmt_percent(c(ae_top3, z_top3), decimals = 0) |>
  tab_options(table.font.size = 12)
Table 5
Does the Top-3 Attribution Point at the Injected Features?
Share of detected attack windows whose 3 largest contributors include an injected feature
Attack type Detected windows Autoencoder residuals Plain |z|-scores
Data Exfiltration 2 100% 100%
Credential Stuffing 150 100% 100%
Privilege Escalation 157 100% 100%
Ransomware Staging 290 100% 100%
Lateral Movement 156 100% 100%
Low-and-Slow Exfiltration 1 0% 100%

How to read the table. For each detected attack window we listed the three features with the largest reconstruction error and checked whether at least one of them was a feature the attack actually changed. The middle column applies this test to the autoencoder’s errors. The last column repeats it using each feature’s plain distance from average, with no model involved. “Detected windows” shows how many alerts each percentage rests on.

What the table tells you. Wherever there are enough detections to judge, both methods place a changed feature in the top three every time. Attribution works, but it does not need the autoencoder: plain distance from average does just as well. The test is also lenient. The exfiltration windows count as hits because a changed feature ranks second or third, although the alert was driven by something else. A stricter top-one test would be more informative.

Containment routing

This is where the two layers meet. An alert’s response depends on how critical the affected service is, using the tiers from the Dependency Graph page.

Display code
policy <- c(
  "Tier 1" = "Human approval before any isolation or credential revocation",
  "Tier 2" = "Automated step-up authentication / single-session termination; analyst review",
  "Tier 3" = "Automated step-up authentication / single-session termination; analyst review"
)
analysis$routing |>
  pivot_wider(names_from = label, values_from = n, values_fill = 0) |>
  mutate(policy = policy[criticality_tier], share_false = Normal / (Anomaly + Normal)) |>
  select(criticality_tier, Anomaly, Normal, share_false, policy) |>
  gt() |>
  tab_header(title = "Alert Routing by Service Criticality",
             subtitle = "Main-seed alerts at the 99.9% threshold; each test window mapped to a service at random") |>
  cols_label(criticality_tier = "Service tier", Anomaly = "True attack alerts", Normal = "False alarms",
             share_false = "Share false", policy = "Response until production validation") |>
  fmt_percent(share_false, decimals = 1) |>
  tab_options(table.font.size = 12)
Table 6
Alert Routing by Service Criticality
Main-seed alerts at the 99.9% threshold; each test window mapped to a service at random
Service tier True attack alerts False alarms Share false Response until production validation
Tier 1 192 2 1.0% Human approval before any isolation or credential revocation
Tier 2 236 6 2.5% Automated step-up authentication / single-session termination; analyst review
Tier 3 328 8 2.4% Automated step-up authentication / single-session termination; analyst review

How to read the table. Each row is a criticality tier from the dependency graph. The counts show how many of this run’s alerts at the 99.9% threshold would land on services in that tier, split into real attacks and false alarms. The final column gives the response the containment rule allows until the detector is validated on production data. Test windows are assigned to services at random here, standing in for an asset inventory.

What the table tells you. In this run 25% of alerts land on Tier 1 services, where isolation is itself an outage, so they wait for a person. No tier gets automated host isolation yet. False alarms are a small share of these alerts only because attacks are so common in the test set. At realistic prevalence they would dominate, and automated isolation would mostly cut off healthy hosts.

Drift monitoring

The original recommendation was a weekly Kolmogorov-Smirnov (KS) test on every feature at \(p < 0.01\). This table tests that rule and two alternatives on a simulated week from 100 new hosts (201,600 windows).

Display code
dr <- analysis$drift
dr |>
  summarise(
    ks_shifted = sum(shifted & ks_p_holm < cfg$drift$ks_alpha),
    ks_other = sum(!shifted & ks_p_holm < cfg$drift$ks_alpha),
    psi_shifted = max(psi[shifted]),
    psi_other = max(psi[!shifted]),
    w_shifted = max(wasserstein[shifted]),
    w_other = max(wasserstein[!shifted]),
    .by = scenario
  ) |>
  left_join(select(analysis$alert_rate, scenario, alert_rate), by = join_by(scenario)) |>
  gt() |>
  tab_header(title = "Which Drift Metric Flags Which Change?",
             subtitle = sprintf("Two features shifted; KS uses Holm correction across %d features", d_features)) |>
  cols_label(scenario = "Scenario", ks_shifted = "Shifted (of 2)", ks_other = sprintf("Others (of %d)", d_features - 2),
             psi_shifted = "Shifted", psi_other = "Others", w_shifted = "Shifted", w_other = "Others",
             alert_rate = "Alert rate at 99.9%") |>
  tab_spanner(sprintf("KS flags (p < %s)", cfg$drift$ks_alpha), c(ks_shifted, ks_other)) |>
  tab_spanner("Max PSI", c(psi_shifted, psi_other)) |>
  tab_spanner("Max Wasserstein (SD units)", c(w_shifted, w_other)) |>
  fmt_number(c(psi_shifted, psi_other, w_shifted, w_other), decimals = 3) |>
  fmt_percent(alert_rate, decimals = 2) |>
  tab_options(table.font.size = 12)
Table 7
Which Drift Metric Flags Which Change?
Two features shifted; KS uses Holm correction across 19 features
Scenario
KS flags (p < 0.01)
Max PSI
Max Wasserstein (SD units)
Alert rate at 99.9%
Shifted (of 2) Others (of 17) Shifted Others Shifted Others
No shift 0 3 0.000 0.016 0.010 0.114 0.11%
Small shift (0.05 SD) 2 3 0.003 0.016 0.059 0.114 0.11%
Material shift (0.3 SD) 2 3 0.089 0.016 0.309 0.114 0.11%

How to read the table. Each row is one version of a simulated new week: unchanged, with two features nudged by a trivial 0.05 standard deviations, or by a material 0.3. The KS columns count features that a significance test flags as changed. PSI is a common stability index, read as “watch” above 0.1 and “act” above 0.2. Wasserstein distance is the size of the shift in standard deviations. The alert rate should stay near 0.1%.

What the table tells you. The significance test fails both ways. It flags the trivial shift as firmly as the material one, and it flags 3 untouched features in every scenario because new hosts differ slightly. PSI misses the material shift (maximum 0.089). Wasserstein distance reads the shift size directly and separates trivial from material. The alert rate barely moved, so it cannot be the only monitor either.