AbsoluteSeasonalReturn¶
yohou.stationarity.transformers.AbsoluteSeasonalReturn
¶
Bases: BaseTransformer
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
References¶
[1] 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¶
Show/Hide source
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 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 | |
Methods¶
observation_horizon
property
¶
Return the number of past observations needed.
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¶
Show/Hide source
Tutorials¶
The following example notebooks use this component:
-
How to Apply Stationarity Transforms
Data-Features
Catalogue of variance-stabilising and detrending transforms: LogTransformer, BoxCox, SeasonalDifferencing, SeasonalReturn, and ASinh with inverse verification.