PointReductionForecaster¶
yohou.point.reduction.PointReductionForecaster
¶
Bases: BaseReductionForecaster, BasePointForecaster
Point forecaster using sklearn estimators on tabularized time series.
Converts the time series point forecasting task to a tabular one.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
estimator
|
BaseEstimator
|
Point estimator used to fit the tabularized data. |
LinearRegression()
|
reduction_strategy
|
(direct, dir - rec, multi - output)
|
Strategy for multi-step forecasting. |
"direct"
|
target_transformer
|
BaseTransformer or None
|
Transformer for target preprocessing. |
None
|
feature_transformer
|
BaseTransformer or None
|
Transformer for feature engineering (typically LagTransformer). |
None
|
target_as_feature
|
(transformed, raw)
|
Whether to include the target variable as a feature for reduction.
If |
"transformed"
|
panel_strategy
|
('global', multivariate)
|
How to handle panel data. See |
"global"
|
nan_handling
|
(drop, 'pass')
|
How to handle NaN values in tabularized data.
|
"drop"
|
n_jobs
|
int or None
|
Number of jobs to run in parallel for the |
None
|
step_feature_alignment
|
(all, matched, cumulative)
|
Controls which step-indexed feature columns each direct estimator
sees. Only affects the
|
"all"
|
Examples¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.point import PointReductionForecaster
>>>
>>> # Create simple time series data
>>> df = pl.DataFrame({
... "time": pl.datetime_range(
... start=datetime(2021, 1, 1), end=datetime(2021, 1, 10), interval="1d", eager=True
... ),
... "value": [10.0, 12.0, 15.0, 14.0, 16.0, 18.0, 20.0, 19.0, 21.0, 23.0],
... })
>>>
>>> # Split into train/test
>>> train = df[:8]
>>>
>>> # Create and fit forecaster
>>> forecaster = PointReductionForecaster()
>>> _ = forecaster.fit(y=train, forecasting_horizon=1)
>>>
>>> # Generate one-step prediction
>>> y_pred = forecaster.predict(forecasting_horizon=1)
>>> len(y_pred)
1
>>> sorted(y_pred.columns)
['time', 'value', 'vintage_time']
Notes¶
Reduction strategies:
- Multi-output: A single model predicts all H horizon steps simultaneously. Simple and fast, but assumes the same model structure is appropriate for every step.
- Direct: H independent models, one per horizon step. Each model specialises in its own step, avoiding error accumulation from recursive prediction but ignoring inter-step dependencies.
- Dir-Rec (direct-recursive hybrid): H models are fitted sequentially. Model h predicts step h using the original features augmented with in-sample predictions from models 1 to h-1. This combines the specialised per-step training of the direct strategy with inter-step information flow.
For direct and dir-rec strategies, estimator_ becomes a
list[BaseEstimator] of length H (one per horizon step) instead
of a single estimator.
All strategies can be applied recursively for multi-step forecasting beyond the fit horizon by specifying a larger forecasting horizon during prediction.
See Also¶
BaseReductionForecaster: Base class for reduction forecasters.LagTransformer: Create lagged features for reduction strategies.
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
Methods¶
fit(y, X_actual=None, forecasting_horizon=1, time_weight=None, vintage_weight=None, sample_weight_alignment='first_step', X_future=None, X_forecast=None, **params)
¶
Fit the forecaster to historical data.
Tabularizes the time series and fits the wrapped sklearn estimator.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
y
|
DataFrame
|
Target time series with a |
required |
X_actual
|
DataFrame or None
|
Actual feature observations with a |
None
|
forecasting_horizon
|
int
|
Number of time steps to forecast into the future. |
1
|
time_weight
|
callable, pl.DataFrame, dict, or None
|
Per-timestep weights for fitting. Accepts a callable
|
None
|
vintage_weight
|
callable, pl.DataFrame, dict, or None
|
Per-vintage weights for fitting. Same formats as
|
None
|
sample_weight_alignment
|
str
|
Strategy for converting |
"first_step"
|
X_future
|
DataFrame or None
|
Known future features with a |
None
|
X_forecast
|
DataFrame or None
|
External forecasts with |
None
|
**params
|
dict
|
Metadata to route to nested estimators. |
{}
|
Returns¶
| Type | Description |
|---|---|
self
|
The fitted forecaster instance. |
Source Code¶
Show/Hide source
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
Tutorials¶
The following example notebooks use this component:
-
How to Use ColumnTransformer
Data-Features
Route columns through distinct transformers with ColumnTransformer, including remainder handling and automatic panel-aware column detection.
-
Decomposition
Data-Features
Chain PolynomialTrendForecaster, PatternSeasonalityForecaster, and FourierSeasonalityForecaster inside DecompositionPipeline with component visualisation.
-
How to Compose Features with FeatureUnion
Data-Features
Combine lag features, rolling statistics, EMA, and scaling in parallel with FeatureUnion and automatic observation horizon resolution.
-
How to Tune Fourier Seasonality Terms
Data-Features
Explore how Fourier harmonic count affects seasonal fit quality, compare Fourier vs Pattern seasonality, and tune harmonics jointly with GridSearchCV.
-
How to Wrap Functions as Transformers
Data-Features
Wrap arbitrary polars or numpy operations as sklearn transformers with FunctionTransformer, supporting stateful warmup, inverse transforms, and pipelines.
-
How to Handle Short Series
Data-Features
Use Fourier seasonality, simple train/test splits, and panel pooling when individual series are too short for standard approaches.
-
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 Use Scikit-learn Scalers
Data-Features
Wrap sklearn scalers (StandardScaler, MinMaxScaler, RobustScaler, PowerTransformer, PolynomialFeatures) for polars DataFrames with inverse transforms.
-
How to Align Exogenous Features Across Pipeline Steps
Data-Features
Control which step-indexed columns each direct-strategy estimator sees using the step_feature_alignment parameter of PointReductionForecaster.
-
How to Aggregate Scorer Results
Evaluation-Search
Demonstrate all scorer aggregation strategies (stepwise, vintagewise, componentwise, groupwise, coveragewise, all) on panel data with weighted group aggregation.
-
How to Create a Custom Scorer
Evaluation-Search
Implement a custom point scorer with aggregation, panel support, and systematic testing.
-
How to Run Hyperparameter Search
Evaluation-Search
Tune forecaster hyperparameters with GridSearchCV and RandomizedSearchCV using temporal cross-validation splitters and result scatter visualisation.
-
How to Search Interval Forecaster Hyperparameters
Evaluation-Search
Tune interval forecaster parameters directly with interval metrics in GridSearchCV, including mixed point+interval multimetric search.
-
How to Score Multi-Vintage Forecasts
Evaluation-Search
Generate multi-vintage predictions with observe_predict, score per step and per vintage, and visualize with heatmap, per-step, and per-vintage plots.
-
How to Use Point Forecast Metrics
Evaluation-Search
Compare MAE, MAPE, MASE, RMSE, and other point metrics across multiple forecasters with componentwise and groupwise aggregation.
-
How to Forecast with CatBoost
Forecasting-Models
Plug CatBoostRegressor into PointReductionForecaster as a drop-in sklearn estimator, compare gradient-boosted versus Ridge linear baseline, and demonstrate the direct reduction strategy with tree-based models.
-
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 Use Distance-Based Similarity for Intervals
Forecasting-Models
Adaptive prediction intervals via similarity-weighted conformal prediction using DistanceSimilarity with configurable distance metrics and bandwidths.
-
How to Build a Lag-Feature Forecaster
Forecasting-Models
Chain feature and target forecasters with ForecastedFeatureForecaster when exogenous variables are unknown at prediction time and must be forecasted.
-
How to Use Lagged Forecasts as Features
Forecasting-Models
Compare ForecastedFeatureForecaster strategies (actual, predicted, rewind) and split ratio tuning for chaining feature and target forecasters.
-
How to Produce Multi-Vintage Predictions
Forecasting-Models
Generate multiple predictions from different weather forecast vintages without refitting, using the X_forecast predict-time override.
-
How to Apply Time-Weighted Training
Forecasting-Models
Use time_weight and sample_weight_alignment to emphasise recent or seasonal training samples in PointReductionForecaster, with visualisation of weight curves and alignment strategy comparison.
-
How to Combine Interval Forecasters
Forecasting-Models
Build interval ensembles with VotingIntervalForecaster using envelope, mean, and median aggregation strategies.
-
How to Combine Forecasters with VotingPointForecaster
Forecasting-Models
Build point ensembles with VotingPointForecaster using mean, weighted, and median aggregation strategies.
-
How to Choose a Forecasting Method
Getting-Started
Interactive decision guide progressing from SeasonalNaive baseline through linear reduction, stationarity transforms, feature enrichment, nonlinear models, decomposition, and prediction intervals.
-
Conformal Prediction Intervals
Getting-Started
Build distribution-free prediction intervals with SplitConformalForecaster using calibration holdouts and configurable conformity scoring functions.
-
How to Create a Custom Transformer
Getting-Started
Implement a ScaleTransformer from scratch, validate it with the check generator, and use it in a forecast pipeline.
-
Exogenous Features (X_actual, X_future, X_forecast)
Getting-Started
Build a forecasting model with actual observations, known-future indicators, and multi-vintage external forecasts on synthetic electricity price data.
-
Forecasting Workflow
Getting-Started
Evaluate forecasters with cross-validation, search hyperparameters with GridSearchCV, and inspect residuals to diagnose model weaknesses.
-
Interval Forecasting
Getting-Started
Wrap a point forecaster with SplitConformalForecaster to produce 95% prediction intervals with statistical coverage guarantees.
-
Observe-Predict Workflow
Getting-Started
Walk through a test set in batches, updating forecasts as new data arrives with observe_predict.
-
Reduction Forecasting Walkthrough
Getting-Started
Walk through the full fit/predict/evaluate cycle with PointReductionForecaster, cross-validation, and grid search on a real dataset.
-
Direct, Recursive, and MIMO Strategies
Getting-Started
Compare direct, recursive, and MIMO reduction strategies across forecasting horizons to understand the trade-offs for your use case.
-
How to Save and Load Forecasters
Getting-Started
Serialize fitted forecasters with joblib and pickle, reload them in a fresh session, and produce predictions without retraining.
-
How to Configure LocalPanelForecaster
Panel-Data
Wrap any forecaster with LocalPanelForecaster for fully independent per-group clones, parallel fitting via n_jobs, and selective group operations.
-
How to Forecast Multiple Columns Independently
Panel-Data
Use ColumnForecaster to apply a point forecaster independently to each column of a multivariate time series.
-
How to Run Panel Cross-Validation
Panel-Data
Time series cross-validation on panel data with GridSearchCV, selective group observation, rewind operations, and groupwise performance comparison.
-
How to Forecast Panel Prediction Intervals
Panel-Data
Combine conformal and quantile regression intervals on panel data with per-group coverage analysis, calibration plots, and groupwise interval scoring.
-
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.
-
How to Visualize Forecast Evaluation Results
Visualization
Use plot_calibration, plot_score_per_step, and plot_forecast to diagnose forecast accuracy and interval calibration visually.
-
Forecast Visualization
Visualization
Visualise point forecasts from single and multiple models, decomposition pipeline components, and time weight decay functions with interactive Plotly.
-
How to Visualize Forecasts
Visualization
Plot point forecasts, compare multiple models, render prediction interval bands, inspect residual diagnostics, and check interval calibration.