How-to Guides¶
Task-oriented recipes for common Yohou workflows. Each guide assumes you have completed the tutorials and are familiar with the basics.
Setup¶
- Installation: Install Yohou with pip, uv, or conda, including optional extras and development setup.
Forecasting¶
- Choose a Forecasting Method: Pick the right forecaster and reduction strategy for your data.
- Build Reduction Forecasters: Create lag-feature forecasters, combine feature transformers, and choose a reduction strategy.
- Produce Prediction Intervals: Wrap a point forecaster with
SplitConformalForecasterto generate calibrated prediction intervals. - Combine Forecasters with Ensembles: Use voting ensembles to combine multiple forecasters.
- Forecast with CatBoost: Use gradient-boosted trees for point and interval time series forecasting.
- Forecast with Class Probabilities: Predict discrete class labels with calibrated probabilities.
Evaluation & Tuning¶
- Evaluate Forecast Accuracy: Score predictions with point, interval, and classification metrics.
- Evaluate with Multi-vintage Scoring: Generate forecasts from successive observation points and break down errors by vintage and horizon step.
- Tune Forecaster Hyperparameters: Search and tune forecaster hyperparameters with
GridSearchCVandRandomizedSearchCV.
Visualization¶
- Visualize Forecasts: Plot forecast output against actuals using
plot_forecast,plot_residuals, andplot_calibration. - Visualize and Compare Model Scores: Plot per-step accuracy, per-vintage trends, score distributions, and model comparisons.
Data & Features¶
- Work with Panel Data: Handle multiple related time series with the
__column naming convention. - Use Exogenous Features: Incorporate external predictors using X_actual, X_future, and X_forecast.
- Work with Forecast Vintages: Prepare, align, and predict with
X_forecastfeatures from upstream models stamped with an issuance time. - Add Calendar and Time Features: Engineer temporal features like day of week, month, and holidays.
- Use Time Weighting: Apply non-uniform weights to emphasize recent or seasonal observations.
Preprocessing & Pipelines¶
- Use Preprocessing Transformers: Apply
ColumnTransformer,FunctionTransformer, sklearn scalers, and window transformers. - Clean and Resample Time Series: Detect type mismatches, validate value ranges, and change frequency with
DownsamplerandUpsampler. - Compose Feature Pipelines: Build
FeaturePipelinechains, combine branches withFeatureUnion, and compose panel-aware pipelines. - Apply Stationarity Transforms: Remove trends and seasonality with
SeasonalDifferencingandDecompositionPipeline. - Apply Signal Processing: Smooth noise with digital filters and inspect the frequency spectrum.
Production Use¶
- Save and Load Forecasters: Serialize fitted forecasters to disk and reload them for batch scoring or deployment.
- Handle Missing Data: Detect and fill gaps in a time series before they propagate through the pipeline.
- Handle Outliers: Clip or flag outliers and limit their effect on conformal prediction intervals.
- Handle Complex Seasonality: Choose between Fourier terms, nested decomposition, and feature engineering for multi-period seasonality.
- Handle Short Series: Fallback strategies for series too short for seasonal estimation, cross-validation, or scaled metrics.
- Handle Long Series: Limit history with
observation_horizon, weight recent errors, and resample to the right frequency.
Extending¶
- Create a Point Forecaster: Implement a custom point forecaster by subclassing
BasePointForecaster. - Create an Interval Forecaster: Implement a custom interval forecaster by subclassing
BaseIntervalForecaster. - Create a Class-Probability Forecaster: Implement a custom categorical forecaster by subclassing
BaseClassProbaForecaster. - Create a Transformer: Implement a custom time series transformer by subclassing
BaseTransformer. - Create Custom Scorers: Implement a custom evaluation metric by subclassing
BasePointScorerorBaseIntervalScorer. - Contribute to Yohou: Set up a development environment, run tests, and submit changes.