Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try RobustPeriod implementation in Pyriodicity #6

Open
iskandergaba opened this issue Jan 3, 2025 · 0 comments
Open

Try RobustPeriod implementation in Pyriodicity #6

iskandergaba opened this issue Jan 3, 2025 · 0 comments

Comments

@iskandergaba
Copy link

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:

Thank you for your time, and I look forward to your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant