larzanomaly
The same math flags bot traffic AND finds SEO opportunities.
Which cohorts have an event rate implausible for their volume - ranked by volume, not rate alone, so a 1-view/0-click cohort stays noise while a 50,000-view one gets flagged. Ported from a real production ad-fraud scanner - and the identical function, just different thresholds, is what a real CTR-opportunity finder runs: a bot farm behind a clean UA and an underperforming page with high impressions are the same statistical shape from opposite sides. Includes atomic_write() - write-then-rename, so a reader never sees a half-written file.
What you get
- find_low()/find_high() - volume-gated rate filtering, ranked
- The same call catches fraud AND finds SEO opportunities
- min_volume gate - a cohort needs a fair chance before judging it
- atomic_write() - write-then-rename, never a half-written file
Try it
import "anomaly" as anomaly
let cohorts = [
{"key": "bot-farm-ua", "volume": 42000, "hits": 9},
{"key": "real-users-ua", "volume": 8000, "hits": 340},
]
let flagged = anomaly.find_low(cohorts, 2000, 0.001)
print("flagged:", flagged)
let pages = [
{"key": "/blog/underperforming/", "volume": 5000, "hits": 40},
{"key": "/blog/doing-great/", "volume": 5000, "hits": 400},
]
let opps = anomaly.find_low(pages, 150, 0.03)
print("opportunities:", opps)flagged: [{key: bot-farm-ua, volume: 42000, hits: 9, rate: 0.000214286}]
opportunities: [{key: /blog/underperforming/, volume: 5000, hits: 40, rate: 0.008}]Why it's in the Larz Stack
larzanomaly is a real Larzscript package (larzscript pkg install anomaly) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.