Model Pipeline - Time series components (trend, seasonality)
This pipeline breaks down a time series into its main parts: trend and seasonality. It helps us understand how data changes over time and repeats in patterns.
Jump into concepts and practice - no test required
This pipeline breaks down a time series into its main parts: trend and seasonality. It helps us understand how data changes over time and repeats in patterns.
Loss
0.5 |****
0.4 |***
0.3 |**
0.2 |*
0.1 |
+----
1 5 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.45 | N/A | Initial decomposition with high error in residuals |
| 2 | 0.30 | N/A | Trend smoothing improved, residuals smaller |
| 3 | 0.20 | N/A | Seasonality captured better, residual noise reduced |
| 4 | 0.15 | N/A | Stable decomposition, residuals close to random noise |
| 5 | 0.12 | N/A | Final model captures trend and seasonality well |
seasonal?
import pandas as pd
import numpy as np
index = pd.date_range('2023-01-01', periods=12, freq='M')
data = np.sin(np.linspace(0, 2 * np.pi, 12))
df = pd.Series(data, index=index)
seasonal = df.groupby(df.index.month).transform('mean')trend = df['value'].rolling(window=3).mean()But the output has many NaN values at the start. How can you fix this?