Skip to main content

Efficient periodicity length detection for univariate signals in Python.

Project description

Pyriodicity

PyPI Version PyPI - Python Version License Codecov Docs CI Build

Efficient periodicity length detection for univariate signals in Python. You can check the supported detection methods in the API Reference.

Installation

To install pyriodicity, simply run:

pip install pyriodicity

To install the latest development version, you can run:

pip install git+https://github.com/iskandergaba/pyriodicity.git

Usage

Please refer to the package documentation for more information.

For this example, start by loading Mauna Loa Weekly Atmospheric CO2 Data from statsmodels and downsampling its data to a monthly frequency.

>>> from statsmodels.datasets import co2
>>> data = co2.load().data
>>> data = data.resample("ME").mean().ffill()

Use Autoperiod to find the list of periodicity lengths in this data, if any.

>>> from pyriodicity import Autoperiod
>>> Autoperiod.detect(data)
array([12])

The detected periodicity length is 12 which suggests a strong yearly seasonality given that the data has a monthly frequency.

We can also use online detection methods for data streams as follows.

>>> from pyriodicity import OnlineACFPeriodicityDetector
>>> data_stream = (sample for sample in data.values)
>>> detector = OnlineACFPeriodicityDetector(window_size=128)
>>> for sample in data_stream:
...   periods = detector.detect(sample)
>>> 12 in periods
True

All the supported periodicity detection methods can be used in the same manner as in the examples above with different optional parameters. Check the API Reference for more details.

References

  1. Hyndman, R.J., & Athanasopoulos, G. (2021). Forecasting: principles and practice, 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3. Accessed on 09-15-2024.
  2. Vlachos, M., Yu, P., & Castelli, V. (2005). On periodicity detection and Structural Periodic similarity. Proceedings of the 2005 SIAM International Conference on Data Mining. doi.org/10.1137/1.9781611972757.40.
  3. Puech, T., Boussard, M., D'Amato, A., & Millerand, G. (2020). A fully automated periodicity detection in time series. In Advanced Analytics and Learning on Temporal Data: 4th ECML PKDD Workshop, AALTD 2019, Würzburg, Germany, September 20, 2019, Revised Selected Papers 4 (pp. 43-54). Springer International Publishing. doi.org/10.1007/978-3-030-39098-3_4.
  4. Toller, M., Santos, T., & Kern, R. (2019). SAZED: parameter-free domain-agnostic season length estimation in time series data. Data Mining and Knowledge Discovery, 33(6), 1775-1798. doi.org/10.1007/s10618-019-00645-z.
  5. Wen, Q., He, K., Sun, L., Zhang, Y., Ke, M., & Xu, H. (2021, June). RobustPeriod: Robust time-frequency mining for multiple periodicity detection. In Proceedings of the 2021 international conference on management of data (pp. 2328-2337). doi.org/10.1145/3448016.3452779.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyriodicity-0.7.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyriodicity-0.7.0-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file pyriodicity-0.7.0.tar.gz.

File metadata

  • Download URL: pyriodicity-0.7.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyriodicity-0.7.0.tar.gz
Algorithm Hash digest
SHA256 037c25a3e752371d505325f248c68034ed17b38110914a9f7ef22e8287d72548
MD5 69b58a614a2b327af1f06ca635a91db1
BLAKE2b-256 9ad36457093458656885bd5ce5120858126d3655a31df5d412e4fb4990c17c2d

See more details on using hashes here.

File details

Details for the file pyriodicity-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: pyriodicity-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pyriodicity-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7fb295696d9704edae45acc92de9a2486debcaa483293aef6b2b78083145ca8
MD5 b3965d00b363d3599bfb792cc5e2470b
BLAKE2b-256 994f68dedd6fbf22af2e2190ef8f62bd47848b07d2e88c1b9ec0b0dcaae29c21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page