ASinhTransformer¶
yohou.stationarity.transformers.ASinhTransformer
¶
Bases: BaseTransformer
Variance stabilization through arcsinh transform.
Applies the transformation:
where \(\tilde{X}\) is the median and \(\text{MAD} = c \cdot \text{median}(|X - \tilde{X}|)\) with scale factor \(c = 1.4826\) by default to match the standard deviation for normally distributed data.
This transformation is useful for:
- Stabilizing variance in heteroscedastic time series
- Handling data with outliers (asinh is less sensitive than log)
- Data that can be negative (unlike log transform)
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
float > 0
|
Scale factor for MAD normalization. Default value makes MAD consistent with standard deviation for normal distributions. |
1.4826
|
Attributes¶
| Name | Type | Description |
|---|---|---|
median_ |
dict[str, float]
|
Median values for each column (excluding time). |
mad_ |
dict[str, float]
|
Scaled MAD values for each column (excluding time). |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.stationarity import ASinhTransformer
>>> X = pl.DataFrame({
... "time": [datetime(2024, 1, i) for i in range(1, 6)],
... "value": [1.0, 10.0, 100.0, 1000.0, 10000.0],
... })
>>> transformer = ASinhTransformer()
>>> transformer.fit(X)
ASinhTransformer(...)
>>> X_t = transformer.transform(X)
>>> "time" in X_t.columns
True
References¶
[1] Johnson, N.L. (1949). "Systems of frequency curves generated by methods of translation." Biometrika, 36(1-2), 149-176. https://doi.org/10.1093/biomet/36.1-2.149
See Also¶
BoxCoxTransformer: Power transform for variance stabilization.LogTransformer: Simpler variance stabilization for positive data.sklearn.preprocessing.PowerTransformer: sklearn's power transforms.
Source Code¶
Show/Hide source
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 | |
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¶
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.