SeasonalLogDifferencing¶
yohou.stationarity.transformers.SeasonalLogDifferencing
¶
Bases: SeasonalDifferencing, LogTransformer
Seasonal log differencing time series transformer.
Applies log transform followed by seasonal differencing. This combines variance stabilization with seasonal stationarization.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
seasonality
|
int >= 1
|
Seasonality for the differencing. |
1
|
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). |
log_transform_ |
LogTransformer
|
Fitted log transform component. |
seasonal_diff_transform_ |
SeasonalDifferencing
|
Fitted seasonal differencing component. |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.stationarity import SeasonalLogDifferencing
>>> X = pl.DataFrame({
... "time": [datetime(2024, 1, i) for i in range(1, 6)],
... "value": [1.0, 2.0, 4.0, 8.0, 16.0],
... })
>>> transformer = SeasonalLogDifferencing(seasonality=1)
>>> transformer.fit(X)
SeasonalLogDifferencing(...)
>>> X_t = transformer.transform(X)
>>> "time" in X_t.columns
True
Notes¶
This is equivalent to computing log(x_t + offset) - log(x_{t-s} + offset)
which equals log((x_t + offset) / (x_{t-s} + offset)).
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. [2] Hyndman, R.J., & Athanasopoulos, G. (2021). "Forecasting: principles and practice," 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3. Chapter 9.1.
See Also¶
SeasonalDifferencing: Simple seasonal differencing without log transform.LogTransformer: Log transform without differencing.SeasonalReturn: Percentage returns instead of log differences.
Source Code¶
Show/Hide source
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
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.