In this recipe, we first imported numpy and pandas for data manipulation. We then imported sesd, our anomaly detection package. Next, we got the raw data ready for machine learning. We did this by removing the data that clearly had an issue, such as sensors that were not working properly. We then filtered the data into one column. We then put that column through the seasonal ESD algorithm.
Similar to the Z-score algorithm in the first recipe, this recipe uses an online approach. It uses Seasonal and Trend decomposition using Loess (STL) decomposition as a preprocessing step before doing anomaly detection. A data source may have a trend and a season, as shown in the following graph:
What decomposition allows you to do is look at the trend and the seasonality independently (as shown in the following trend graph). This helps to ensure the data is not affected by seasonality:
The Seasonal ESD algorithm is more complicated than the Z-score algorithm. For example, Z-score...