robust-period
robust-period copied to clipboard
Try RobustPeriod implementation in Pyriodicity
Hello @ariaghora!
First, thank you for your work here. It surely has inspired me.
I am the maintainer of a small Python package called pyriodicity
that aims at providing the implementation of popular and state-of-the-art automatic periodicity detection methods in univariate and equidistant signals and time series. I have implemented RobustPeriod
in the latest version through my own understanding of the paper, with a focus on code efficiency, simplicity, and good parameter defaults. My implementation remains as faithful as possible to the method presented in the paper, with the addition of good parameter suggestions, such as automatically computing lambda
using one of two methods in the scientific literature based on the number of observation per year.
Understanding the paper was not very easy for me as there were many issues in it, such as the inconsistent interchangeable use of N
and N'
, incorrectly using the inverse null hypothesis of the Fisher g-test, and more. And since you are, apparently, the only other person to attempt replicating the paper and given that you "welcome any contribution", I would love it if you could give pyeriodicity
a try and let me know of your feedback.
It should be noted that the methods' comparison section of the paper is somewhat lacking, as there is no mention of the number of CPUs used, for example. In the case of the comparison with Autoperiod
(also implemented in pyriodicity
), it is unclear how efficient their implementation is. I have managed to make Autoperiod
much faster than the first iteration by just eliminating redundant computations.
Anyway, installing pyriodicity
is as easy as running pip installl pyriodcity
. You can use statsmodels
co2
dataset to test RobustPeriod
like this:
>>> from statsmodels.datasets import co2
>>> from pyriodicity import RobustPeriod
>>> data = co2.load().data.ffill()
>>> RobustPeriod.detect(data)
array([52]) # 52 weeks, i.e. one year
>>> data = co2.load().data.resample("ME").mean().ffill()
>>> RobustPeriod.detect(data)
array([12]) # 12 months, i.e. one year
The code above should take less than a minute (2 minutes max) to run on a modern computer. For more information, check out the links below:
- https://pypi.org/project/pyriodicity
- https://pyriodicity.readthedocs.io
- https://github.com/iskandergaba/pyriodicity
Thank you for your time, and I look forward to your feedback.