feat: add UCM (Unobserved Components Model) support#1081
feat: add UCM (Unobserved Components Model) support#1081formeo wants to merge 11 commits intoNixtla:mainfrom
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for Unobserved Components Models (UCM), also known as Structural Time Series Models, by wrapping statsmodels' UnobservedComponents class to conform to the statsforecast API. UCM decomposes time series into interpretable components (level, trend, seasonal, cycle, irregular) using state-space methods and the Kalman filter.
Changes:
- Added new UCM implementation module with full model class and convenience subclasses
- Integrated UCM classes into statsforecast's model registry
- Added comprehensive test suite covering all UCM functionality
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 15 comments.
| File | Description |
|---|---|
| python/statsforecast/ucm.py | New module implementing UCM wrapper with base class and convenience subclasses (LocalLevel, LocalLinearTrend, SmoothTrend) |
| python/statsforecast/models.py | Updated exports to include new UCM model classes |
| tests/test_ucm.py | Comprehensive test suite covering UCM functionality including fit/predict, seasonality, prediction intervals, components, exogenous variables, and StatsForecast integration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @formeo thank you for your contribution. Please double check the import paths, as shown above. |
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Feature: Add UCM (Unobserved Components Model) Support
Closes #1012
Summary
This PR adds support for Unobserved Components Models (UCM), also known as Structural Time Series Models. UCM is a well-known and proven forecasting approach that decomposes time series into interpretable components.
What is UCM?
UCM (Harvey, 1989) decomposes a time series into:
This is similar to classical decomposition but uses state-space methods and the Kalman filter, allowing for:
Implementation
This PR adds a wrapper around
statsmodels.tsa.statespace.structural.UnobservedComponentsthat follows the statsforecast API.New Classes
UCM- Full UCM model with all configuration optionsLocalLevel- Convenience class for random walk modelLocalLinearTrend- Convenience class for level + trend modelSmoothTrend- Convenience class for integrated random walkRandomWalkWithDrift- Convenience class for RW with driftAPI
Features
fit,predict,forecast,predict_in_sample)get_components())Testing
Dependencies
statsmodels(already an optional dependency for some models)Checklist
References