1
$\begingroup$

I am trying to create a pipeline in Python which automatically identifies global and contextual anomalies of a time series.

Which one of these approaches do you believe is more correct?

Method 1)

  1. Detect global outliers using z-score threshold.
  2. Remove the outliers from the time series and impute values
  3. Detect if seasonality/periodicity is present
  4. If yes on 3) perform seasonal decomposition
  5. Detect contextual outliers using z-score threshold on residuals.
  6. Combine both groups of outliers.

Method 2)

  1. Detect global outliers using z-score threshold.
  2. Remove the outliers from the time series and impute values
  3. Detect if seasonality/periodicity is present
  4. If yes on 3) perform seasonal decomposition
  5. Remove seasonality and trend from original signal potentially containing global outliers as well
  6. Detect contextual outliers and global outliers using z-score threshold on residuals.

Method 3)

Something else which you know of?

Appreciate any insights or tips!

enter image description here

$\endgroup$

1 Answer 1

0
$\begingroup$

It depends on how the nature of your anomalies. If global and contextual outliers co-exist often, and outliers are common outliers in general, and are extreme enough, have clusters or otherwise could impact the seasonal decomposition, then something like method 1 may work better. In all other cases it is just additional complexity, including more hyperparameters to tune to each good performance.

Method 2 is simpler, so implement it first. Evaluate how well it performs. If it is insufficient, then consider a more complex method based on the short-comings that have been identified. Which may not be

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.