LogTransformer¶
yohou.stationarity.transformers.LogTransformer
¶
Bases: BoxCoxTransformer
Logarithmic time series transformer.
Applies \(y = \ln(x + \text{offset})\), equivalent to BoxCoxTransformer
with lmbda=0.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
float >= 0.0
|
Offset to apply to the input time series before the log transform. |
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 LogTransformer
>>> X = pl.DataFrame({
... "time": [datetime(2024, 1, i) for i in range(1, 6)],
... "value": [1.0, 4.0, 9.0, 16.0, 25.0],
... })
>>> transformer = LogTransformer(offset=0.0)
>>> transformer.fit(X)
LogTransformer(...)
>>> X_t = transformer.transform(X)
>>> "time" in X_t.columns
True
References¶
[1] Box, G.E.P., & Cox, D.R. (1964). "An analysis of transformations." Journal of the Royal Statistical Society: Series B, 26(2), 211-252.
See Also¶
BoxCoxTransformer: Generalized power transform (parent class).ASinhTransformer: Variance stabilization for data with negatives.SeasonalLogDifferencing: Combined log + seasonal differencing.
Source Code¶
Show/Hide source
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:
-
Decomposition
Data-Features
Chain PolynomialTrendForecaster, PatternSeasonalityForecaster, and FourierSeasonalityForecaster inside DecompositionPipeline with component visualisation.
-
How to Apply Stationarity Transforms
Data-Features
Catalogue of variance-stabilising and detrending transforms: LogTransformer, BoxCox, SeasonalDifferencing, SeasonalReturn, and ASinh with inverse verification.
-
How to Choose a Decomposition Strategy
Forecasting-Models
Build 2- and 3-component DecompositionPipeline forecasters chaining trend, seasonality, and residual models with target pre-transformation.
-
Reduction Forecasting Walkthrough
Getting-Started
Walk through the full fit/predict/evaluate cycle with PointReductionForecaster, cross-validation, and grid search on a real dataset.
-
Quickstart
Quickstart
Comprehensive end-to-end tour of yohou beyond the Getting Started tutorials, covering data loading, baseline forecasting, preprocessing pipelines, decomposition, cross-validation search, and interval prediction.