PolynomialTrendForecaster¶
yohou.stationarity.trend.PolynomialTrendForecaster
¶
Bases: _BaseTrendForecaster
Forecast using polynomial trend extrapolation with ElasticNet regularization.
Fits a polynomial of specified degree to the historical data using ElasticNet regression and extrapolates into the future. Linear trend is the special case with degree=1.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
degree
|
int
|
Polynomial degree. degree=1 gives linear trend, degree=2 quadratic, etc. Higher degrees can overfit - typically use degree <= 3. |
1
|
estimator
|
RegressorMixin
|
Regression model used to fit polynomial coefficients. |
ElasticNet()
|
target_transformer
|
BaseTransformer
|
Transformer for target variable (e.g., LogTransformer). |
None
|
panel_strategy
|
('global', multivariate)
|
How to handle panel data. See |
"global"
|
Attributes¶
| Name | Type | Description |
|---|---|---|
Fitted sklearn Pipeline with a polynomial feature transformer and the provided |
a clone of the |
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.stationarity import PolynomialTrendForecaster
>>>
>>> # Create time series with linear trend
>>> y = pl.DataFrame({
... "time": pl.datetime_range(
... start=datetime(2020, 1, 1), end=datetime(2020, 12, 31), interval="1d", eager=True
... ),
... "value": range(366),
... })
>>>
>>> # Fit linear trend forecaster
>>> forecaster = PolynomialTrendForecaster(degree=1)
>>> forecaster.fit(y, forecasting_horizon=7)
PolynomialTrendForecaster()
>>>
>>> # Forecast next 7 days
>>> y_pred = forecaster.predict(forecasting_horizon=7)
See Also¶
PatternSeasonalityForecaster: Seasonal pattern extraction for periodic components.FourierSeasonalityForecaster: Fourier-based seasonality estimation.DecompositionPipeline: Combines trend + seasonality + residual forecasters.
Notes¶
- For exponential trends, consider using target_transformer=LogTransformer() with degree=1
- Polynomial trends can overfit - use with caution (typically degree <= 3)
- Time is converted to numeric values (number of intervals since first observation)
References¶
[1] Hyndman, R.J., & Athanasopoulos, G. (2021). "Forecasting: principles and practice," 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3. Chapters 3.2 and 7.4.
Source Code¶
Show/Hide source
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
Tutorials¶
The following example notebooks use this component:
-
Decomposition
Data-Features
Chain PolynomialTrendForecaster, PatternSeasonalityForecaster, and FourierSeasonalityForecaster inside DecompositionPipeline with component visualisation.
-
How to Build a Feature Pipeline
Data-Features
Nest FeaturePipeline, FeatureUnion, and DecompositionPipeline for multi-level feature engineering with trend-season-residual decomposition.
-
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.
-
How to Build Panel Feature Pipelines
Panel-Data
Combine ColumnForecaster, FeaturePipeline, FeatureUnion, and DecompositionPipeline on panel data with per-group scoring on KDD Cup air quality.
-
How to Apply Stationarity to Panel Data
Panel-Data
Apply per-group stationarity transforms on panel data with SeasonalDifferencing, DecompositionPipeline (polynomial trend + pattern seasonality), and residuals.
-
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.
-
Forecast Visualization
Visualization
Visualise point forecasts from single and multiple models, decomposition pipeline components, and time weight decay functions with interactive Plotly.