## 3 Materials and Methods
### Framework Overview
#### 3.2.3 Deep Learning Model  
This study employed the Temporal Fusion Transformer (TFT) architecture, following the same configuration as used in our previous work [34], where it demonstrated superior performance in short-term water level forecasting. Given its effectiveness in capturing complex temporal relationships and its capacity for interpretable multi-step prediction, the TFT was selected as the deep learning component of our hybrid framework. To formally define the problem and improve mathematical clarity, we now briefly present the core equations of the Temporal Fusion Transformer (TFT) components as applied in this study. These include the input-output structure, gated residual networks (GRNs), multi-head attention, and LSTM layers. At timestep \(t\) for a forecast horizon of length H, we aim to predict target \(y_{t+\tau}\in R\) for all timesteps \(\tau\in\{1,\ \dots,\ H\}\), given a set of input feature variables. Input features are divided into observed inputs \(z_{t}\), which are only available up to the present timestep \(t\) and known future inputs \(x_{t}\) which can be predetermined for timesteps \(t+1,\ \dots,\ t+H\). To condition forecasts on recent dynamics, we use a fixed-length lookback window of size \(k\), which provides the model with access to the most recent \(k\) historical values of the target and covariates (\(t-k\) timesteps). As such, we adopt quantile regression to our multi-horizon forecasting setting. Each quantile forecast takes the form  
\[y^{\{q\}}(t)(t,\tau)=\ TFT_{q}(\tau,\ y_{t-kt},\ z_{t-kt},\ x_{t-kt+\tau})\]  
where \(y^{\{q\}}(t)(t,\tau)\) denotes the TFT model's estimate of the \(q\)-th conditional quantile of the future target value \(y_{t+\tau}\) for a forecast horizon \(\tau\), given all available information up to time t and known future inputs up to time \(t+\tau\). To capture temporal dynamics, the TFT employs a sequence-to-sequence LSTM architecture. The encoder processes past observed and known inputs within a fixed lookback window, generating hidden and cell states that summarize the recent sequence. These states are then used to initialize the LSTM decoder, which processes known future inputs. Thisresults in a temporally aware representation that serves as the foundation for downstream processing by the attention and gating components. To refine the extracted temporal features, TFT applies gated residual networks (GRNs). The information flow through the GRNs can be represented using the following equations:  
\[\text{GRN}(a)=\text{ LayerNorm }(a+GLU(\eta_{1}))\] \[GLU(\eta_{1})=\sigma(W_{1}\eta_{1}+b_{1})\odot(W_{2}\eta_{1}+b_ {2})\] \[\eta_{1}=\ W_{3}\eta_{2}+b_{3}\] \[\eta_{2}=ELU(W_{4}a+b_{4})\]  
Here, \(a\) is the basic input to GRN, and \(W\) and \(b\) are weights and biases that are optimized during training. Firstly, \(a\) passes through a dense layer with Exponential Linear Unit (ELU) activation function [51], followed by a linear layer with dropout. The output from this layer goes into a Gated Linear Unit [52], where \(\odot\) is the element-wise product, and \(\sigma\) is the sigmoid activation function. Finally, the output from GRN is calculated by standard layer normalization of the sum of input \(a\) and GLU output (residual connection). Following temporal encoding and gating, the model employs an interpretable multi-head attention mechanism to capture long-range dependencies across the input sequence. Unlike standard attention, TFT's modified design shares value projections across all heads and uses additive aggregation to combine their outputs.