0
0
ML Pythonml~8 mins

Time series components (trend, seasonality) in ML Python - Model Metrics & Evaluation

Choose your learning style9 modes available
Metrics & Evaluation - Time series components (trend, seasonality)
Which metric matters for this concept and WHY

For time series components like trend and seasonality, the key metric is Mean Absolute Error (MAE) or Root Mean Squared Error (RMSE). These metrics measure how close our model's predictions are to actual values over time.

We focus on these because time series data changes over time, and we want to capture patterns like upward trends or repeating seasonal effects accurately.

Confusion matrix or equivalent visualization (ASCII)
Actual Values:      100, 120, 130, 150, 170, 160, 140, 130
Predicted Values:   105, 118, 128, 155, 165, 158, 138, 135

Error (Actual - Predicted): -5, 2, 2, -5, 5, 2, 2, -5

MAE = (|−5| + |2| + |2| + |−5| + |5| + |2| + |2| + |−5|) / 8 = 3.375
RMSE = sqrt((25 + 4 + 4 + 25 + 25 + 4 + 4 + 25) / 8) ≈ 4.33
    

This shows how well the model captures trend and seasonality by measuring prediction errors.

Precision vs Recall (or equivalent tradeoff) with concrete examples

In time series, instead of precision and recall, we balance bias and variance.

  • High bias (underfitting): Model misses trend or seasonality, so errors are large and consistent.
  • High variance (overfitting): Model fits noise, causing errors to vary wildly on new data.

Example: A sales forecast model that ignores holiday seasonality (high bias) will miss sales spikes. A model that fits every small fluctuation (high variance) will fail to predict future sales well.

What "good" vs "bad" metric values look like for this use case

Good: Low MAE and RMSE values close to zero, meaning predictions closely follow actual data including trend and seasonality.

Bad: High MAE and RMSE values, indicating the model misses important patterns like steady growth or repeating seasonal peaks.

For example, if monthly sales range from 100 to 200, an MAE of 5 is good, but an MAE of 50 is bad.

Metrics pitfalls (accuracy paradox, data leakage, overfitting indicators)
  • Ignoring seasonality: Leads to systematic errors during seasonal peaks or drops.
  • Data leakage: Using future data to train the model inflates performance metrics falsely.
  • Overfitting: Very low training error but high error on new data means the model learned noise, not true patterns.
  • Accuracy paradox: High overall accuracy can hide poor performance during important seasonal events.
Self-check

Your time series model has an MAE of 2 on training data but 20 on new data. Is it good? Why or why not?

Answer: No, this shows overfitting. The model fits training data well but fails to generalize to new data, missing true trend or seasonality patterns.

Key Result
Mean Absolute Error (MAE) and Root Mean Squared Error (RMSE) best measure how well a model captures trend and seasonality in time series.