Module 4 · Core Machinery
Data: Time Series, Features & Cleaning
Models get the glory; data does the work. This module walks through how both papers turn messy real-world measurements — four years of sensor readings, hours of robot video — into clean, well-shaped training input. Examiners adore this territory because it separates people who ran code from people who understood a pipeline.
4.1 Real sensor data is dirty
Paper 1's plant produces thousands of measurements per day: five weather stations logging GHI (global horizontal irradiance, W/m²), ambient temperature, and — at station WS5 only — air pressure, wind direction, wind speed, and humidity; plus power from every one of the 84 inverters and the plant total. At that scale, sensor failure, communication dropouts, and faulty readings are not risks — they are certainties. The paper treats missing and faulty entries as a fact of life to be engineered around, not an inconvenience to be ignored.
Garbage in, garbage out
A neural network has no notion of "that reading looks wrong." It will faithfully learn from a 1600 W/m² irradiance spike or a curtailed output plateau as if they were physics. Every downstream result — every NRMSE in Paper 1's tables — silently rests on the quality of this stage.
Paper 1 organizes the journey from sensor to model as a three-stage pipeline:
Stage 1 · Raw capture→
Stage 2 · Cleaning→
Stage 3 · Pre-processing→
Model input
Stage 1 just records everything. Stage 2 (Section 4.2) repairs and removes. Stage 3 (Sections 4.3–4.4) reshapes clean data into features a model can learn from.
4.2 Cleaning: eliminate, interpolate, impute
Stage 2 has exactly three operations, and you should be able to name and distinguish all three:
- Elimination — delete what is clearly wrong. Paper 1's examples: GHI readings of 1600 W/m² (physically implausible), temperatures of 50 °C, and single sensors deviating wildly from the norm of the other stations. It also eliminates curtailment periods — stretches where the plant's output was purposefully limited (e.g. on grid-operator instruction). Curtailed output is real data but not natural plant behaviour; leaving it in would teach the model that sunny skies sometimes produce capped power for no visible reason.
- Interpolation — fill short gaps, at most 1 hour, by drawing smooth values between the known endpoints. The 1-hour cap is deliberate: interpolating longer gaps would alter the character of the signal, inventing smooth weather where a storm might have passed.
- Imputation — repair long gaps, from hours up to weeks, using other sources of truth: the multi-station weather network (if WS2 died, its neighbours kept measuring the same sky), and — for missing inverter power — substituting data from inverters with similar output dynamics.
A quiet elegance
Notice the imputation trick: some inverters behave alike, so one can stand in for another. That is the same insight Paper 1 later formalizes as inverter clustering by Euclidean distance (Module 8). Similarity between inverters is doing useful work in this paper before any clustering algorithm is ever named — a lovely connection to volunteer in the exam.
Cleaning choices are modelling choices
Every elimination rule embeds an assumption about what "normal" looks like. An examiner may push: could aggressive elimination bias the results? Yes — if you delete every extreme reading, the model never sees genuinely extreme (but real) conditions, and the reported accuracy describes a politer world than the one the plant lives in. The defensible answer: eliminate only the physically impossible and the artificially manipulated (curtailment), interpolate conservatively, and impute from independent evidence — which is precisely the discipline Paper 1 follows.
4.3 Feature engineering: giving the model what it can't compute
Stage 3 begins with a beautiful idea. The sun's position in the sky is deterministic astronomy: for any future instant, the solar Altitude β (height above the horizon) and Azimuth Φ (compass bearing) can be computed exactly — Paper 1 uses the pvlib-solarposition library. So the model is handed, as input, the exact sun position for every forecast moment:
(βt+1, Φt+1), (βt+2, Φt+2), …, (βt+21, Φt+21)
This is future information used legitimately: unlike future cloud cover, which is unknowable without a weather service, future sun angles are pure calculation. A pleasant side effect: once the model knows exactly where the sun will be, a separate hour-of-day feature becomes unnecessary — the angles already encode the time.
Two more Stage-3 moves you met in Module 1 now earn their place in the pipeline:
- One-hot encoding of wind direction (4 entries: N/E/S/W) and month (12 entries). Cyclical variables lie when written as numbers: 359° and 0° are the same wind, December and January are neighbouring months, but numerically they sit at opposite ends of the scale. One-hot removes the false ordering.
- Normalization of all inputs (with forecasts de-normalized back to megawatts afterwards) — chiefly for computational speed: features on wildly different scales make gradient descent slow and lopsided.
4.4 Resolution and sliding windows
The plant logs at 1-minute intervals, but Paper 1 averages this down to 5-minute resolution. Counter-intuitive but wise: minute-level wiggles add unnecessary uncertainty — noise without repeatable pattern — while 5-minute data keeps every dynamic that matters for 15-minute-step forecasts.
The model's input is then a sliding window of recent history: the last 1, 2, 3, 6, or 24 hours of feature vectors, tried as hyperparameter options. Plus one clever extra:
The HISIMI+x window
HIstoric SIMIlarity: take yesterday's data from the exact same time-of-day span you are now forecasting (a 5-hour segment from 24 h ago), and staple it to a normal sliding window of the most recent x hours. Rationale: solar power has strong daily seasonality — the plant's behaviour at 2 pm today probably resembles 2 pm yesterday. HISIMI hands the model that resemblance directly instead of hoping it discovers it.
Window length was searched per model, and the winners are telling: FFNN 1 h, LSTM 3 h, GRU 6 h. The recurrent models prospered with longer histories — they digest a sequence step by step and can prioritise within it without being overwhelmed by input size, whereas the FFNN, which swallows the whole window as one flat vector, did best keeping that vector small. This observation is exam gold; Module 5 builds on it.
4.5 Feature selection by experiment, not correlation
Which features actually help? The standard textbook answer is to compute Pearson or Spearman correlation between each candidate feature and the target, and keep the strong ones. Paper 1 explicitly declines, for a sharp reason: pairwise correlation cannot reveal feature-combination effects. A feature that looks weak alone may be valuable alongside another; a feature that correlates well may add nothing a better feature hasn't already supplied.
Instead, features were added progressively, in combinations, during the grid search — measure the model with feature set A, then A+B, then A+B+C — letting forecast accuracy itself be the judge. The verdict:
| Feature | Effect on accuracy |
| Historic power output | Essential — the backbone |
| GHI (irradiance) | Strong improvement |
| Ambient temperature | Improvement — completes the best trio |
| Wind speed, air pressure | Also helped |
| Wind direction, humidity | Reduced accuracy |
More features is not automatically better
Wind direction and humidity carry some physical information — yet including them hurt, because the extra model complexity outweighed the information gained. Every added input is more weights to fit and more ways to overfit. Feature selection is subtraction as much as addition.
4.6 Vision data: from video to training pairs
Paper 2 faces the same "raw world → model input" problem in a different medium. Its pipeline:
Motor babbling video→
Encoder-verified frames→
Colour segmentation→
Binary silhouette + joint angles
- Motor babbling, disciplined. The robot performs random trajectories, but the action space is discretized at 9° intervals, and a feedback loop with the joint encoders guarantees data quality: a frame is saved only when every joint is within 0.5° of its commanded target, and a movement that fails to progress within 1 second is flagged as halting (e.g. a collision) and handled. Each saved frame is thus a verified (image, joint-angle) pair — the labels come free from the robot's own encoders.
- 12,000 data points: 10,000 for training/validation (split 8:2) and 2,000 held out for testing. Each image is RGB, resized to 100×100.
- Colour-based segmentation to binary silhouettes. The arm is painted black and blue against a clean, uniform background. The background is isolated by taking median pixel values across many images — since the robot is the only moving element, each pixel's median over time is simply the background. Then RGB thresholds (0.15 for the body, 0.4 blue for the end effector) produce binary images, with pixel values normalized to [0, 1].
Why is a flat binary silhouette enough to supervise a 3D self-model? Because the model sees thousands of silhouettes across varied poses. Any single 2D outline is ambiguous, but only the correct 3D shape is consistent with all of them at once — the same principle by which many 2D X-ray angles determine a 3D CT volume. (Module 6 makes this precise.)
Same discipline, different sensor
Compare with Paper 1: both papers refuse to trust raw capture. The solar paper validates sensor readings against neighbouring stations; the robot paper validates frames against joint encoders and strips away everything but the signal (the silhouette). Data curation is the method, in both worlds.
4.7 Class imbalance in pixels
One last trap. In a 100×100 silhouette, the robot arm occupies a small fraction of the frame — the overwhelming majority of pixels are black (empty). A model minimizing average pixel error can therefore score deceptively well with a degenerate strategy: predict every pixel black. Paper 2's model initially fell into exactly this local optimum, producing all-black images.
Two mitigations, both worth naming precisely:
- Early abort and restart: if the model is predicting only black images early in training, abandon that run and restart (new random initialization) rather than waste epochs in a dead end.
- Central focus: for the first 200 iterations, concentrate the loss on the central 50×50 region — where the robot actually is — so the arm's pixels, not the empty border, dominate the early gradient signal.
The same beast everywhere
Class imbalance wears many costumes: rare diseases among healthy patients, fraudulent transactions among honest ones, a few white pixels in a black frame, a handful of storm days in years of sunshine. The degenerate solution is always "predict the majority", and the remedy is always some form of reweighting or refocusing attention on the minority — by loss weighting, resampling, or, as here, by cropping the loss to where the minority lives.
Exam warm-up — say it out loud
- Why does Paper 1 interpolate only gaps shorter than an hour, and what does it do with longer gaps?
- Why are future solar angles legitimate model inputs while future cloud cover is not?
- Adding humidity as a feature made Paper 1's forecasts worse. How is that possible?
- Explain Paper 2's black-image problem and both fixes, as if to a fellow student who hasn't read the paper.
Module 4 Quiz
10 questions on pipelines, cleaning, features, and imbalance.