Research on River Water Quality Anomaly Early Warning Method Based on LSTM–SOA–DA
Tianhao Zhao, Dexiu HuRiver water quality monitoring data are often non-stationary and nonlinear and may contain occasional abnormal values. To support anomaly early warning, this study proposes an LSTM–SOA–DA framework. Water quality monitoring data for six indicators, including pH, DO, CODMn, NH3-N, TP, and TN, were collected from the Bahekou section in Xi’an at 4 h intervals from 2021 to 2023 and chronologically divided into training and testing sets at an 8:2 ratio. The Seagull Optimization Algorithm (SOA) was used to optimize the L2 regularization coefficient, initial learning rate, and number of hidden units of the Long Short-Term Memory (LSTM) network, establishing an LSTM-SOA forecasting model. Compared with traditional LSTM, BP neural network, Support Vector Machine (SVM), Extreme Learning Machine (ELM), and other optimization-based LSTM models, the proposed model achieved better RMSE and R2 performance, indicating improved prediction accuracy. Based on the residuals between observed and predicted values, the DA method was then used to determine indicator-specific anomaly thresholds from the residual distributions. The model identified 193 abnormal points in the test set. After manual rechecking, the Precision, Recall, and F1-score reached 87.6%, 93.9%, and 90.64%, respectively. These results suggest that the LSTM–SOA–DA framework can effectively identify abnormal fluctuations in river water quality data and support timely water environment management.