Intro to ML · Time Series II
Core idea

What is the signal telling us?

Match the output contract and evaluation protocol to the operational decision.

From time-series tasks
to learned representations
and foundation models.

Lecture 2 · 90 minutes

What is the signal telling us?
Intro to ML · Time Series II01 / 45
Core idea

Serega has a clever forecaster. Is the pump healthy?

It predicts the next reading accurately.
Does that prove normal operation?

Keep this question open until the final experiment.

Serega has a clever forecaster. Is the pump healthy?
Intro to ML · Time Series II02 / 45
Core idea

Five tasks. Five different outputs

Choose the required output before choosing the model.

Five distinct task outputs: an epoch class, a future forecast, anomaly scores and alarms, state segments, and imputed missing values.
Intro to ML · Time Series II03 / 45
Worked example

Classification: a label for an observed window

One observed epoch → one class. Bandpower + logistic regression; MiniROCKET features or learned EEGNet features.

Classification: a label for an observed window
Intro to ML · Time Series II04 / 45
Worked example

Forecasting: predict values that have not arrived

History → future horizon. Compare every model at the same issuance time and forecast horizon.

Forecasting: predict values that have not arrived
Intro to ML · Time Series II05 / 45
Core idea

Anomaly detection: unusual relative to what?

A score becomes a decision only after thresholding. Define whether the label covers an onset or the entire abnormal state.

Anomaly detection: unusual relative to what?
Intro to ML · Time Series II06 / 45
Pump investigation 5/8 · Scores, decisions and ranking
Worked example

Scores rank; thresholds decide

Intro to ML · Time Series II07 / 45
Worked example

Segmentation: label the timeline, or find its boundaries

State labeling: HMM or temporal CNN. Change-point detection: PELT / ruptures.

Segmentation: label the timeline, or find its boundaries
Intro to ML · Time Series II08 / 45
Worked example

Imputation: what information may cross the gap?

Linear interpolation → Kalman methods → SAITS. Offline filling may use right context; online filling may not.

Imputation: what information may cross the gap?
Intro to ML · Time Series II09 / 45
Core idea

The architecture expresses an assumption

Read the models: TCN · EEGNet · DeepAR · PatchTST · Chronos-2.

The architecture expresses an assumption
Intro to ML · Time Series II10 / 45
Reference detail

A causal TCN grows its field of view

Dilation skips input positions while retaining a local kernel. Future values must stay outside the receptive field.

A causal TCN grows its field of view
Intro to ML · Time Series II11 / 45
Core idea

Memory and attention answer different questions

Both can learn long dependencies; they store and access the available history differently.

Memory and attention answer different questions
Intro to ML · Time Series II12 / 45
Bridge · From pump sensors to EEG
Core idea

EEG: time is only one of the axes

Read a neural time-series model by following its axes and operations.

Same axis-reading skill, different target: one movement label for an observed EEG epoch.

EEG: time is only one of the axes
Intro to ML · Time Series II13 / 45
Worked example

A classical EEG pipeline already has useful structure

EEGNet makes a related sequence of temporal and spatial operations learnable end to end.

A classical EEG pipeline already has useful structure
Intro to ML · Time Series II14 / 45
Worked example

A temporal kernel has a frequency response

These kernels are chosen by hand. EEGNet learns temporal weights; we can inspect them with the same Fourier tools.

A temporal kernel has a frequency response
Intro to ML · Time Series II15 / 45
Pump investigation 6/8 · Can a filter extract a useful feature?
Worked example

One convolution, computed by hand

One convolution, computed by hand
Intro to ML · Time Series II16 / 45
Core idea

Temporal first. Spatial second.

Each temporal feature gets its own spatial projections. Depthwise means we do not mix different temporal filters here.

Temporal first. Spatial second.
Intro to ML · Time Series II17 / 45
Worked example

Separable convolution: refine, then mix

Focus: Distinguish per-map temporal refinement from pointwise feature-map mixing.

Separable convolution: refine, then mix — concrete illustrated operations and data axes
Intro to ML · Time Series II18 / 45
Worked example

Follow one EEG epoch through the network

Focus: Follow which EEGNet operations change maps, electrodes and time.

Follow one EEG epoch through the network — concrete illustrated operations and data axes
Intro to ML · Time Series II19 / 45
Core idea

An EEG score is only as honest as its split

An EEG score is only as honest as its split — concrete illustrated operations and data axes
Intro to ML · Time Series II20 / 45
Transfer check · Choose → explain → reveal
Core idea

Transfer the filtering idea back to pump sensors

Intro to ML · Time Series II21 / 45
Bridge · Back to the pump
Core idea

What changes when we pretrain once?

Explain pretrained forecasting and evaluate a complete detector under a fixed alarm budget.

Local models fit each series. Global models share weights. A pretrained forecaster reuses weights on a new task.

What changes when we pretrain once?
Intro to ML · Time Series II22 / 45
Worked example

Chronos-2: a modern forecasting model we can read

autogluon/chronos-2-small · 6 blocks · 8 heads · hidden size 512 · 13 quantiles

Chronos-2: a modern forecasting model we can read — concrete illustrated operations and data axes
Intro to ML · Time Series II23 / 45
Core idea

A forecasting task is data plus a visibility contract

A forecasting task is data plus a visibility contract — concrete illustrated operations and data axes
Intro to ML · Time Series II24 / 45
Worked example

Scaling keeps units from dominating the network

z = asinh((x − μ) / σ)    →    x̂ = μ + σ sinh(ẑ)

Scaling keeps units from dominating the network
Intro to ML · Time Series II25 / 45
Core idea

A missing value and a measured zero are different

The schedule is hypothetical. These are input-construction numbers, not a measured forecast.

A missing value and a measured zero are different
Intro to ML · Time Series II26 / 45
Worked example

A patch becomes a vector, without value quantization

Focus: Explain how values, time and an observation mask become one patch representation.

A patch becomes a vector, without value quantization — concrete illustrated operations and data axes
Intro to ML · Time Series II27 / 45
Core idea

Time attention reads within one variable

Chronos-2 uses an encoder. Its time attention is bidirectional across the supplied context and future placeholders.

Time attention reads within one variable
Intro to ML · Time Series II28 / 45
Core idea

Group attention reads across related variables

At one patch index, series with the same group ID exchange information. Different group IDs block that exchange.

Group attention reads across related variables
Intro to ML · Time Series II29 / 45
Core idea

The head predicts quantiles for the whole horizon

Direct multi-step forecast

Each future patch embedding produces values at several quantile levels.

H × targets × quantiles

Multiple future patches come from one forward pass.

Read the uncertainty correctly

q = 0.5 is the predicted median.

[q = 0.1, q = 0.9] is a nominal 80% prediction interval.

A set of marginal quantiles is not a sampled joint future trajectory.

Intro to ML · Time Series II30 / 45
Worked example

Quantile loss makes over- and underprediction cost different

At q = 0.9: underpredict by 1 → loss 0.9; overpredict by 1 → loss 0.1.

Quantile loss makes over- and underprediction cost different
Intro to ML · Time Series II31 / 45
Core idea

Pretraining teaches transferable forecasting structure

Pretraining teaches transferable forecasting structure — concrete illustrated operations and data axes
Intro to ML · Time Series II32 / 45
Pump investigation 7/8 · Has the fault ended?
Worked example

A forecast can become comfortable with a fault

A forecast can become comfortable with a fault
Intro to ML · Time Series II33 / 45
Core idea

A detector is a chain of choices

Compare complete detection systems, then inspect which stage explains their differences.

Four distinct stages: representation, raw detector, calibration and alarm policy.
Intro to ML · Time Series II34 / 45
Compare complete detection pipelines
Core idea

The lab question: detect the entire abnormal state

Which pipeline detects the full abnormal state under a 1% normal alarm-time budget?

Fit

Normal prefixes only.

Fit scaler and classical detector parameters.

Healthy calibration

Separate normal prefixes.

Map raw scores to empirical percentiles.

Labeled validation

Select a threshold under a normal alarm-time budget.

Freeze the choice.

Test

Evaluate once.

State detection first; onset delay second.

Intro to ML · Time Series II35 / 45
Define the denominator
Worked example

Macro and pooled answer different questions

In this lab, AP and F1 give every run one vote; normal alarm time gives every normal timestamp one vote.

Two runs with unequal normal duration demonstrate macro F1 and pooled normal alarm fraction.
Intro to ML · Time Series II36 / 45
Worked example

Rolling features help this model on validation

Same Isolation Forest: 200 trees. Raw sensors → 48 causal sensor, difference and rolling features. Validation only.

validation representation ablation
Intro to ML · Time Series II37 / 45
Frozen validation evidence
Worked example

Compare the complete validation pipelines

Complete detection pipelineMacro APMacro F1Normal alarm time
Normal distance0.7680.0000.000%
PCA Q0.8550.0000.000%
IF: raw sensors0.6730.1040.935%
IF: rolling features0.7660.2820.999%
Mean fusion0.8770.5220.999%
Max fusion0.7750.0000.000%
Persistence residual0.4350.0390.967%
Chronos residual0.4420.0910.967%
Chronos interval0.3620.0010.902%

Validation only · AP/F1: mean over 5 runs · alarm time: pooled normal timestamps.
AP: calibrated ranking · F1: selected cutoff · normal-time budget: 1%.

Intro to ML · Time Series II38 / 45
Pump investigation 8/8 · When should Serega raise an alarm?
Worked example

Useful ranking can fail at the chosen cutoff

Intro to ML · Time Series II39 / 45
Worked example

Averaging helps here; max inherits the saturated tail

Fixed validation run: valve1/8. Shading = abnormal state. Mean fusion averages three calibrated scores.

validation fixed run scores
Intro to ML · Time Series II40 / 45
Worked example

Compare complete anomaly-detection pipelines

PipelineMacro APMacro state F1Normal alarm time
Mean fusion0.8770.5220.999%
Persistence residual0.4350.0390.967%
Chronos residual0.4420.0910.967%
Chronos interval0.3620.0010.902%

8 targets · context 128 · horizon/stride 16 · cross-learning across runs disabled.
Local CPU: 7.82s for 816 forecast tasks; model loading excluded.

These are selected detector pipelines. Forecast accuracy is measured separately on the next slides.

Intro to ML · Time Series II41 / 45
Worked example

Better forecasts do not guarantee better state detection

Chronos reduces point-forecast error on these validation runs; its selected residual detector still misses most faulty timestamps.

Better forecasts do not guarantee better state detection
Intro to ML · Time Series II42 / 45
Worked example

Read the horizon and check the interval

The nominal 80% Chronos interval covers about 76% here. Read coverage together with width.

Read the horizon and check the interval
Intro to ML · Time Series II43 / 45
Worked example

Read the score, then read the actual alarm

A high score is not an alarm. On this fixed run, the mean ensemble issues no alerts at its frozen cutoff.

Read the score, then read the actual alarm
Intro to ML · Time Series II44 / 45
Core idea

Serega can read the forecast. You define the question.

Specify the target.
Follow the axes and the masks.
Compare with an honest baseline.

In the lab: explain one success and one failure before changing the model.

Serega can read the forecast. You define the question.
Intro to ML · Time Series II45 / 45