🔀 SeriesDecomposition
🔀 SeriesDecomposition
🟡 Intermediate
✅ Stable
⏱️ Time Series
🎯 Overview
The SeriesDecomposition layer decomposes time series into trend and seasonal components using moving average. This is a fundamental technique in time series analysis that separates long-term trends from recurring patterns.
The layer: - Extracts Trend: Using moving average smoothing - Captures Seasonality: As residual after trend removal - Preserves Information: No information loss in decomposition - Enables Hierarchical Analysis: Process components separately
🔍 How It Works
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
The trend is computed using a moving average filter, preserving temporal length through edge padding.
💡 Why Use This Layer?
| Problem | Solution |
|---|---|
| Mixed Patterns | Separate trend and seasonality |
| Noisy Data | Trend extraction via smoothing |
| Pattern Analysis | Analyze components independently |
| Forecasting | Model trend and seasonal separately |
📊 Use Cases
- Classical Time Series Analysis: Traditional decomposition
- Trend Forecasting: Separate trend prediction
- Seasonal Adjustment: Remove seasonality for analysis
- Anomaly Detection: Decompose before detection
- Feature Engineering: Use components as features
🚀 Quick Start
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
🔧 API Reference
1 2 3 4 5 | |
Parameters
| Parameter | Type | Description |
|---|---|---|
kernel_size |
int |
Moving average window size |
name |
str \| None |
Optional layer name |
Returns
Tuple of (seasonal, trend) tensors with same shape as input.
💡 Best Practices
- Kernel Size: Choose based on seasonality frequency
- Daily data: kernel_size=7 (weekly pattern)
- Monthly data: kernel_size=12 (annual pattern)
- Edge Handling: Automatically paddles edges to preserve length
- Multiple Scales: Apply recursively for hierarchical decomposition
- Information Preservation: Guaranteed: seasonal + trend = original
⚠️ Common Pitfalls
- ❌ Small kernel_size: Misses true trends
- ❌ Large kernel_size: Removes important patterns
- ❌ Wrong frequency: Choose kernel based on domain knowledge
- ❌ Assuming perfect reconstruction: Numerical precision limits
📚 References
- Classical time series decomposition (Additive/Multiplicative)
- Cleveland et al. (1990). "STL: A Seasonal-Trend Decomposition"
- Hyndman & Athanasopoulos. "Forecasting: Principles and Practice"
🔗 Related Layers
DFTSeriesDecomposition- Frequency-based decompositionMovingAverage- Trend extraction componentMultiScaleSeasonMixing- Process seasonal components
Last Updated: 2025-11-04 | Keras: 3.0+ | Status: ✅ Production Ready