Introduction

Water, an essential resource for human survival, is inherently vulnerable and non-renewable. Rapid industrialization and urbanization have caused ecological and environmental destruction and a considerable upsurge in water pollution (Tirkolaee et al. 2018). Both human activities and natural processes, such as rock weathering, erosion, and climate change, impact water quality (Lyu et al. 2020). The persistent presence of pollution and deteriorating water environments pose serious threats to human health (Vörösmarty et al. 2010). Water quality prediction plays a crucial role in addressing specific environmental challenges, such as effective management and pollution reduction. It enables early detection, warning, and water pollution treatment, ensuring the safe use of water. First, water quality prediction aids water resource managers in understanding the current status and trends in water pollution. This insight enables the implementation of targeted management measures, optimization of water supply strategies, and preservation of water resources through judicious usage. Second, it assists in monitoring and controlling pollution sources, promptly detecting and responding to potential pollution incidents. This, in turn, helps reduce water pollution and preserve the health of water ecosystems. Last, the early detection and resolution of potential water pollution issues contribute to ensuring personal safety and well-being.

Water quality prediction methods can be categorized into traditional and machine learning methods. Traditional methods typically consist of physical and statistical models. Physical models utilize mathematical equations to describe water movement, transport, and transformation processes (Magar et al. 2017, Post et al. 2018, Rong et al. 2019, Wool et al. 2020, Zamani et al. 2018), such as the Soil and Water Assessment Tool, Hydrological Simulation Program-FORTRAN, and MIKE System Hydrological European. When applied to water quality prediction, these models are typically build upon a foundation of understanding physical processes and factors with parameters possessing rigorous physical explanations. However, challenges such as difficulty with parameter calibration, modeling structure complexity, parameter uncertainty, and high computational costs restrict their utility in river basin water quality prediction. Additionally, these models are often challenging to calibrate and require a high level of professional expertise to achieve accurate results (Liu and Tong 2011, Moshtaghi et al. 2018; Wan et al. 2021; Zhou et al. 2021). Statistical models are based on probability theory and mathematical statistical methods. While some processes cannot be derived through theoretical analyses, the functional relationship between variables can be obtained through methods such as multiple regression and principal component analysis (PCA) using experimental data. Statistical models, unlike physical models, require only historical data for water quality prediction, making them simpler and more effective (Guo et al. 2020; Shi et al. 2019). However, the simplistic nature of statistical models means they typically assume a normal and linear distribution in the correlation between water quality and explanatory variables, and linearizing nonlinear relationships between water quality changes and influencing factors can reduce the model’s accuracy (Avila et al. 2018; Yang et al. 2017).

Deep learning (LeCun et al. 2015) is a machine learning branch that utilizes neural network models. These methods involve learning complex feature representations and pattern recognitions through multi-layer neural networks. These multi-layer neural networks offer enhanced expressive power and adaptability, with wide-ranging applications in big data analytics, including but not limited to computer vision (Badrinarayanan et al. 2015), image classification (Rawat and Wang 2017), speech recognition (Zhang et al. 2020), time series prediction (Sezer et al. 2019), natural language processing (Otter et al. 2020), and anomaly detection (Malki et al. 2022). In the context of water quality prediction, deep learning technology has significantly improved both prediction accuracy and model effectiveness. It enables not only water quality concentration predictions but also classifications based on water quality levels (Islam and Irshad 2022). In the water quality prediction field, deep learning technology and traditional machine learning methods exhibit notable distinctions. Deep learning methods employ neural network models that autonomously learn intricate features for feature extraction and generalization. Conversely, traditional machine learning methods utilize simpler models that necessitate manual feature design and selection. Consequently, deep learning tends to achieve higher accuracy. Despite this advantage, deep learning models are often considered ‘black boxes’ because of their lower interpretability compared with traditional machine learning models. Nonetheless, researchers are striving to enhance deep learning model interpretability. Therefore, advancements in deep learning techniques are crucial for water quality prediction technologies and governing strategies for water resource management and environmental preservation.

This study aims to furnish a comprehensive review of deep learning algorithms applied to water quality prediction. The screened literature covers a variety of pollutants and a wide range of algorithms used for prediction. Literature screening for research studies on deep learning technology in water quality prediction involves three stages: search, collation, and analysis. During the search stage, the search engines used include Web of Science, Google Scholar, SpringerLink, and ScienceDirect; the specific keywords used include water quality prediction, artificial intelligence, deep learning, meta-heuristic method, data decomposition, groundwater quality, and surface water quality. Additional articles were identified using the cross-citation method by reviewing the selected articles’ references, resulting in a total of 253 articles. The collation stage involved a comprehensive evaluation of articles based on title, keywords, abstracts, etc., leading to the selection of 87 highly relevant articles. Finally, in the analysis stage, each article was carefully reviewed to examine the advancements in deep learning technology for water quality prediction. “The application of deep learning technology in water quality prediction” of this article provides an overview of existing deep learning technology applied to water quality prediction, as shown in Fig. 1, categorized into single and hybrid deep learning models. “Model performance evaluation indicators and factors affecting deep learning technologies for water quality prediction” discusses the evaluation indicators for model performance and the factors influencing water quality prediction using deep learning technology. “The limitations of current deep learning techniques in water quality prediction” explores deep learning technology limitations in water quality prediction. Finally, this article concludes by outlining prospective research avenues and opportunities in this burgeoning field.

Fig. 1
figure 1

Classification of water quality prediction methods based on deep learning technology

The application of deep learning technology in water quality prediction

A systematic analysis of the 87 highly correlated articles was conducted to examine the deep learning prediction of water quality based on the number of deep learning models utilized. This analysis revealed two main categories: single-model predictions of water quality and hybrid-model predictions of water quality, as illustrated in Fig. 1. In single-model predictions, a deep learning model is employed to forecast water quality. In contrast, to enhance prediction accuracy, hybrid-model predictions involve integrating various deep learning models or combining deep learning models with other techniques, such as traditional machine learning, data decomposition methods, and optimization algorithms.

General steps in water quality prediction based on deep learning technology

The process of predicting water quality using deep learning is schematically represented in Fig. 2 and encompasses the following steps:

  1. 1.

    Data gollection: gather relevant data on water quality indicators and environmental factors from sensors, monitoring stations, and historical records.

  2. 2.

    Data preprocessing: clean data by addressing missing values and outliers and standardizing the features.

  3. 3.

    Feature dimension reduction: apply methods such as PCA to reduce feature dimensionality.

  4. 4.

    Model selection and training: choose an appropriate deep learning model for water quality prediction and train and optimize the model using the preprocessed dataset and evaluate its performance using a test dataset.

  5. 5.

    Model optimization: fine-tune the model parameters or improve the model structure based on the evaluation results to enhance its performance further.

  6. 6.

    Real-time prediction and monitoring: utilize the optimized model to predict real-time water quality, include monitoring data into the model to obtain water quality prediction results, monitor the water quality in real-time, and take necessary actions accordingly.

Fig. 2
figure 2

General procedure for utilizing deep learning technologies in water quality prediction

Single deep learning model predictions of water quality

Convolutional neural network (CNN)

Inspired by biology, CNNs have been successfully applied to tasks such as image recognition, object detection, and text processing (Banan et al. 2020; Kumar et al. 2021). A CNN consists of three main components: the convolution layer, the pooling layer, and the fully connected layer. The convolution layer applies a series of filters that slide over the input image to perform dot products based on input data. The pooling layer reduces the dimensionality of the resulting matrix, and the fully connected layer compresses the extracted features to produce the final result.

CNNs can be utilized for time series prediction by constructing an end-to-end model. For instance, water quality time series data can serve as the model input, with the predicted water quality as the output. Pyo et al. (2020) employed a CNN by inputting synthetic nutrient, environmental, and atmospheric grid unit data to predict the cyanobacteria concentration in water. Ta andWei (2018) proposed a simplified reverse understanding CNN model for predicting dissolved oxygen, which showed a faster convergence speed and better prediction stability compared with a back propagation neural network (BPNN). Additionally, CNN can effectively reduce data dimension and extract spatial features. When CNNs are used for predictions in this context, they are commonly incorporated into mixed models, as explained in “Hybrid-model predictions of water quality.”

CNNs are capable of effectively extracting both spatial and temporal features for water quality prediction while effectively reducing data feature dimensionality. Despite their relatively simple architecture and training ease, CNNs possess certain limitations. Specifically, they exhibit restricted capabilities in processing extended sequences and offer limited model interpretability. Currently, CNNs are primarily used as data processing models to extract various features from water quality data to enhance prediction accuracy (Fan et al. 2020, Habib and Qureshi 2020, Xue et al. 2021).

Temporal convolutional network (TCN)

TCNs (Bai et al. 2018) represent a specialized sequence modeling architecture that leverages CNNs to discern patterns and features within sequence data. Unlike traditional CNNs, TCNs incorporate a dilation factor, allowing the convolution kernel to skip a certain number of inputs. This expands the receptive field and captures long-distance dependencies in the sequence effectively. Upon gradually increasing the expansion factor layer by layer, TCNs can model temporal patterns at various scales and consider multiple time scales simultaneously.

Zhang and Li (2022) proposed a multi-input, multi-output end-to-end prediction model called MIMO-TCN based on a TCN. ConvNeXt was utilized to extract features from input data, and a TCN was employed to enhance the prediction accuracy using extracted feature data. To address the issue of gradient disappearance with an increasing number of network layers, the model incorporates skip connections between its modules.

TCNs offer several advantages, including the ability to consider time series correlations, process indefinite long time series data, and enable parallel computing. However, TCNs also possess some limitations, such as a lack of consideration for spatial correlation, data imbalance issues, and limited explanatory power. Despite these shortcomings, TCNs show promising application prospects, particularly in time series prediction tasks that prioritize computational efficiency, modeling long-term dependence, and achieving better results with fewer parameters (Zhang et al. 2019c).

Recurrent neural network (RNN)

RNNs are a type of neural network capable of processing data with a time series structure (Schmidhuber 2015). Unlike traditional feedforward neural networks (FFNNs), RNN neurons receive activation values from the hidden layer in the previous time step as well as input from the current time step. This allows RNNs to update their internal states dynamically and to consider both past inputs and states when computing the current output, making them particularly apt for sequence modeling and forecasting.

Mohamed et al. (2012) implemented deep learning techniques using RNN algorithms. Xiang and Demir (2020) utilized an RNN and sequence learning to develop a neural runoff model and enhanced flow prediction by integrating water level data from an upstream flowmeter. Zhang et al. (2019b) proposed a water quality prediction model based on kernel PCA (kPCA) and an RNN for predicting trends in dissolved oxygen. kPCA was employed to reduce noise in the original dataset while retaining relevant information. The RNN was used to leverage past information for future trend prediction. Compared with FFNNs, support vector regression (SVR), and general regression neural networks, this model demonstrated higher prediction accuracy.

RNNs possess the theoretical capability to handle sequences of any length. However, they are susceptible to issues such as gradient disappearance or explosion when dealing with long sequences. Additionally, the sequential nature of RNN computations can negatively impact the model’s training speed and efficiency, especially when working with large-scale data. Furthermore, the transmission of information in RNNs occurs step by step through time steps, leading to subpar modeling performance in long-term relationships. These limitations restrict its practical applicability (Chen et al. 2018, Hochreiter and Schmidhuber 1997).

Long short-term memory network (LSTM)

LSTMs (Hochreiter and Schmidhuber 1997) are an enhanced model derived from RNNs. They incorporate three essential gating mechanisms, namely, the input gate, forgetting gate, and output gate, aiding in effective information retention and omission. This improves the model’s long-term memory capacity and its ability to capture time series patterns (Gers et al. 2000, 2003). Building upon the LSTM, Bi-LSTM (Graves and Schmidhuber 2005) introduces a reverse LSTM network to consider both the forward and backward information in a sequence.

LSTM and bidirectional LSTM (Bi-LSTM) models have gained significant popularity in the water quality prediction field. These models have proven to be effective tools for predicting various aspects of water quality, such as water quality indexes (Saroja et al. 2023), drinking water quality (Liu et al. 2019a), and river algal blooms (Lee et al. 2018). Several studies have demonstrated that LSTM models outperform other models, such as support vector machines (SVMs) and artificial neural networks (ANNs) in water quality prediction (Essam et al. 2022; Yang et al. 2023a). Additionally, an improved LSTM model has shown promise as a practical method for early warnings of water pollution risks (Guan et al. 2022). Furthermore, Bi-LSTMs have also been widely adopted (Khullar and Singh 2022), as they provide more accurate water quality prediction results. Overall, the research literature indicates that LSTM and Bi-LSTM models possess significant application value and high prediction accuracy in water quality prediction.

LSTMs effectively address the issues of gradient disappearance and explosion through their gating structure. They excel at preserving long-term memory and exhibit a robust modeling capability for handling lengthy sequences and intricate temporal dependencies. However, it is important to note that LSTMs incur a higher computational cost compared with ordinary RNNs, as they necessitate more parameters and computing resources. Additionally, when handling shorter sequence data, they may become overly complex and prone to overfitting (Chen et al. 2018; Zhou 2020).

Gated recurrent unit (GRU)

GRUs (Chen et al. 2018) are an RNN structure that improves upon LSTMs. By simplifying the LSTM gating mechanism, GRUs reduce the number of parameters and improve model efficiency. Unlike LSTMs, GRUs only comprise two gating units: the reset and the update gates. The reset gate controls the degree of reset for the hidden state at the previous time step, while the update gate determines how the current input updates the hidden state. By reducing the number of gating units, GRUs reduce computational complexity and enhance their ability to handle long-term dependencies (Chung et al. 2014).

Researchers have successfully integrated GRUs with other models or employed different data processing methods to improve prediction accuracy. For instance, Liu et al. (2020) introduced a deep learning network called bidirectional stacked simple recurrent units. Additionally, GRU has the advantage of faster convergence compared with LSTM and higher training efficiency (Cheng et al. 2020).

GRUs offer advantages such as fewer parameters and increased computational efficiency compared with LSTMs. GRU utilizes a memory unit similar to LSTM, enabling it to learn both long-term and short-term dependencies. However, GRU’s modeling ability in very long sequence data remains constrained. In certain tasks, GRU demonstrates comparable or slightly better performance than LSTM. Additionally, the reduced parameter count in GRUs makes them less prone to overfitting (Gruber and Jockisch 2020, Yan et al. 2021).

Transformer

Transformer (Vaswani et al. 2017) is a neural network architecture that addresses the issue of gradient disappearance or explosion in traditional RNNs when handling long sequences. It comprises an encoder and a decoder, which are composed of multiple identical layers. Each layer consists of two sub-layers: a multi-head self-attention and an FFNN. The encoder encodes the input sequence, while the decoder generates the output sequence.

Currently, there are limited Transformer applications in water quality prediction. Yao et al. (2022) conducted a study in the Chaohu area and employed various deep learning models, including RNN, LSTM, multi-layer perceptron (MLP), and transformer-based models, to predict a long-term comprehensive water quality index. The results demonstrated that all selected models performed well in the study area. However, as the length of the prediction sequence increased, the performance of informer, a transformer-based model, was notably better. Particularly, informer showed significant advantages in long-term water quality prediction, offering effective modern tools for water quality monitoring and management.

The transformer model is a promising tool for water quality prediction, especially for large-scale predictions. It offers parallel computing capabilities for processing long sequence data, resulting in high efficiency. However, the transformer model applied to water quality prediction requires a substantial amount of high-quality training data. Additionally, this model has numerous parameters and high computational complexity, which limits its application research range. Nevertheless, the research prospects for the transformer model in water quality prediction are extensive.

Deep belief neural network (DBN)

DBNs (Mohamed et al. 2012) are a probabilistic generation model consisting of a series of constrained Boltzmann machine elements. They serve as a tool for unsupervised learning, similar to an autoencoder, and can also be used for supervised learning and classification purposes. These models comprise multiple hidden layers interconnected by weights. The DBN training process involves a greedy layer-by-layer approach. Initially, each restricted Boltzmann machine (RBM) is trained to obtain the weight parameters for each layer. Subsequently, the entire DBN is established by connecting these layers. By combining unsupervised pre-training and supervised fine-tuning, the model’s expressive capability can be enhanced, making it adaptable to the target task.

Yan et al. (2020) proposed a water quality prediction model called PSO-DBN-LSSVR, which combines the particle swarm optimization (PSO) algorithm and the least squares SVR machine. This model demonstrates improved accuracy and robustness in predicting water quality parameters compared with traditional neural networks and model combination methods. In order to address the complex relationship between variables in wastewater treatment processes, Niu et al. (2020) introduced a GA-DBN method that utilizes genetic algorithms (GAs) to reduce dimensionality and simplify network structure. Comparing GA-DBN with traditional DBN and back propagation neural network models, it achieves higher accuracy in predicting variables in complex wastewater treatment processes and improves prediction accuracy.

DBNs are seldom utilized as standalone approaches in water quality modeling because of their relatively lower prediction accuracy compared with other deep learning models. Instead, DBNs are commonly combined with other optimization algorithms or data processing methods to evaluate and showcase the effectiveness of these algorithms. Additionally, DBNs can be used as a benchmark model to highlight the superior prediction accuracy of other models (Niu et al. 2020; Ren et al. 2020).

Autoencoder

The autoencoder is an unsupervised learning algorithm used to learn high-dimensional representation and extract feature data (Zhao et al. 2019). It is composed of two parts: the encoder and the decoder. The encoder combines input data into a low-dimensional coding representation, which is then decoded into an output that resembles the original input data. Through training, the encoder can learn meaningful features from the input data and map these features back to the original data using the decoder.

Autoencoders are unsuitable for water quality prediction. They are commonly employed for reducing data dimensionality or enhancing prediction accuracy when combined with other models. For instance, Kayalvizhi et al. (2023) developed a denoising autoencoder (DAE) model by combining an autoencoder with an LSTM. They used the LSTM as both an encoder and decoder to predict the nitrate and chloride levels in groundwater.

While autoencoders may not be directly applicable to water quality prediction, they can serve as a valuable auxiliary tool in such tasks. Autoencoders can be utilized for data preprocessing and feature extraction, ultimately enhancing water quality prediction model performance. The potential for autoencoders in data preprocessing is vast and holds promising application prospects.

Hybrid-model predictions of water quality

Our comparative analysis of recent literature studies on deep learning for water quality prediction revealed a significant increase in research focusing on mixed model predictions. In contrast, applying single-model predictions is on a downward trend. Typically, researchers combine multiple deep learning models or integrate deep learning with traditional machine learning algorithms, data decomposition algorithms, optimization algorithms, etc., to leverage their respective strengths in capturing complex relationships and patterns within data.

Fusion of multiple deep learning models to predict water quality

The fusion of multiple deep learning models leverages the unique characteristics of different methods, such as CNN, RNN, LSTM, TCN, and attention, to address the challenges posed by complex time series problems arising from spatial and temporal variations in datasets. By combining these deep learning methods, hybrid models can achieve improved prediction results. This approach is particularly effective in handling large quantities of time series data and can adapt well to diverse data structures.

Using the timing processing ability of the original RNN and the ability of attention to weight or focus on different input positions (Geng et al. 2022; Liu et al. 2019b), more accurate predictions can be achieved. LSTM can be improved by combining it with attention (Chen et al. 2022). Upon combining the spatiotemporal feature extraction ability of CNN with the timing processing ability of LSTM, the prediction accuracy and training speed for water quality can be improved (Prasad et al. 2022). LSTM-TCN (Li et al. 2022) outperforms LSTM in capturing characteristics from historical data, while MPA-RNN (Geng et al. 2022) improves prediction accuracy compared with RNN. There are various applications of CNN and RNN (including LSTM and GRU) after fusing with Attention (Mei et al. 2022; Yang et al. 2023b, c, 2021). These models primarily utilize CNN to extract features, RNNs and their improved models to capture long-term dependencies, and the attention mechanism to dynamically adjust the model’s focus. The prediction accuracy of these fusion models is superior to that of single models (LSTM, GRU, etc.) and simple hybrid models (such as CNN-LSTM and LSTM-attention).

The fusion of different deep learning models in time series prediction is an efficient method that combines their individual advantages. This approach, known as the hybrid prediction model, demonstrates improved prediction accuracy and stability compared with single deep learning methods. By integrating multiple deep learning models, this approach offers novel ideas and methods for addressing time series prediction problems.

Fusion of deep learning and traditional machine learning to predict water quality

Traditional machine learning methods refer to using statistical theory and algorithms to construct models for solving machine learning problems. These methods include linear regression (LR), random forest (RF), SVM, PCA, SVR, MLP, and other algorithms. While some traditional machine learning methods can be used alone for water quality prediction (such as LR, RF, SVM, MLP, etc.), their prediction accuracy is generally lower compared with deep learning methods. Therefore, they are often used as benchmark models to compare the prediction accuracy of deep learning models. Additionally, traditional machine learning algorithms are utilized for data processing.

Juan et al. (2022) utilized RF to interpolate missing data and then fed these processed data into an RNN with an attention mechanism for the multi-step prediction of dissolved oxygen. The findings demonstrate that RF can compensate for a lack of dissolved oxygen monitoring data, contribute to creating high-quality water quality monitoring datasets, and enhance the model’s prediction accuracy. Similarly, Shan et al. (2022) proposed a hybrid deep learning architecture called XG-LSTM, which comprises an XGBoost module and two parallel LSTM models. XGBoost is employed to process variables and predict algal cell density and microcystin concentration in the Three Gorges Reservoir. The results indicate that the XG-LSTM model outperforms other models in terms of prediction accuracy, and the ensemble learning approach exhibits advantages in handling noise and missing data in water quality datasets. The utilization of various algorithms in combination enhances the model performance, accelerates convergence speed, and improves prediction accuracy for water quality prediction challenges. Moreover, integrating deep learning models with ensemble techniques effectively addresses complex temporal and spatial dependencies, allowing for powerful expression capabilities. This approach enables the model to learn intricate patterns and features from data, ultimately reducing prediction errors and enhancing prediction accuracy (Zamani et al. 2023).

Traditional machine learning methods possess certain advantages in handling raw and noisy data. However, in terms of improving water quality prediction accuracy, their effectiveness is limited compared with deep learning methods. It is important to carefully consider the characteristics and suitable scenarios for both methods.

Fusion of deep learning and data decomposition algorithms to predict water quality

Deep learning models often encounter complex data when performing time series prediction. This complexity can greatly reduce the model’s prediction efficiency and render simple predictors unreliable. To address this issue, data decomposition methods have been implemented in data processing. These methods aim to handle larger and more complex data sequences. In recent years, the significance of data decomposition methods in time series prediction has grown, leading to their widespread use in signal decomposition and noise reduction to enhance prediction accuracy.

The general steps for predicting water quality using deep learning and data decomposition are outlined in Fig. 3. First, data for the time series prediction are collected and organized, ensuring a time sequence and performing necessary preprocessing. Next, data decomposition algorithms, such as EMD, EEMD, and VMD, are employed to decompose the original time series data into different components such as trend, periodicity, and seasonality. Subsequently, deep learning models such as RNN or CNN are utilized to train and learn from the decomposed data. Finally, the trained model is employed for timing prediction, and the results are adjusted and optimized as required.

Fig. 3
figure 3

General steps of deep learning and data decomposition to predict water quality

The commonly used data decomposition methods are empirical mode decomposition (EMD), ensemble empirical mode decomposition (EEMD), and variational mode decomposition (VMD). These methods have distinct advantages, such as identifying vibration modes, suppressing modal aliasing, and reducing data smoothness. Researchers have applied these decomposition methods to process original data in order to reduce noise. These denoised data are subsequently fed into a deep learning model to enhance prediction accuracy (He et al. 2022; Wang et al. 2023c; Zhang et al. 2021, 2023). For instance, Zhang et al. (2021) proposed an EEMD-LSTM model, which combines EEMD and LSTM networks. By establishing an LSTM sub-model for each sub-sequence and aggregating the prediction results, better prediction accuracy was achieved compared with CNN, LSTM, and EEMD-CNN. Another example is the VMD-LSTM model proposed by He et al. (2022) for water quality data denoising and prediction. VMD was utilized to denoise water quality data, while LSTM/GRU was employed for prediction, resulting in improved prediction performance. Additionally, the secondary decomposition method, which employs two data decomposition methods, can further enhance the deep learning model (Dong and Zhang 2021). Furthermore, combining the data decomposition method with other technologies, such as the two-level attention mechanism or optimization algorithm, can also improve the model’s prediction capability (Li and Li 2023, Song et al. 2021).

Therefore, choosing an appropriate data decomposition method is crucial for enhancing the water quality prediction accuracy attained using deep learning models. However, it is necessary to fully consider the needs of practical applications and data characteristics and select the appropriate data decomposition method.

Fusion of deep learning and optimization algorithms to predict water quality

Optimization algorithms are a practical method for improving prediction model performance. They effectively enhance the efficiency and accuracy of deep learning models when dealing with complex data. By utilizing optimization algorithms, we can efficiently search for the model’s optimal parameter set, optimize the feature engineering process, and enhance the stability and accuracy of the learning algorithm. These technologies are extensively applied in deep learning, enabling models to better adapt to and learn complex data relationships.

The integration of deep learning and optimization algorithms for prediction involves several steps, as shown in Fig. 4. First, time series data need to be prepared, including collection, collation, and preprocessing. Then, relevant features are extracted from time series data to enable the deep learning model to comprehend the patterns and relationships in these data. Subsequently, the deep learning model is designed and trained, with careful selection of the appropriate network structure and optimization algorithm to maximize the time series prediction accuracy. Additionally, the model parameters are further optimized using optimization algorithms such as the chaotic sparrow search algorithm (CSSA) to enhance the prediction performance. Finally, the trained model is utilized for timing prediction, with the option to adjust and optimize the results as necessary.

Fig. 4
figure 4

General steps of deep learning and optimization algorithms for predicting water quality

He et al. (2022) utilized the CSSA to determine the optimal hyperparameters for an LSTM model. Yang and Liu (2022) employed the VMD and wavelet threshold joint denoising methods to eliminate mixed noise in water quality time series and enhanced the whale optimization algorithm to identify the optimal hyperparameters for GRU. Wang et al. (2023c) developed an optimized LSTM prediction model using VMD and an improved grasshopper optimization algorithm. Furthermore, PSO (Zhang et al. 2023), adaptive hybrid mutation particle swarm optimization (Liu et al. 2021), pathfinder optimization algorithm (Guo et al. 2022), and GA (Niu et al. 2020) have also been utilized to optimize deep learning model performance, with successful applications in water quality monitoring and wastewater treatment. Other optimization algorithms, such as the gray wolf optimizer algorithm (Yang et al. 2020) and modified teaching–learning-based optimization algorithm (Larijani and Dehghani 2023), could be considered for enhancing water quality prediction models in future research. These optimization techniques enable us to enhance prediction models’ accuracy and reliability, resulting in more precise data predictions. In some cases, optimization algorithms can not only improve the prediction accuracy but also reduce the model’s run time (Farsi et al. 2020).

In recent years, researchers have focused on studying hybrid models to enhance water quality prediction accuracy. These models typically combine multiple deep learning models or integrate deep learning with traditional machine learning, data decomposition algorithms, and optimization algorithms. The fusion of multiple deep learning models or deep learning with traditional machine learning leverages the strengths of different methods to address complex time series challenges arising from spatial and temporal dataset changes. This approach is adaptable to diverse data structures and can efficiently handle large quantities of time series data. Integrating deep learning with data decomposition algorithms involves utilizing these algorithms to reduce or break down original data using various techniques, extracting the most relevant features to enhance prediction accuracy. Similarly, integrating deep learning with optimization algorithms focuses on leveraging optimization algorithms to effectively search for optimal model hyperparameters, optimize feature engineering, and enhance the stability and accuracy of learning algorithms. Some researchers have also explored Transformer-based methods, improved models (Yao et al. 2022), and satellite remote sensing data (Wang et al. 2023b) for water quality prediction, although this research area requires further exploration and improvement.

There are alternative methods for water quality prediction aside from deep learning. Given the need to acquire substantial data to ensure accurate predictions, researchers have explored virtual sample generation to enhance prediction accuracy (El Bilali et al. 2022). This involves creating virtual samples to expand datasets and improve the model’s generalization ability. Transfer learning is another approach where researchers pre-train the model in a source domain and then optimize it for the target domain to boost prediction accuracy (Cao et al. 2022; Chen et al. 2023). To address the interpretability issue of deep learning, some researchers combine physical models with deep learning models to achieve a balance between physical and data-driven approaches to enhance prediction accuracy and interpretability (Dong et al. 2023).

Comparison of different deep learning methods

In summary, different deep learning methods usually have different roles in water quality prediction, and their characteristics and disadvantages also differ, as shown in Table 1.

Table 1 The characteristics and disadvantages of deep learning technologies in water quality prediction

The advantage of hybrid models is that their prediction accuracy is usually higher than that of single models. However, this improvement comes at the expense of increasing the number of model parameters, which makes hyperparameter tuning more difficult and increases the computational cost.

There are various types of deep learning models, each with its own set of advantages and disadvantages. It is essential to choose the model that best fits the characteristics of the original data and the model itself. Once a deep learning model is selected, determining the appropriate number of layers in the neural network and other parameters, such as the size of the convolution kernel, is crucial, often conducted using empirical methods. Conducting multiple experiments, comparing prediction results, and fine-tuning parameters or utilizing meta-heuristic algorithms to determine optimal values is common practice. Moreover, before making predictions, data preprocessing techniques such as handling missing values and standardizing data are employed to minimize the impact of raw data on prediction accuracy.

Data sources for predicting water quality can encompass national water quality platforms, sensor networks, and collaborations with relevant companies to gather water quality data detected by these entities. Preprocessing data is crucial and involves outlier detection, missing value interpolation, and standardization. Outlier detection assists in removing the influence of anomalous data on the model while missing value interpolation maintains data integrity. Standardization harmonizes features of varying scales into a consistent standard scale, mitigating unit constraints and differences in initial data magnitudes. This process aims to enhance model training and prediction outcomes.

Model performance evaluation indicators and factors affecting deep learning technologies for water quality prediction

Model performance evaluation indicators

Performance metrics are statistical measures that assist developers in assessing and fine-tuning prediction performance on various platforms. Moreover, performance accuracy and effectiveness are translated into comprehensible and quantifiable formats. In the literature pertaining to water quality prediction, the primary model evaluation indicators are mean absolute error (MAE), mean square error (MSE), root mean square error (RMSE), and the coefficient of determination (R2) (Irwan et al. 2023).

MAE

An objective quantitative evaluation of the model’s prediction error. It measures the gap between the model’s predicted and true values. A smaller MAE indicates a closer prediction result to the true value and a better prediction effect. MAE primarily focuses on the error size rather than the error distribution.

$${\text{MAE}}=\frac{1}{{\text{n}}}\sum\limits_{{\text{i}}=1}^{{\text{n}}}\left|{{\text{y}}}_{{\text{pred}}}-{{\text{y}}}_{{\text{true}}}\right|$$

MSE

An objective quantitative measure used to evaluate the model’s prediction error. It calculates the square sum of the difference between the true and predicted values. A smaller MSE indicates that the predicted result is closer to the true result, indicating better model performance. However, MSE only focuses on quantifying the error and does not consider the error distribution.

$${\text{MSE}}=\frac{1}{{\text{n}}}\sum\limits_{{\text{i}}=1}^{{\text{n}}}{\left({{\text{y}}}_{{\text{pred}}}-{{\text{y}}}_{{\text{true}}}\right)}^{2}$$

RMSE

RMSE has the same effect and significance as MSE. The main difference is that RMSE places a higher penalty on samples with large errors, making it more sensitive to outliers.

$${\text{RMSE}}=\sqrt{\frac{1}{n}\sum\limits_{i=1}^{n}{\left({y}_{{\text{pred}}}-{y}_{{\text{true}}}\right)}^{2}}$$

R.2

R2 is an objective quantitative measure that evaluates the degree of model fitting. It indicates how well a model fits data, with values ranging from 0 to 1. A value closer to 1 implies a better degree of fitting.

$${R}^{2}=1-\frac{\sum_{i=1}^{n}{\left({y}_{{\text{true}},i}-{y}_{{\text{pred}},i}\right)}^{2}}{\sum_{i=1}^{n}{\left({y}_{{\text{true}},i}-\overline{{y }_{{\text{true}}}}\right)}^{2}}$$

In the above four formulas, \({y}_{{\text{true}}}\) is the true value, \({y}_{{\text{pred}}}\) is the predicted value, \(\overline{{y }_{{\text{true}}}}\) is the average value of the true value, and \(n\) is the number of samples.

Factors affecting deep learning technologies in water quality prediction

Water quality indicators are categorized into biological, chemical, and physical indicators (Tchobanoglous and Schroeder 1985). Biological indicators encompass fecal coliforms and algae, while chemical indicators include dissolved oxygen, chemical oxygen demand, and ammonia nitrogen. Physical indicators consist of pH, temperature, and turbidity (Wu et al. 2014).

Various factors, such as climate change, geological terrain, soil type, hydrological characteristics, land use, and management, influence water quality (Lintern et al. 2018, Liu et al. 2017, Shi et al. 2017, Wilhm and Dorris 1968). These factors interact in intricate ways, resulting in multiple forms of pollution that significantly impact water quality. Therefore, when utilizing deep learning methods to predict water quality and construct water quality datasets, it is essential to collect different data types. The reasons for the diverse factors affecting water quality are as follows.

Water area

The impact of various water types on water quality varies, and each type exhibits spatial non-stationarity. Different water types exhibit different relationship models with water quality, attributable to variations in purification processes in rivers and lakes (Deng 2020).

Land use/cover change

River water quality is influenced by land use, with the extent of this effect depending on the specific river area and the spatial scale used to measure land use (Wang et al. 2023a). City and cultivated land showed a negative correlation with water quality, while forest land and water bodies exhibited a positive correlation with water quality (Zhang et al. 2019a).

Natural factors

Natural factors include rainfall, topography, and hydrogeology and can significantly influence water flow, oxygen content, and pollutant concentration, consequently impacting water quality. For instance, rainfall can alter water flow and velocity. At the same time, the terrain’s fluctuation and slope direction can affect water flow velocity and direction, ultimately influencing water mixing and circulation.

Internal factors for water bodies

Water temperature, pH value, conductivity, turbidity, color, and redox potential play a significant role in determining water quality. For instance, a low water temperature can slow or impede certain chemical reactions, while a high water temperature can accelerate reaction rates. The pH value influences element dissolution in water, while the redox potential reflects the water’s redox properties, which in turn affect the presence and exchange of oxygen and oxygen compounds as well as biological and chemical reactions. These indicators collectively contribute to overall water quality.

Human activities

Large-scale industrial, agricultural, and urban activities can significantly contribute to poor water quality. These activities involve the discharge of wastewater, pollutants, and other substances into water bodies, which disrupt the ecological balance and impair the regulation and self-purification capabilities of water.

Biological factors

Algae, bacteria, and plankton also play a role in influencing water quality. Algae, through photosynthesis, impact gas concentrations and proportions in water. Bacteria, through decomposing organic matter, affect chemical indicators and overall water quality. Excessive bacterial proliferation can lead to water body eutrophication. Plankton influences the nutritional status, color, turbidity, and oxygen concentration in water.

The limitations of current deep learning techniques in water quality prediction

Constraints of raw data availability

Deep learning models require a large quantity of data to achieve accurate prediction results. However, data collection constraints often restrict many studies to small-scale datasets. In the water quality prediction field, current deep learning techniques primarily utilize single-dimension raw data for modeling and prediction without fully considering other factors that may impact water quality, such as land use, forest coverage, and population. However, these additional factors play a significant role in water quality prediction. To obtain more precise and comprehensive prediction results, it is crucial to expand the dataset size and incorporate these influential factors. This approach can enhance the accuracy and practicality of water quality models to better support decision-making in water environment management.

Failure of data processing

Data processing methods, including wavelet transform, can be susceptible to errors resulting from data preprocessing and processing (Du et al. 2017, Quilty and Adamowski 2018). As the utilization of deep learning techniques for water quality management and prediction becomes more extensive, it becomes crucial to comprehend the errors and limitations of these models, particularly in relation to data selection and processing.

Challenges of long-term prediction

In the water quality prediction field, long-term prediction poses a significant challenge. Unlike short-term and medium-term forecasts, long-term forecasts involve intricate and adaptable spatiotemporal correlations, as well as increased uncertainties, resulting in reduced prediction accuracy. This is due to the diminishing impact of historical data on future predictions and the presence of multiple ambiguous features. Additionally, long-term prediction is influenced by uncertain factors such as the difficulty in accurately predicting weather changes, water mobility, human activities, and a lack of sufficient historical data to establish precise models.

Poor interpretability of models

Deep learning models have faced challenges due to the black box problem since their inception. These models’ intricate structures and multiple parameters obscure the understanding of their operational mechanisms. While deep learning models produce more accurate prediction results compared with traditional models, the rationale and methodology behind parameter selection remain unclear.

Directions for future research

Model selection for optimal prediction

In order to achieve the best prediction results, it is crucial to select the appropriate model based on the characteristics and requirements of the task. However, the process of choosing the most suitable model still requires further research and exploration. Additionally, when dealing with prediction problems involving noise, it is important to consider whether data noise can impact the model’s performance and quality. Therefore, it is necessary to conduct further studies on data processing methods that can effectively reduce noise in data and enhance prediction robustness.

Construction of high-dimensional datasets

In order to enhance the accuracy of water quality prediction, researchers should compile a comprehensive dataset that includes various indicators such as water quality variables, meteorological variables, population data, and forest coverage. By constructing datasets that incorporate these indicators, researchers can employ different analysis methods to investigate correlations between these indicators. This approach will facilitate a deeper understanding of water quality issues and their influencing factors and provide a scientific foundation for relevant departments and decision-makers to develop more effective water quality management strategies. By improving the accuracy and efficiency of water quality prediction, we can take prompt and precise measures to address water quality problems and ensure the sustainable development of human life and the ecological environment.

Enhancing long-term prediction accuracy

Current studies largely concentrate on short-term water quality predictions, which perform inadequately for long-term forecasting. Only a few studies have successfully achieved long-term predictions based on water quality principles. Analyzing the importance of features in long-term prediction and improving prediction accuracy are important issues. Factors such as optimizing feature selection, feature engineering, data processing, and considering model complexity play crucial roles in improving the accuracy of long-term water quality prediction. These improvements will provide a more reliable basis for decision-making in water quality monitoring and management, ultimately leading to more accurate and sustainable water quality protection and management.

Advancements in large model prediction

The complexity and multidimensionality of water quality prediction have prompted researchers to focus on large-scale models. These models can better capture the complex relationship among water quality indicators, thereby enhancing prediction accuracy. Additionally, increasing the depth and breadth of the network in these large models enhances their expressive power. Leveraging distributed computing and parallelization technology accelerates the training process, further improving efficiency. Although research on large-scale models in water quality prediction remains in the early stages, advancements in computing resources and algorithms are expected to drive further research in this area. This will yield enhanced accuracy and reliability of water quality prediction, providing crucial support for macro-level water quality control.

Bridging academic research and practical application

The majority of the literature focuses on assessing the viability of deep learning techniques in predicting water quality, with the goal of enhancing the accuracy and accessibility of such predictions. However, these studies often fail to provide explicit guidelines on effectively connecting academic research with industry and government management. Consequently, it is pivotal for scholars to actively engage in the practical application of deep learning technologies to facilitate precise water quality assessment and management.

Conclusion

In recent years, deep learning technology has been widely used in water quality prediction, yielding positive results. Its effectiveness lies in handling high-dimensional feature representation and nonlinear relationships within water quality data. Through multi-layer nonlinear processing units, more intricate structures can be constructed to better model data. Deep learning excels in processing large-scale data efficiently, utilizing batch processing and parallel computing to handle massive and high-dimensional water quality data to support effective water quality prediction. Furthermore, deep learning models can autonomously learn and be iteratively optimized to enhance prediction accuracy over time. However, the success of deep learning technology hinges on high-quality datasets. Original water quality data often includes missing values, outliers, and noise, which impact prediction accuracy. Despite outperforming physical and statistical models in prediction accuracy, deep learning models are criticized for their lack of interpretability, often referred to as a ‘black box.’ Moreover, training deep learning models demands significant computing resources, necessitating high hardware and computing power requirements.

To further advancements in water quality prediction research and application, it is crucial to integrate various technologies including machine learning, data mining, cloud computing, multi-source data fusion, and deep reinforcement learning. Data mining plays a key role in uncovering underlying rules and relationships, offering valuable insights for water quality prediction. Cloud computing and distributed platforms provide the necessary computational power for handling large-scale water quality data, while multi-source data fusion enhances monitoring accuracy and temporal resolution. Deep reinforcement learning optimizes decision-making processes for water quality treatment, thereby enhancing overall efficacy. Furthermore, exploring the interpretability of deep learning models in water quality prediction enhances model credibility and practicality. Simplifying algorithms and computational requirements, along with promoting understanding of deep learning methods through educational resources, can greatly support the widespread application of deep learning in water quality prediction.

Interdisciplinary collaboration is essential for advancing water quality prediction research. Environmental scientists can utilize sensor networks and remote monitoring technology developed by embedded engineers to access up-to-date water quality data in real time. By leveraging their domain knowledge, environmental scientists can identify key water quality characteristics and factors, creating datasets for water quality prediction. Artificial intelligence researchers can then use these datasets to develop feature importance analysis methods and prediction models. Subsequently, environmental scientists can analyze the prediction results using their expertise in water systems and provide feedback to AI researchers. This collaborative effort leads to the innovation and optimization of water quality prediction models, ultimately enabling real-time monitoring and efficient water quality prediction.

The application of deep learning technology in water quality prediction can enhance prediction accuracy and monitoring quality to provide strong support for water environment protection and management. Further research and exploration of deep learning technology in water environment protection can contribute to promoting water environment improvement and sustainable development.