File size: 2,668 Bytes
3d62172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
license: mit
tags:
  - time-series
  - forecasting
  - lstm
  - hydrology
  - groundwater
---

# LSTM Groundwater Level Forecasting β€” UK

A tuned LSTM model for single-step monthly groundwater level forecasting
using meteorological variables as exogenous inputs.

## Model Details

| Parameter | Value |
|---|---|
| Architecture | LSTM(128) β†’ Dropout(0.1) β†’ Dense(32) β†’ Dense(1) |
| Framework | TensorFlow / Keras |
| Task | Single-step monthly forecasting |
| Lookback window | 24 months |
| Input features | water_level, temperature, precipitation, wind_speed |
| Tuning method | Bayesian Optimisation (Keras Tuner, 20 trials) |

## Data Splits

| Split | Period | Months |
|---|---|---|
| Training | 1944-01-01 β†’ 2007-10-01 | 766 |
| Validation | 2007-11-01 β†’ 2015-10-01 | 96 |
| Test | 2015-11-01 β†’ 2023-10-01 | 96 |

## Best Hyperparameters

| Parameter | Value |
|---|---|
| LSTM layers | 2 |
| Units | 64 |
| Dropout | 0.1 |
| Learning rate | 0.000773 |
| Batch size | 32 |

## Test Set Performance

| Metric | Value |
|---|---|
| RMSE | 2.9386 m |
| MAE | 2.397 m |
| MAPE | 3.671% |
| RΒ² | 0.5505 |
| NSE | 0.5505 |

> This model is part of a benchmark study comparing SARIMAX, LSTM, and TCN
> for UK groundwater level forecasting.

## Important Note

Contemporaneous meteorological variables are used as inputs at forecast time
(oracle assumption). Future met values are treated as known β€” consistent with
the experimental setup used across all models in this study.

## Repository Contents

```
β”œβ”€β”€ lstm_model.keras    # Trained Keras model
β”œβ”€β”€ scaler_X.pkl        # Feature scaler (MinMaxScaler)
β”œβ”€β”€ scaler_y.pkl        # Target scaler (MinMaxScaler)
β”œβ”€β”€ model_config.json   # Config, hyperparameters & metrics
β”œβ”€β”€ inference.py        # Load model & generate forecasts
└── README.md           # This file
```

## Quick Start

```python
from huggingface_hub import hf_hub_download
from tensorflow.keras.models import load_model
import joblib, pandas as pd, numpy as np

model    = load_model(hf_hub_download('kozy9/GWLSTM', 'lstm_model.keras'))
scaler_X = joblib.load(hf_hub_download('kozy9/GWLSTM', 'scaler_X.pkl'))
scaler_y = joblib.load(hf_hub_download('kozy9/GWLSTM', 'scaler_y.pkl'))

# Provide a 24-month window of features
X_window = pd.DataFrame({
    'water_level'  : [...],   # 24 values
    'temperature'  : [...],
    'precipitation': [...],
    'wind_speed'   : [...],
})

X_scaled = scaler_X.transform(X_window)
X_input  = X_scaled.reshape(1, 24, 4)
y_scaled = model.predict(X_input)
pred     = scaler_y.inverse_transform(y_scaled)[0][0]
print(f'Next month forecast: {pred:.2f} m')
```