Multilayer Perceptrons for Time Series
You'll learn how to adapt MLPs—the feedforward neural networks you know—to forecasting problems using sliding windows of past observations.
From Classical to Neural: The Input Challenge
Classical methods like ARIMA work directly with time-ordered sequences. MLPs, however, expect fixed-size feature vectors—they don't inherently "know" about time. The solution? Transform your time series into a supervised learning problem using sliding windows.
How Sliding Windows Work
Think of forecasting like looking through a moving window at the past to predict the future. You choose a window size (e.g., the last 7 days) and create training samples where:
- Input (X): Past values at lags 1, 2, 3... up to your window size
- Target (y): The value you want to predict (e.g., tomorrow's value)
For example, with a 3-step window forecasting one step ahead:
- Sample 1: [value_t-3, value_t-2, value_t-1] → value_t
- Sample 2: [value_t-2, value_t-1, value_t] → value_t+1
- Sample 3: [value_t-1, value_t, value_t+1] → value_t+2
Building the MLP Architecture
Your MLP takes these lagged features as input nodes. A typical architecture:
- Input layer: One node per lag feature (window size determines this)
- Hidden layers: One or more dense layers with nonlinear activations
- Output layer: One node for single-step forecasts, or multiple for multi-step
You can enrich inputs beyond raw lags: add rolling statistics, time-based features (day-of-week, month), or other engineered features you've already learned.
The Key Advantage
MLPs can capture nonlinear patterns that classical linear models miss, and they naturally handle multiple input features—not just past values of the target variable.
Key Takeaway: MLPs forecast time series by converting them into fixed-size windows of lagged features, treating forecasting as a supervised regression problem where past observations become predictors.