Skip to main content
When SynForecast injects an anomaly, changepoint, or gap, it also keeps the label and the uncorrupted series. That lets you measure two things you normally can’t: how well a detector finds the corruptions, and how much they cost a forecaster. Both need answers that real data doesn’t hand you.
Why synthetic data A detector’s precision and recall are only defined if you know which points are anomalies. Measuring the cost of contamination needs a clean copy of the same series. On real data you have neither; the generator supplies both.

Detecting anomalies

We make weekly-seasonal series with 4% of points hit by spikes and dips, and record their positions with ExogenousConfig(anomaly_flags=True). A rolling robust z-score scores each point; varying the threshold moves along the precision/recall trade-off.
The labels make the operating point measurable rather than assumed: the marked threshold is the one with the best F1. Higher thresholds buy precision at the cost of recall. Substitute another detector to see where it sits on the same axes.

The cost of contamination

We generate clean seasonal series, hold out the last 14 days, then corrupt a growing fraction of the training history and refit a trend-plus-seasonal-means model. That model reads its slope and seasonal profile off every training point, so outliers shift the fit β€” a seasonal-naive rule, which only repeats recent values, would barely register them.
Scale against the clean series Each forecast is scaled by an in-sample seasonal error taken from the clean training series and held fixed across contamination levels. Scale by the contaminated series instead and the spikes inflate the denominator, so error appears to drop as contamination rises.
Error rises with contamination, measured on a holdout we know is clean and against a scale the noise can’t move. The same setup works for any pipeline: perturb the input by a known amount and watch a trustworthy metric respond.
Related capabilities