How would you approach detecting outliers in time-series data, considering temporal dependencies?
Role: Data Scientist
Category: Statistics & Math
Difficulty: hard
Interview Round: Other
How would you approach detecting outliers in time-series data, considering temporal dependencies?
Think of a series such as hourly request counts for a web service, where each value depends on recent values and on the hour of the day and the day of the week.
```hint What counts as unusual
A value of 4,000 can be normal at 9am on a Monday and alarming at 3am on a Sunday. Work out how you would get an expected value for each timestamp before you score how far an observation is from it.
```
```hint Thresholds over time
Consider which data a detector may look at when it scores a point, what a few large outliers do to a threshold built from the mean and standard deviation, and what happens to a fixed cutoff when the baseline moves over months.
```
### What a Strong Answer Covers
- The kinds of anomaly (single points, values unusual for their context, unusual subsequences) and why the method depends on which one matters
- How trend, seasonality and autocorrelation are modeled before scoring, and how residuals or forecast errors become a flag
- How the threshold is set so that outliers do not distort it, and how it adapts as the baseline changes
- Validation that respects time order, given that labeled anomalies are usually scarce
- What happens to a flagged point afterward, such as alerting, investigation or replacement before modeling
### Follow-up Questions
- A single huge spike inflates the residual standard deviation. How do you keep it from hiding the other outliers?
- How would you run detection across 10,000 related series, such as sales per store, without tuning each one by hand?
- How do you evaluate a detector when you have only a handful of labeled incidents?
- How would you tell a real level shift from a run of outliers, and should the detector keep alerting after the shift?
Overview: Asks how to detect outliers in time-series data where each value depends on trend, seasonality and recent history. It tests how a candidate accounts for temporal structure, sets thresholds that hold up as the baseline drifts, and validates a detector without letting it see the future.