0
0
ML Pythonml~12 mins

Moving averages in ML Python - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Moving averages

This pipeline uses moving averages to smooth noisy data. It helps the model see clearer trends by averaging recent points before training.

Data Flow - 4 Stages
1Raw data input
1000 rows x 1 columnCollect raw time series data points1000 rows x 1 column
[23, 25, 22, 24, 26, 28, 27, 29, 30, 31, ...]
2Calculate moving average
1000 rows x 1 columnCompute 5-point moving average to smooth data996 rows x 1 column
[24.0, 25.0, 25.4, 26.8, 28.0, 29.0, 29.8, 31.0, 32.0, ...]
3Train/test split
996 rows x 1 columnSplit data into 80% training and 20% testing setsTrain: 796 rows x 1 column, Test: 200 rows x 1 column
Train: [24.0, 25.0, ..., 29.0], Test: [29.8, 31.0, ...]
4Model training
Train: 796 rows x 1 columnTrain simple regression model on smoothed dataTrained model
Model learns trend from moving average values
Training Trace - Epoch by Epoch

Loss
0.15 |*****
0.10 |****
0.07 |***
0.05 |**
0.04 |*
      +---------
       1 2 3 4 5 Epochs
EpochLoss ↓Accuracy ↑Observation
10.150.60Model starts learning, loss is high, accuracy low
20.100.72Loss decreases, accuracy improves
30.070.80Model fits data better, smoother predictions
40.050.85Loss continues to drop, accuracy rises
50.040.88Training converges, good fit on smoothed data
Prediction Trace - 3 Layers
Layer 1: Input raw data sample
Layer 2: Calculate 5-point moving average
Layer 3: Model prediction
Model Quiz - 3 Questions
Test your understanding
What does the moving average step do to the data?
ARandomly changes data values
BRemoves all data points
CSmooths the data by averaging recent points
DSplits data into training and testing sets
Key Insight
Using moving averages helps the model see clearer trends by reducing noise. This smoothing improves training stability and prediction accuracy.