← Course Home Module 4 · Data: Time Series, Features & Cleaning
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.

▶
Audio recap
A ~2-minute spoken summary of this module — great for revision on the go.

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:

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:

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:

FeatureEffect on accuracy
Historic power outputEssential — the backbone
GHI (irradiance)Strong improvement
Ambient temperatureImprovement — completes the best trio
Wind speed, air pressureAlso helped
Wind direction, humidityReduced 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

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:

  1. 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.
  2. 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
  1. Why does Paper 1 interpolate only gaps shorter than an hour, and what does it do with longer gaps?
  2. Why are future solar angles legitimate model inputs while future cloud cover is not?
  3. Adding humidity as a feature made Paper 1's forecasts worse. How is that possible?
  4. 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.

← Previous
Module 3: Neural Networks