Loops' Anomaly Detection Model
Overview
Loops’ anomaly detection algorithm identifies points in time where a Key Performance Indicator (KPI) deviates sharply from its recent historical pattern. Unlike approaches that may flag slow-moving trends or gradual shifts, our model focuses on highlighting true outliers—short-term, unexpected changes that stand out from the baseline established by the KPI’s immediate past.
For example, if a KPI suddenly spikes or drops for a short period, our algorithm will flag those points. If the KPI settles into a new, higher (or lower) level, only the first few data points in that shift might appear as anomalies. After that, the new values will be considered the “new normal.”
By design, the algorithm mimics the judgment of a skilled data analyst, helping you quickly pinpoint unusual data points that may warrant investigation.
How It Works
1. Defining the Look-Back Period
Daily Data:
- We use the past 28 days of KPI values to understand what “normal” looks like.
Weekly Data:
- We use the past 4 weeks of KPI values to define the expected level.
2. Modeling the Historical Data
For Daily Data:
- We fit a model that:
- Captures weekly seasonality (the natural ebb and flow across the week).
- Incorporates a linear trend, reflecting gradual increases or decreases.
This model strikes a balance between simplicity and accuracy, and it runs efficiently, making it suitable for real-time monitoring.
For Weekly Data:
- We calculate the average of the last 4 weeks. This average represents the baseline against which the current week’s value is compared.
3. Predicting the Current Point – "Expected Value”
Using the model and the historical data, we generate an expected value (forecast) for the current time point (e.g., “today” for daily data or “this week” for weekly data). This expected value is displayed in the Loops UI as the baseline KPI.
4. Calculating Residuals
Residual = Actual Value – Expected Value
Residuals represent how much higher or lower the actual KPI is compared to what we predicted. Positive residuals mean the KPI is unexpectedly high; negative residuals mean it’s unexpectedly low.
Why Are Residuals Important?
We calculate residuals to measure deviation from our expected baseline. These residuals are crucial for constructing the Confidence Intervals (CIs), which help us distinguish normal fluctuations from genuine anomalies.
5. Constructing Confidence Intervals (CIs)
We recognize that data naturally varies. To determine whether a deviation is large enough to be considered an anomaly, we build a confidence interval (CI) around the expected value. The CI represents a range of “normal” variation.
For Daily Data (IQR Method):
- We compute the Inter-Quartile Range (IQR) of recent residuals.
- IQR = Q3 – Q1, where Q3 and Q1 are the 75th and 25th percentiles of the residuals, respectively.
- We multiply the IQR by a calibrated factor to account for typical variability.
- This gives us upper and lower bounds:
- Upper CI = Expected + Q3 + (IQR * Factor)
- Lower CI = Expected + Q1 – (IQR * Factor)
Because real-world data often isn’t symmetric, these intervals might not be evenly spaced around the expected value.
For Weekly/Monthly Data (Standard Deviation Method):
- We calculate the standard deviation of the last four residuals.
- We Multiply this standard deviation by a calibrated factor (optimized from real-world data).
- The upper and lower CI limits are then set around the average of recent values.
Why We Chose This Method
Our approach is the result of extensive testing and refinement:
- Real-World Validation: We tested the algorithm on hundreds of KPIs across various clients and thousands of expert-labeled anomalies.
- Speed and Efficiency: Unlike more complex tools (e.g., Prophet or advanced outlier detection methods), our method needs less data and is faster, making it ideal for real-time applications.
- Accuracy and Reliability: The chosen method matches the performance of more complex models when compared to expert-labeled anomalies.
In short, our anomaly detection method provides a practical, swift, and accurate way to surface unusual points in your data.
Summary of the Process
- Identify the baseline:
- Daily: Use a seasonal-trend model based on 28 days of data.
- Weekly: Use the average of the last 4 weeks.
- Check actual vs. expected (residual analysis):
- If the actual value deviates too far from the expected value, consider it anomalous.
- Confidence Intervals:
- Daily data: IQR-based CI for a robust, asymmetric range.
- Weekly data: Standard deviation-based CI for a simpler, symmetric range.
- Result:
- Flag only those points that stand out from the recent pattern, ignoring gradual shifts or consistent trends after they become the new norm.
Types of Anomalies
This section provides examples of the kinds of irregularities our model can identify. Understanding these examples will help you recognize when and why certain data points are flagged as anomalies.
High/Low Spike
A brief, sharp increase or decrease that quickly returns to normal levels. Visually, these look like sudden peaks or dips.
Level Change
A sudden jump or drop that leads the KPI to settle at a new, stable level. Only the initial points of this “step” are flagged as anomalies, and the rest are considered the new baseline.
Trend Deviation
A significant break from an existing trend, either up or down, that goes beyond the normal expectations. Even if a trend is emerging, a sudden, dramatic deviation may be flagged as an anomaly.
Conclusion
Loops’ anomaly detection helps you quickly spot the unexpected, guiding you toward the data points that truly need attention. By focusing on short-term irregularities, it reduces noise and ensures that what you see as “anomalous” is both meaningful and actionable.