Undergraduate thesis, 2026

Where foreshocks become forecasts.

A machine learning model that reads the tremors before a Philippine mainshock and estimates how large it will be. Built on 119 years of PHIVOLCS records and mapped fault distances.

17,667 catalogued events 16 models compared Verified against Python

Annual maximum magnitude 1960 to 2026
PHIVOLCS catalogue Marked: M 7.5 and above
Best model Extra Trees
Skill over average +23.6%
b-value 0.920
17,667 Earthquakes retained after cleaning, 1907 to 2026
535 Mainshocks with a usable foreshock window
23.6% Error reduction over the historical average
797 Mapped fault points the catalogue is measured against

What the study does

Six stages, each one auditable on its own.

Every stage writes a table you can check. Nothing is asserted that the repository cannot reproduce from the raw workbook.

01

Catalogue cleaning

Reads the PHIVOLCS workbook, rejects impossible hypocentres, collapses duplicate origins and resolves four magnitude scales into one working scale.

18,338 in, 17,667 out

02

Frequency and magnitude

Completeness magnitude by maximum curvature and goodness of fit, then the Gutenberg-Richter b-value by least squares and Aki-Utsu maximum likelihood.

b = 0.920, Mc 4.9

03

Maeda declustering

Removes the small dependent events that trail a larger one, using the space and time windows of Hirose and colleagues, without deleting the mainshocks being forecast.

2,207 removed

04

Feature engineering

Twenty-two features from the published table plus five that summarise how far the foreshocks sit from the nearest mapped active fault.

27 features per window

05

Model comparison

Sixteen forecasters across four families, scored first by expanding-window validation and then once on a test partition nothing has touched.

Tree, linear, recurrent, classical

06

Browser forecaster

Four trained models exported to run client side, with the feature mathematics reimplemented and checked value by value against the Python original.

1,620 values verified

The record

A century of Philippine seismicity, and what it honestly supports.

PHIVOLCS has logged earthquakes along the archipelago since 1907. This study uses the whole retrievable archive: every event with a complete origin time, epicentre, depth and at least one reported magnitude.

Cleaning that archive is where most of the honest work sits. The four magnitude scales are almost never co-reported with moment magnitude, so no defensible conversion could be fitted from this catalogue alone. The working magnitude falls back to the first available scale in the order Mw, Ms, mb, ML, and the paper says so plainly rather than implying a homogeneous record.

The catalogue is also complete only from magnitude 4.0 upward, because that is where PHIVOLCS begins publishing. Each event additionally carries its distance to the nearest active fault, measured against fault lines mapped in QGIS. Two in five sit within 25 km of one.

See how it is processed
Scatter map of earthquake epicentres across the Philippine archipelago. Open circles mark events of magnitude 6.0 and above, concentrated along the eastern trenches and the Philippine Fault.
Epicentres of all 17,667 catalogued events. Open circles mark magnitude 6.0 and above.
Frequency magnitude distribution on a logarithmic axis with a fitted Gutenberg-Richter line above a completeness magnitude of 4.9 and a b-value of 0.920.
Frequency magnitude distribution with the Aki-Utsu maximum-likelihood fit above Mc 4.9.

Our approach

From a raw bulletin to a forecast the calendar cannot cheat.

Every step exists to stop the model learning something it would not know in advance.

01

Clean

Reject impossible records, collapse duplicates, resolve the magnitude scales, and log what each rule removed.

02

Decluster

Apply Maeda's method so aftershock swarms cannot masquerade as precursory activity.

03

Engineer

Build 27 features from the 14 days and 100 km before each mainshock, target excluded.

04

Train

Split strictly by time, 60:20:20, refitting every transform inside each fold from training rows alone.

05

Verify

Score once on untouched data, compare against naive baselines, and publish the limits.

Results

Real skill, and small. Both halves of that sentence matter.

Sixteen forecasters ran on identical sequences. A third of them cannot beat simply quoting the historical average.

Horizontal bar chart of test root mean squared error for sixteen forecasting models. Extra Trees and Random Forest are shortest. A dashed line marks the climatology baseline; the multilayer perceptron, the convolutional network and the persistence baseline extend past it.
Test-partition error for all sixteen models. Bars past the dashed line fail to beat the historical average.
Test partition, 107 held-out sequences
ModelRMSER squaredSkill
Extra Trees0.4920.147+23.6%
Random Forest0.4980.125+21.6%
ARIMAX0.5100.085+18.0%
Elastic Net0.5130.073+17.0%
k-Nearest Neighbours0.5140.068+16.6%
GRU0.551-0.069+4.2%
LSTM0.560-0.103+1.2%
Climatology baseline0.563-0.1160.0%
Multilayer Perceptron0.585-0.206-8.0%
1D-CNN0.675-0.606-43.9%

What the numbers say

An Extra Trees ensemble on 27 features cuts squared error by 23.6% against quoting the historical average magnitude. That is real skill. It is also small: the typical error is still about half a magnitude unit, the difference between a tremor and a damaging event.

Fault distance earns its place

Adding the distance from each foreshock to the nearest mapped fault lifted the best model from 21.4% to 23.6%. Three of the five fault features rank fifth, sixth and seventh of 27 by permutation importance. The other two measure nothing the model can use, and are reported as such.

Whether, not just how large

A second model was built for the other half of the objective: the chance an earthquake of a given size follows within two weeks. Across nine combinations of magnitude and radius it beat the historical rate in one, by 3.4% Brier skill with a fold-to-fold spread several times that. The panel therefore reports the historical rates, each with its margin of error at 95% confidence.

Those intervals come from a bootstrap that resamples whole years rather than individual anchors. The standard Wilson interval assumes independent trials, and these are overlapping windows cut from one catalogue where a single productive swarm supplies many of them. Dropping that assumption roughly triples the margin of error, from 2.1 to 5.6 percentage points on the headline figure, which is the honest width.

Depth beats recurrence

The recurrent networks land barely ahead of the baseline and every tree ensemble beats them. With 428 training sequences of ten timesteps, there is not enough data for a recurrent architecture to pay for its parameters.

Try it

Run the model on a foreshock sequence.

Four trained models from the paper, running in your browser on the events you give them. The panel returns how large a mainshock would be, and separately how often one has actually followed a sequence like this within two weeks.

Choose a sequence

A recorded sequence loads a real case from the held-out test partition, so you can compare the forecast against what actually happened. Your own lets you type an epicentre, a date and your own list of tremors.

Check the foreshocks

One row per tremor in the 14 days before. Days before counts backward from the forecast moment, so 0.44 means about eleven hours earlier. At least three complete rows are needed before the model can be computed.

Pick a model and forecast

The number beside each model is its test error in magnitude units, so lower is better. Press Forecast and the panel returns the expected magnitude, its uncertainty, and the historical chance that anything follows.

Sequence

Real sequences from the held-out test partition, so the observed outcome is known.

Model
Foreshocks in the 14 days before
Days before Magnitude Lat N Lon E Depth km Remove

Loading the trained models.

Why the numbers hold

Built so the result survives being checked.

Chronological splits

Every validation sequence postdates every training sequence. A shuffled split is the most common way a seismic forecast turns out to be an artefact.

Leak-free preprocessing

Imputation, winsorising and scaling are refitted inside each fold from that fold's training rows alone.

Naive baselines included

Climatology and persistence are scored alongside every model, so skill is measured against something, not asserted.

Cross-language verification

The browser reimplementation is replayed against Python on 60 held-out sequences: 1,620 feature values and 240 predictions.

Fully reproducible

One seed, one command, one file. Re-running the analysis reproduces every number on this page and in the document.

Limits published

What the model cannot do is given its own section rather than buried in a footnote.

Stated plainly

What this cannot do.

A forecasting paper is only as trustworthy as the list of things it refuses to claim.

Not a prediction system

It does not say when or where

The model estimates the magnitude a mainshock would reach given a foreshock sequence already in progress. It forecasts neither the time nor the location of an earthquake, and nothing here is an early-warning capability.

Foreshocks are rare

Most large events arrive unannounced

Of 3,261 candidate mainshocks, only 535 had enough catalogued activity in the preceding fortnight to support a forecast at all. The method is silent for the great majority of damaging earthquakes.

Occurrence resists modelling

How large is learnable, whether is not

Conditional on a mainshock following, its magnitude is forecast with 23.6% skill. Whether one follows at all is another matter: across nine magnitude and radius combinations the probability model beat the historical rate once, marginally. The honest answer to "what is the chance" remains the observed frequency.

Detection, not seismicity

The record grew with the network

Recorded events rise sharply through the 1970s and after, tracking the expansion of the monitoring network rather than a change in the ground. Any temporal trend confounds the two.

One fault layer

Fault distance is only as good as the map

Distances are measured to fault lines digitised in QGIS. A fault absent from that layer is invisible to the model, and the browser approximates the assignment from 797 mapped points.

Open and reproducible

See what the model makes of your own sequence.

Enter a handful of foreshocks, pick a model, and read the forecast with its uncertainty. Everything runs in your browser, nothing is uploaded.

The study

A Machine Learning Model for Forecasting Mainshock Magnitudes Using PHIVOLCS Foreshock Data

Submitted to the Faculty of the College of Engineering and Architecture, Lyceum of the Philippines University, Cavite, in partial fulfilment of the requirements for the degree of Bachelor of Science in Civil Engineering.

Institution
LPU Cavite, College of Engineering and Architecture
Degree
BS Civil Engineering, 2026
Sustainable Development Goals
SDG 9 and SDG 11
Loui Cris C. Atienza Researcher
Alexander Jr. R. Noveno Researcher
Joseph Lorenz B. Pajarin Researcher

Catalogue source: PHIVOLCS earthquake bulletin, 1907 to 2026. Fault lines mapped in QGIS. Official earthquake advisories come from PHIVOLCS, not from this page.