1
$\begingroup$

I am trying to use anomaly detection to find the anomalies in my time series, and if I find it, I will replace it with my past values. I'm trying to do this because I want to create an upper and lower bound to replace those anomalies and by using the past values will help me to create this bound. Is there any guidance or example, where I can learn to do this? Thanks!

$\endgroup$
1
  • $\begingroup$ How does your data look like? (normal and anomalies) $\endgroup$
    – Jon Nordby
    Dec 18, 2021 at 18:57

1 Answer 1

1
$\begingroup$

A rudimental mechanical approach would be to track moving average & its moving standard deviation for a predefined time window of your dataset. Any handful of points that temporarily breach over or under your 3 standard deviation value are outliers (assuming no process shift) & you could replace these by the moving average.

$\endgroup$
2
  • $\begingroup$ Could you give an example? Like a code example. I'm not sure how to write this in code. @eliangius $\endgroup$ Dec 12, 2021 at 23:47
  • 1
    $\begingroup$ @user3002936 If you have the data in a panda dataframe, you can use pandas.DataFrame.rolling to calculate rolling statistics and combine it with pandas.DataFrame.mean and pandas.DataFrame.std to get the moving average and moving standard deviation. $\endgroup$
    – Oxbowerce
    Dec 14, 2021 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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