Module 2 · Foundations
Machine Learning Basics
Both papers are, at heart, supervised regression projects: gather (input, target) pairs, choose a loss, descend its gradient, split the data honestly, and measure the error in a way that means something. This module builds exactly that vocabulary.
2.1 What "learning from data" means
Classical programming: a human writes the rules, the computer applies them to data. Machine learning flips this: you supply examples of inputs paired with the answers you want, and the computer finds the rules itself. In supervised learning — the setting of both papers — the dataset is a collection of (input, target) pairs. The input's individual measurements are called features (power, irradiance, temperature; or a 3D point plus joint angles), and the value to be predicted is the target (future power; a point's occupancy).
The model starts as a flexible function with adjustable parameters. "Learning" means adjusting those parameters until the model's outputs match the targets on the examples — and, crucially, on new examples it never saw.
Where the papers use this
Paper 1's examples: a sliding window of recent plant measurements in, the next 21 power values as targets. Paper 2's examples: a 3D point and joint angles in, with the target supplied by camera pixels — is that part of space occupied by the robot? Neither project contains a single hand-written forecasting or kinematics rule.
2.2 Regression vs classification
Classification predicts a category: spam / not spam, cat / dog. Regression predicts a continuous number: a temperature, a price, a power output. The distinction matters because it dictates the loss functions and the metrics you can use. Both papers are regression: Paper 1 predicts power values in kW; Paper 2 predicts a density (occupancy) and visibility for each queried 3D point — continuous values trained through pixel intensities.
One refinement is essential exam vocabulary. Paper 1 needs 21 future values per forecast. It could train a single-target model and run it 21 times (or train 21 separate models) — or use multi-target regression (MTR): one model whose output layer emits all 21 values in a single run.
Why MTR, and why now
Paper 1 uses MTR: one model, one forward pass, all 21 forecast steps at once. Classical statistical methods handled multi-step forecasting awkwardly, but a neural network's output layer can simply have 21 units — deep learning made MTR natural and cheap. Bonus: the shared hidden layers let all 21 horizons learn from the same internal representation of the plant's recent behaviour.
2.3 Loss functions for regression
The loss function scores how wrong the model currently is; training minimizes it. The three standard regression losses differ in how hard they punish large errors:
- MAE (mean absolute error): average of |error| — every kW of error costs the same.
- MSE (mean squared error): average of error² — a doubled error costs four times as much.
- Huber: a compromise — quadratic for small errors, linear for large ones (robust to outliers).
Micro-example: the outlier takes over
Errors (1, 1, 10). MAE = (1 + 1 + 10)/3 = 4. MSE = (1 + 1 + 100)/3 = 34. Under MSE the single large error contributes 100 of the 102 total — squaring makes the model obsess over avoiding big misses, at the price of tolerating many small ones.
Both papers pick MSE — one on purpose, one by convention
Paper 1 chooses MSE deliberately: a large out-of-phase forecast error means grid stress and financial loss, so a loss that punishes large errors aggressively matches the real-world cost structure better than MAE or Huber. Paper 2's loss is also an MSE — averaged over pixels: L = (1/WH)ΣΣ(Predij − GTij)², comparing the rendered predicted silhouette to the binary segmented 100×100 camera image.
2.4 Gradient descent and the learning rate
How do we actually minimize the loss? Module 1's downhill rule, applied over and over:
w ← w − η ∇L
Computing the gradient on the entire dataset per step is slow, so in practice we use mini-batches: small random chunks (e.g. 32 or 64 examples) whose gradient approximates the full one — this is stochastic gradient descent (SGD). One full pass through the training data is an epoch; training runs for many epochs.
The learning rate η sets the step size. Too big: the weights overshoot the valley and the loss bounces or explodes. Too small: training crawls and may stall in a mediocre spot. Both papers sidestep hand-tuning it by using Adam with learning rate 10−4 — an optimizer that adapts step sizes per parameter (Module 3 explains how).
2.5 Splitting data honestly
A model must be judged on data it never trained on. The standard three-way split:
- Training set — the examples gradient descent actually learns from.
- Validation set — untouched by training; used to compare hyperparameter choices and decide when to stop.
- Test set — touched exactly once, at the very end, to report final performance.
For time series the split must be chronological. Paper 1 takes 4 years (2015-06-01 to 2019-05-31) and splits them 2 years train / 1 year validation / 1 year test, in calendar order. Shuffling would scatter, say, Tuesday afternoon into training and Tuesday morning into test — the model would effectively see the future, and the measured accuracy would be a lie. Paper 2's data isn't a forecast, so ordering matters less: of 12,000 frame/joint-angle pairs from motor babbling, 10,000 are split 8:2 into train and validation, with 2,000 held out as test.
The cardinal sin: test-set leakage
Any information flowing from the test set into training or model selection — tuning hyperparameters against test scores, normalizing with statistics computed on all the data, shuffling time series — inflates reported performance and invalidates the study. Examiners probe this constantly: be ready to explain why each paper's split is leak-free.
2.6 Overfitting and underfitting
Underfitting: the model is too simple (or undertrained) to capture the pattern — high error everywhere. Overfitting: the model is so flexible it memorizes the training examples, noise and all, instead of generalizing. The tell-tale symptom: training loss keeps falling while validation loss rises — the model is getting better at the past and worse at the future.
Remedies (previewed here, detailed in Module 3): stop training when validation loss stops improving (early stopping), gather more data, or constrain the model (regularization, e.g. dropout).
Overfitting, time-series edition
For forecasting, overfitting has a sneakier face: a model can fit one particular year's weather quirks — an unusually cloudy March, one heat wave — and then stumble on the different weather of the validation and test years. This is one reason Paper 1 insists on full-year validation and test sets: every season appears in each split.
2.7 Measuring forecast error: NRMSE, MAE, MAPE
The loss trains the model; evaluation metrics tell humans how good it is. Paper 1 reports three, each answering a different question. With P̂i the forecast, Pi the actual power, and Pcap the plant's rated capacity:
NRMSE = √( (1/N) Σ ( (P̂i − Pi) / Pcap )² ) · 100%
MAE = (1/N) Σ |P̂i − Pi|
MAPE = (1/N) Σ |P̂i − Pi|Pcap · 100%
- NRMSE squares errors before averaging, so — like MSE — it punishes large errors hardest. Paper 1 uses it as the model-selection criterion for exactly that reason.
- MAE stays in physical units: a MAE of 750 kW means the forecast is off by 750 kW on a typical interval. Directly interpretable, no squaring drama.
- MAPE expresses the average error as a percentage of plant capacity: instant context for any reader, on any plant size.
Why divide by capacity at all? Normalising by Pcap keeps a real-world perspective — "8% of a 75 MW plant" is meaningful and comparable across plants, whereas raw kW errors are not. (Normalising by the actual power instead would explode near sunrise/sunset when power is tiny.)
Calibrate your intuition with Paper 1's numbers
Best macro NRMSE: GRU 8.12%, FFNN 8.19%, LSTM 8.23% — a tight race. Difficulty tracks weather: clear days come in around 3% NRMSE (roughly 1.5–1.8% MAPE), overcast days around 14–15% NRMSE (roughly 8% MAPE). If an examiner asks "is 8% good?", the honest answer is: it depends almost entirely on the weather mix.
Exam warm-up — say it out loud
- Why does Paper 1 train with MSE rather than MAE? Tie your answer to the grid.
- What is multi-target regression, and what would the alternative to Paper 1's 21-output model look like?
- Why is a chronological split non-negotiable for time series, and what exactly goes wrong with shuffling?
- You're given NRMSE, MAE, and MAPE for a forecast model. What distinct question does each one answer?
Module 2 Quiz
10 questions. Loss functions, splits, and metrics are guaranteed oral-exam territory.