Commit 16f3458
Time-aware NAB attempt + harmonic_anomaly library + README
Three pieces wrapping up the anomaly-detection arc:
1. examples/datascience/nab_time_aware.omc
Tried three iterations to beat IsolationForest on NAB realKnownCause:
naive bucket-rarity, rolling robust z-score (|z|), rolling robust z
(positive-only). All three tie at 7/19 windows covered.
Honest interpretation: beating NAB SOTA needs real time-series
machinery (CUSUM change-point detection, FFT seasonality
decomposition, HMM/LSTM autoencoders). Naive top-K detectors,
harmonic or otherwise, sit at the 30-40% baseline tier.
The harmonic angle is bucket-rarity post-z-score; with positive-only
dev (caught via debug print: was flagging early-morning low-traffic
dips as false positives), the algorithm matches IF but doesn't
exceed it. Documented as honest negative result.
2. examples/lib/harmonic_anomaly.omc
Packages the multi-dim subspace detector from Phase B+2 as a clean
library. API mirrors scikit-learn ergonomics:
h det = ha.new(["latency", "status", "endpoint", "hour"]);
ha.set_strategy(det, 1, "discrete");
ha.fit(det, training_rows);
h alerts = ha.top_k(det, all_rows, 10);
Three bucketing strategies: "log" (default, for numeric ranges
spanning magnitudes), "discrete" (for categorical), "modulo"
(for periodic small ints like hour-of-day).
Plus ha.detect(dims, rows, k) one-shot convenience.
Registered in registry/index.json with sha256. Installable via
`omc --install harmonic_anomaly`.
3. examples/datascience/anomaly_tutorial.omc
Tutorial walking through the library as a drop-in IsolationForest
replacement. Synthesises 200 normal requests + 5 credential-
stuffing rows; ha.top_k catches 5/5 in top-5. Documents when to
choose harmonic_anomaly vs scikit-learn IsolationForest.
4. README updates
- New "Where harmonic detection actually wins" section with the
comparison table against scikit-learn IsolationForest.
- harmonic_anomaly added to the integration libraries list.
- Two new demos in the worth-running table (anomaly_detection,
multidim_anomaly, anomaly_tutorial, nab_validation,
nab_time_aware).
- Honest about wins (multi-dim 10/10) AND ties/losses (NAB 7/19,
1-D power-law K=30).
43/43 functional examples produce identical output under tree-walk
and VM. 92/92 unit tests pass.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 07b4def commit 16f3458
5 files changed
Lines changed: 657 additions & 1 deletion
File tree
- examples
- datascience
- lib
- registry
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
111 | 118 | | |
112 | 119 | | |
113 | 120 | | |
| |||
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
183 | 225 | | |
184 | 226 | | |
185 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
0 commit comments