AbsoluteSeasonalReturn¶
yohou.stationarity.AbsoluteSeasonalReturn
¶
Bases: SeasonalDifferencing
Absolute seasonal return (difference) time series transformer.
Computes the absolute difference relative to the value from seasonality
time steps ago:
This is semantically similar to SeasonalDifferencing but provides a
consistent API with SeasonalReturn and explicitly handles the offset
parameter for API symmetry.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
seasonality
|
int >= 1
|
Seasonality lag for computing differences. |
1
|
offset
|
float >= 0.0
|
Offset parameter (provided for API consistency with SeasonalReturn, but note that offset cancels out in the computation). |
0.0
|
Attributes ¶
| Name | Type | Description |
|---|---|---|
n_features_in_ |
int
|
Number of features seen during fit. |
feature_names_in_ |
list of str
|
Names of features seen during fit (excluding "time" column). |
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.stationarity import AbsoluteSeasonalReturn
>>> X = pl.DataFrame({
... "time": [datetime(2024, 1, i) for i in range(1, 6)],
... "value": [100.0, 110.0, 105.0, 115.0, 120.0],
... })
>>> transformer = AbsoluteSeasonalReturn(seasonality=2, offset=0.0)
>>> transformer.fit(X)
AbsoluteSeasonalReturn(...)
>>> X_t = transformer.transform(X)
>>> len(X_t) == len(X) - 2 # First 2 rows dropped
True
Notes ¶
This transformer is stateful with observation_horizon = seasonality.
The first seasonality rows are dropped in the output. Inverse
transform requires the X_p prior-context argument.
References ¶
- Hyndman, R.J., & Athanasopoulos, G. (2021). "Forecasting: principles and practice," 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3. Chapter 9.1.
See Also ¶
SeasonalReturn: Percentage returns instead of absolute differences.SeasonalDifferencing: Equivalent computation with different API.
Source Code ¶
Source code in src/yohou/stationarity/transformers.py
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | |
Methods ¶
get_feature_names_out(input_features=None)
¶
Get output feature names for transformation.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
input_features
|
array-like of str or None
|
Column names of the input features. If |
None
|
Returns ¶
| Type | Description |
|---|---|
list of str
|
Output feature names after transformation. |
Source Code ¶
Source code in src/yohou/stationarity/transformers.py
Tutorials¶
The following example notebooks use this component:
-
How to Apply Stationarity Transforms
Catalogue of variance-stabilising and detrending transforms: LogTransformer, BoxCox, SeasonalDifferencing, SeasonalReturn, and ASinh with inverse verification.