-
Book Overview & Buying
-
Table Of Contents
Time Series with PyTorch
By :
The conditional X-chart we built is partway to a model. By specifying thresholds relative to exogenous variables, we are saying normal observations are context dependent. Obviously stacking conditions has a ceiling; having price, promotions, day-of-week effects, and seasonality all interacting, the number of conditions multiplies and the boundaries between them become arbitrary. At some point you’re no longer writing rules, but approximating a model, badly.
A cleaner solution is to explicitly build a model. Statistical profiling formalizes this: fit a model (your choice) of expected behavior, and treat its residuals as the detection signal. An anomaly is not a value that exceeds some global threshold; it is a value that is unexpectedly large or small given everything the model knows. Formally, at each time step (
) we compute:

where
is a model’s predicted value given available context: seasonality, trend, price, promotional depth. The...