ACFPeriodicityDetector#
- class pyriodicity.ACFPeriodicityDetector#
Autocorrelation Function (ACF) based periodicity detector.
Find the periods in a given signal or series using its ACF. A lag value is considered a period if it is a local maximum of the ACF [1].
See also
pyriodicity.OnlineACFPeriodicityDetectoronline Autocorrelation Function (ACF) based periodicity detector.
References
[1]Hyndman, R.J., & Athanasopoulos, G. (2021) Forecasting: principles and practice, 3rd edition, OTexts: Melbourne, Australia. https://OTexts.com/fpp3/acf.html. Accessed on 09-15-2024.
Examples
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 ACFPeriodicityDetector to find the list of seasonality periods using the ACF.
>>> from pyriodicity import ACFPeriodicityDetector >>> ACFPeriodicityDetector.detect(data) array([ 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 143, 155, 167, 179, 191, 203, 215, 227, 239, 251])
All of the returned values are either multiples of 12 or very close to it, suggesting a clear yearly periodicity. You can also get the most prominent period length value by setting
max_period_countto 1.>>> ACFPeriodicityDetector.detect(data, max_period_count=1) array([12])
Methods
detect(data[, window_func, detrend_func, ...])Find periods in the given series.