Hybrid LSTM/PINN forecasting of NDVI/EVI for rice yield prediction from satellite time series (Senegal) — Master's thesis code
# Rice Yield Forecasting — Hybrid LSTM / PINN Modeling from Satellite Time Series
Code accompanying my Master's thesis (M2, Modeling of Physical Systems and Phenomena,
Université Cheikh Anta Diop de Dakar, 2026): **"Agricultural Yield Forecasting in
Senegal through Hybrid Modeling: Machine Learning and Satellite Data."**
## Overview
This project forecasts NDVI/EVI vegetation indices for irrigated rice plots in Senegal
from decadal satellite time series, using two models trained under identical
conditions:
- **LSTM baseline** — a purely data-driven recurrent model (LSTM(64) → LSTM(32) → Dense(2)).
- **PINN (Physics-Informed Neural Network)** — the same architecture, with an added
physical consistency constraint in the loss function: the conservation of the
relative dynamics between NDVI and EVI, `d(NDVI)/dt ≈ d(EVI)/dt`. Unlike a logistic
growth law, this constraint remains valid during both growth and post-harvest decline,
including for the 73.4% of plots with a double-harvest cycle.
Both models are trained on 5,731 individual rice plots (206,316 observations after
cleaning), using a 3-decade sliding window to predict the following decade, then
evaluated both one-step-ahead and through 36-step autoregressive forecasting for a
2026 projection.
## Repository contents
| File | Description |
|---|---|
| `data_preprocessing.ipynb` | Loading of 252 raw decadal CSV files, filtering of rice plots, outlier handling, gap-filling, moving-average smoothing, double-harvest detection. |
| `lstm_model.ipynb` | LSTM baseline: training, one-step-ahead validation, 2026 autoregressive forecast, yield estimation. |
| `pinn_model.ipynb` | PINN variant: custom training loop with the NDVI/EVI conservation constraint, same evaluation protocol as the LSTM for direct comparison. |
## Key results
- One-step-ahead validation: R² ≈ 0.97 for both models (NDVI and EVI).
- 2026 autoregressive projection: the LSTM and PINN diverge notably on the average
yield trend (+0.47 t/ha vs. −0.34 t/ …