How do I implement sliding window algorithm with a window size of 10 and visualize the data iteratively to see spikes/possible outliers in the dataframe, using python? Please help a beginner.
-
1$\begingroup$ Are you actually looking for an algorithm that detects spikes (anomaly detection), or simply a way to visualize data 10 observations at a time to manually look for spikes in the data? $\endgroup$– RyanMay 31, 2018 at 16:47
-
$\begingroup$ $There are gems$ -: “Open Machine Learning Course. Topic 9. Part 1. Time series analysis in Python” medium.com/open-machine-learning-course/…,“Open Machine Learning Course. Topic 9. Part 2. Predicting the future with Facebook Prophet” medium.com/open-machine-learning-course/… $\endgroup$– AdityaMay 31, 2018 at 16:54
-
$\begingroup$ Thanks @Aditya the resource you provided was extremely helpful! Ryan, I am looking to detect random spikes on data and smoothen them out, as well as to visualize them in smaller windows. $\endgroup$– natgMay 31, 2018 at 19:11
1 Answer
welcome to DS-SE and to Data Science in general! :)
Your problem can be solved really easily in Python. Please, take a look at Pandas DataFrame class to represent your data, it makes it really convenient because of all the pre-built methods that includes.
One of its methods is pandas.DataFrame.rolling()
(see here) that does exactly what you asked for: rolling (sliding) window calculations, please take a look!
Hope it helps!
-
1$\begingroup$ @pdko1 this is exactly what I was looking to do! Thanks so much! $\endgroup$– natgMay 31, 2018 at 19:32