Detecting Anomalies in Social Media Volume Time Series

Lorenzo Mezzini11 Nov 2024

Problem

Social listening and marketing teams track how many posts mention a brand every few minutes. A sudden spike can mean a crisis or a viral moment, and management wants to hear about it quickly. Raw volume has a day-night cycle, so a fixed threshold either fires every afternoon or misses night-time spikes. The detector must also work live, on each new observation, without labeled incidents.

Example from the article: Twitter volume for Apple (AAPL) from the Numenta Anomaly Benchmark, one count per 5-minute window, over 15,000 observations.

Solution in brief

Remove the daily cycle with a multiplicative seasonal decomposition, then look at the residual between observed and expected volume. The residuals follow a Pareto distribution closely, so a high quantile of a fitted Pareto (0.9995) gives the alert threshold. For live use, refit and re-check on every new observation.

Questions this case answers
  • How to detect abnormal spikes in a high-frequency count series with a strong daily cycle and no labeled incidents, both in batch and in real time
  • How to flag spikes in a social media mention-volume series when daily seasonality hides them?
  • How to set an anomaly threshold on a seasonal volume series without labeled incidents?
  • How to run the same detector in real time on every new 5-minute observation?

Tools and methods

  • Seasonal decomposition — moving average for the trend, ratio to it for the multiplicative daily effect.
  • Pareto threshold on residuals — flags residuals above the 0.9995 quantile of a fitted Pareto distribution.
  • Numenta Anomaly Benchmark — source of the Twitter volume series.
Continue reading — it's free

Google or a one-time email code. No password.