Predicting structural displacement demand SD(1.0) from the NGA-West2 ground motion database. Compares classical GMPE regression against modern ML models (Random Forest, XGBoost, Physics-Informed Neural Networks) with rigorous earthquake-group cross-validation.
See REPORT.md for the full project writeup.
Requires Python 3.10+.
python3 -m venv .venv
source .venv/bin/activate
pip install numpy pandas matplotlib seaborn scikit-learn xgboost torch scipy openpyxl requestsStep 1 — Download data and build database (~1.5 GB download, requires PEER account):
python download.pyThis downloads the NGA-West2 flatfiles and supporting data from PEER and loads everything into earthquake.db.
Step 2 — Exploratory data analysis:
python eda.py # → eda_figures/Step 3 — Spectral interpolation pipeline (Models A–H):
python pipeline.py # → model_figures/, model_comparison.csvStep 4 — GMPE-style pipeline (source/site features only):
python pipeline_gmpe.py # → gmpe_figures/Step 5 — Neural network tuning:
python tune_nn.py # → nn_figures/, model_comparison_nn.csvStep 6 — Physics-informed neural network:
python physics_nn.py # → physics_nn_figures/Step 7 — Diagnostic comparison (GMPE vs XGBoost):
python diagnostics.py # → diagnostics_figures/All results use an earthquake-group train/test split — each earthquake appears entirely in train or entirely in test, preventing leakage across the 36 stations that typically record each event.
| Model | RMSE (log₁₀) | R² |
|---|---|---|
| OLS — PGA only | 0.572 | 0.822 |
| OLS — spectral shape | 0.086 | 0.996 |
| Ridge / Lasso / XGBoost | ~0.086–0.092 | ~0.996 |
Once neighboring spectral values are available, prediction is near-deterministic — all models saturate at R²=0.996.
| Model | RMSE (log₁₀) | R² |
|---|---|---|
| OLS — M + log(R) + log(Vs30) | 0.440 | 0.883 |
| Classic GMPE OLS (full form) | 0.376 | 0.914 |
| Physics-Informed NN | 0.370 | 0.917 |
| XGBoost | 0.340 | 0.937 |
| Model | τ (inter-event) | φ (intra-event) | σ total |
|---|---|---|---|
| Classic GMPE (OLS) | 0.285 | 0.285 | 0.404 |
| XGBoost | 0.253 | 0.260 | 0.363 |
| Aleatory floor | ~0.13–0.17 | ~0.20–0.24 | ~0.25–0.30 |
Both models are approaching the aleatory floor — the irreducible scatter in ground motion that cannot be reduced without path-specific observables.
earthquake/
├── download.py # Data download and SQLite ingestion
├── eda.py # Exploratory data analysis
├── pipeline.py # Spectral interpolation pipeline (Models A–H)
├── pipeline_gmpe.py # GMPE-style pipeline (source/site only)
├── tune_nn.py # PyTorch hyperparameter search
├── physics_nn.py # Physics-informed neural network
├── diagnostics.py # GMPE vs XGBoost sigma decomposition & bias analysis
├── SPEC.md # Original project specification
├── REPORT.md # Full project report (~8 pages)
├── model_comparison.csv # Spectral pipeline results table
├── model_comparison_nn.csv # NN tuning results table
├── eda_figures/ # EDA plots
├── model_figures/ # Spectral pipeline plots
├── gmpe_figures/ # GMPE pipeline plots
├── nn_figures/ # NN tuning plots
├── physics_nn_figures/ # Physics-informed NN plots
└── diagnostics_figures/ # Diagnostic comparison plots
NGA-West2 is available at PEER Ground Motion Database. A free account is required. download.py automates the download and ingestion.
The database sentinel value −999 is treated as NULL throughout.