The practical: build, run and compare
A core LSTM example, with optional maps, graphs and research examples
For the live session, start with the temporal tutorial below. Use its Download prepared notebook button, then open Colab and upload the downloaded file. Run the core cells in order through LSTM evaluation, keeping the tutorial alongside the notebook. The Transformer, MLP and CNN1D remain available as optional comparisons. The frozen data download automatically; no data ZIP upload is needed. The guide also has prepared local outputs. Copying its blocks into a blank Colab remains an optional way to explore the implementation.
Live route: map the study region → build one example → define reference forecasts → train the LSTM → inspect its learning curve → evaluate scores and calibration. Spatial maps and a Graph + LSTM preview connect the example to further exploration.
Apply the same modelling decisions. In the research cases, we chose a representation, defined an output and examined the evidence. Here we make those decisions explicit: summarize 30 days of regional catalogue history, estimate the probability of at least one M ≥ 5 event during the following seven days, and compare the LSTM with simple references. A prepared Transformer comparison shows another way to use that same input. Each model has its construction, compile, fit, predict and evaluation together. The notebook also includes MLP and CNN1D after the live route. In the optional spatial extensions, retain location and predict one weekly probability per cell: maps and graphs use the same six cells, inputs and target windows.
01 · Core tutorial
One regional sequence, step by step
Use 30 days of three daily catalogue features to estimate the probability of at least one M ≥ 5 event in the following seven days. Follow training prevalence and logistic regression, then build and evaluate an LSTM. A small Transformer offers an optional comparison through prepared outputs; MLP/CNN1D are further extensions. Each neural model runs once with seed 7.
Learn: fixed lag positions, temporal filters, recurrent state, attention and positional information. Read Brier score, log loss and calibration alongside parameter counts and completed epochs.
02 · Spatial extension
Learn from sequences of maps
Retain six geographic cells and build a sequence of daily maps. Predict a separate weekly occurrence probability for every cell using CNN2D + LSTM and ConvLSTM2D.
Learn: space versus time, shared spatial filters, sparse cell targets, marginal probability maps and the limits of geographic binning.
03 · Further exploration
Connect the same cells as a graph
Use the same cell histories and outcomes, with a fixed graph connecting cells that share an edge. Combine explicit neighbour aggregation with an LSTM shared across nodes. In the session, we introduce its input and output; the complete notebook is available to continue afterwards.
Learn: adjacency, self-information and neighbour messages, node identity, and how a graph can later support irregular regions.
How to follow the session
Open the prepared temporal notebook alongside its web guide. Before running the preparation, identify one forecast Monday: the input contains the preceding 30 days and the label records whether at least one M ≥ 5 event occurs in the following seven days.
Three daily catalogue features (channels)
A daily feature is one variable constructed from the catalogue for each day; the array also calls these features channels. For each day, summarize catalogue events with M ≥ 4.5 inside the study region:
| Daily feature | Calculation | What it describes |
|---|---|---|
| Event count, transformed | log(1 + count) |
How many qualifying events occurred, on a compressed scale |
| Maximum magnitude excess | Daily maximum magnitude minus 4.5; zero on an empty day | How far the largest event exceeds the input threshold |
| Event presence | 1 if at least one qualifying event occurred; otherwise 0 | Whether the day contains an event |
Illustrative example, before standardization: two events with maximum magnitude 5.2 give approximately [1.10, 0.70, 1]. An empty day gives [0, 0, 0]. One event exactly at M = 4.5 gives approximately [0.69, 0, 1]. Presence distinguishes the last two cases when reading the magnitude-excess variable, although it is redundant with the count and adds no new information.
Stacking 30 consecutive daily rows gives 30 days (rows) × 3 daily features (columns). One row represents a day; one complete window is a training example. The table and examples above show values before standardization. The network receives their standardized versions, using means and standard deviations estimated from training histories only. A negative standardized value means that feature is below its training mean.
The same input reaches the LSTM and the optional MLP, CNN1D and Transformer. The MLP flattens it into 90 values; CNN1D filters neighbouring days; the LSTM reads the ordered days; and the Transformer combines days through attention and position. All four estimate the same weekly occurrence probability. Using three variables is a choice for this example, not a requirement of these architectures. The conditional GAN discussed in the slides is a separate example with mainshock conditions and noise as inputs.
Follow the core experiment
- Load the catalogue, view the study-area map and inspect one 30 × 3 input.
- Read model settings, the epoch limit and the validation stopping rule.
- Define the references; build, compile, fit and predict with the LSTM.
- Read the LSTM learning curve, Brier score, log loss and calibration with bin counts.
- Contrast the regional input with daily maps and the Graph + LSTM input and output.
- Discuss one finding; read the prepared Transformer comparison if the pace allows.
Run the core cells in order and pause at the LSTM probabilities and scores. Each fit is visible next to its model, using the single declared seed 7. The core evaluation does not depend on MLP or CNN1D. The LSTM evaluation, including its calibration plot, completes the core execution. The Transformer comparison can use prepared outputs, while its training cells, MLP/CNN1D sections and the full table remain available for further exploration. If setup or fitting stalls, continue with the example outputs and return to execution after the session.
The spatial tutorials are complete, optional extensions for attendees who wish to explore location information further. Graph + LSTM does not need to be completed during the session. Each can start in its own blank notebook because it includes the same preparation. Their target is per cell, so their scores should not be ranked against the regional scores from Tutorial 1. Within the two spatial tutorials, cell support, normalization, seed 7 and evaluation origins are shared. A map of the numbered six cells connects their geography to the 3 × 2 array and graph nodes.
The first catalogue map
Each tutorial includes a short plotting example immediately after loading the data. The map shows the study region and training-period events (2001–2016) with M ≥ 6 by default. Change the plotting threshold to 5 to display more events. This filter affects only the figure: the models still use catalogue events with M ≥ 4.5, and their occurrence target remains M ≥ 5. Frozen Natural Earth outlines provide geographic context without an online basemap.
Two short connections with the research studies
The research examples isolate two transformations: constructing a temporal input and target from daily intensity maps, and deriving a binary magnitude-threshold label from an aftershock sequence. They include prepared outputs and can be explored independently. No additional model training is needed.
What stays fixed
| Setting | Teaching protocol |
|---|---|
| Catalogue | Frozen, revised USGS records, 2000–2025 |
| Region | 28–34°S, 69–74°W |
| Input threshold / history | M ≥ 4.5 / previous 30 days |
| Target threshold / horizon | M ≥ 5 / following seven days |
| Training / validation | 2001–2016 / 2017–2020 |
| Existing test period | 2021–2025; already inspected in earlier course work and not evaluated in these tutorials |
| Spatial support | Three latitude bands × two longitude bands; six fixed cells |
| Seed in the guided examples | 7; one fit per neural model |
| Separate repeated comparisons | Seeds 7, 17 and 27 |
Standardization uses training histories only. Target intervals crossing split boundaries are excluded. Validation controls early stopping and supplies the displayed comparison; it is not independent evidence of generalization. Spatial probabilities can be positive in several cells and need not sum to one. They describe catalogue occurrence, not shaking, damage or risk.
Optional comparisons across initializations
If you wish to examine sensitivity to initialization, repeat each architecture with seeds 7, 17 and 27 under a fixed data and evaluation protocol. Use the comparisons for temporal sequences, maps and graphs. Report every run and the mean and spread of its scores. For spatial calibration, the displayed ensemble averages probabilities across seeds; its score differs from the mean score of individual runs.
Download the comparison notebook pack and three-seed result files. The guided examples use seed 7; keep that result distinct from the repeated-run summaries.
Download and continue
- Complete tutorial pack: temporal, map and graph notebooks, example outputs and the frozen data ZIP for offline preparation.
- Example result files — seed 7: individual seed-7 scores, predictions, training histories and provenance.
- Further exploration: optional research questions and controlled comparisons. If you pursue an experiment, change one decision at a time, state the hypothesis first and stay on training/validation.
- ETAS-inspired feature experiment: study the effect of adding an activity feature to the same LSTM.
- References: course sources and Keras implementation references.
See Environment and setup for installation, software versions and the execution context of the example outputs.