The preservation of human health and the integrity of the ecosystem depend on regular assessments of water quality. Nevertheless, conventional centralised methodologies encounter difficulties concerning data privacy, scalability, and resource constraints. This research presents an innovative, privacy-preserving approach utilising federated learning with recurrent neural networks (RNNs) to overcome these restrictions. Our approach facilitates decentralised training of predictive models across remote water monitoring sources, such as treatment facilities and field stations, without the need to transfer sensitive data, in contrast to previous methods. Our methodology uniquely captures temporal trends in water quality data, such as variations in pH, dissolved oxygen, and pollutant levels, by integrating federated learning with Long Short-Term Memory (LSTM) networks. Experimental results indicate that our method attains a classification accuracy of 92.3% while simultaneously improving data confidentiality and scalability, rendering it a practical instrument for decentralised water quality monitoring in real-world applications. This new approach provides a significant leap in environmental monitoring by enabling secure, large-scale, and collaborative analysis of water quality data.

  • A privacy-preserving federated learning framework using LSTM networks for decentralised water quality monitoring, achieving 92.3% accuracy, is developed.

  • Temporal trends in parameters like pH, dissolved oxygen, and pollutants without transferring sensitive data is captured.

  • Scalability, data confidentiality, and real-world applicability for sustainable environmental monitoring is enhanced.

Water quality monitoring is of paramount importance for ensuring the health and safety of both humans and the environment. Timely and accurate classification of water quality parameters, such as power of hydrogen (PH) levels, dissolved oxygen concentrations, and pollutant levels, is crucial for effective management and remediation of water resources. Traditional centralized approaches to water quality analysis often face challenges related to data privacy, scalability, and resource constraints. Moreover, centralized data collection may not always be feasible due to the distributed nature of water sources and regulatory restrictions on data sharing (Chen & Han 2018).

In recent years, federated learning (FL) has emerged as a promising approach to address these challenges by enabling collaborative model training across decentralized data sources while preserving data privacy. FL allows machine learning (ML) models to be trained directly on data distributed across multiple devices or locations without the need to exchange raw data (Li et al. 2020). This decentralized paradigm is particularly well-suited for water quality classification (WQC) tasks, where data may be collected from disparate sources such as water treatment plants, environmental monitoring stations, and IoT devices (Kairouz et al. 2021).

Traditional centralized approaches to water quality analysis often face significant challenges, including centralized data collection and processing requiring sharing sensitive data from various sources, such as water treatment plants and environmental monitoring stations. This raises privacy concerns and compliance issues with data protection regulations. Centralized systems must handle large volumes of data from multiple distributed sources, leading to potential bottlenecks in data processing and analysis. Centralized systems often require significant computational resources and infrastructure, which may not be feasible for all organizations, especially those in remote or resource-limited areas. To address these challenges, we propose a decentralized approach to WQC using FL with recurrent neural networks (RNNs). Our solution involves FL, which enables collaborative model training across multiple geographically distributed data sources without requiring them to share their raw data. This approach maintains data privacy and complies with data protection regulations. We employ RNNs, specifically long short-term memory (LSTM) networks, to capture temporal dependencies in time-series water quality data. LSTMs are well-suited for handling sequences of data and can effectively model the temporal patterns in water quality parameters. Each participating data source (e.g., water treatment plants and monitoring stations) trains a local model on its own data. These local models are then periodically aggregated by a central server to update a global model. The aggregation process ensures that the global model benefits from the insights gained from all participating sources while preserving data privacy.

In this study, we propose an FL-based approach to WQC using RNNs, specifically LSTM networks. By leveraging the temporal dependencies inherent in time-series water quality data, LSTM networks can effectively capture patterns and fluctuations over time, leading to more accurate classification results. Through FL, our framework enables collaborative model training across geographically distributed data sources, thereby addressing data privacy concerns and promoting scalability.

In this paper, we present a comprehensive analysis of our FL approach for WQC. We evaluate the performance of our model on real-world water quality datasets, demonstrating its effectiveness in accurately classifying water quality parameters while preserving data privacy and security. Our findings underscore the potential of FL with LSTM networks as a scalable and privacy-preserving solution for decentralized water quality monitoring and classification, with implications for environmental management and public health.

Water quality prediction and management have become critical areas of research due to increasing concerns over water pollution and resource management. Recent studies have focused on employing advanced ML and hybrid models to improve the accuracy and efficiency of water quality predictions. This review synthesizes insights from various studies that have utilized different ML techniques and hybrid approaches for predicting and managing water quality. Panahi et al. (2022) proposed a hybrid model combining variational mode decomposition with ensemble ML techniques like bagging, reduced error pruning tree (REPT), and random forest for streamflow prediction. By decomposing streamflow data into intrinsic mode functions, the model effectively captures nonlinearity and nonstationarity, yielding precise predictions. Although the implementation complexity is higher, the model demonstrates superior accuracy and recall in predicting both water quantity and quality parameters, with a robust F1-score indicating effective handling of complex streamflow dynamics. Abba et al. (2020) explored multiple modeling techniques, including backpropagation neural network, adaptive neuro-fuzzy inference system, support vector regression (SVR), and multiple linear regression, alongside an ensemble approach, neural network ensemble (NNE), for predicting the water quality index (WQI). The NNE ensemble method significantly enhances prediction accuracy by integrating outputs from individual models, leveraging their complementary strengths. The ensemble approach, despite its complexity, achieves high recall and precision in predicting the WQI, demonstrating superior performance and robustness across different river stations. Sarang et al. (2023) provided a comprehensive review of water quality prediction, treatment method prediction, and use case classification. They proposed a hybrid model that integrates statistical models, ML algorithms, and theoretical insights to predict water quality, treatment methods, and use cases. This hybrid approach improves prediction robustness and accuracy, supporting informed decision-making for water resource management, although it requires substantial computational resources and expertise. Kuvayskova et al. (2024) addressed the challenge of predicting water quality violations in real time, integrating statistical regression models with ML techniques like gradient boosting, random forest, and support vector machine (SVM). Their methodology combines regression, ML, and fuzzy logic for decision-making regarding reagent dosage adjustments, ensuring high recall and precision in predicting water quality violations, crucial for maintaining safe drinking water standards. Sattari et al. (2021) assessed various data mining methods for classifying water quality parameters in the Aladag River, Turkey. Methods like support vector classifiers, decision trees like reduced error pruning tree (REP tree), and k-nearest neighbor (KNN) demonstrated high accuracy in classifying water quality based on hydro-chemical and hydrological parameters. These methods offer robust performance, although they require substantial computational resources and parameter-tuning expertise. Ghosh et al. (2023) utilized several ML models, including G-naive bayes, B-naive bayes, SVM, KNN, eXtreme Gradient Boosting (XGBoost), and random forest, to assess and classify water quality as potable or non-potable. The random forest model achieved the highest accuracy, emphasizing the effectiveness of ML in water quality assessment. The study highlights the use of precision-recall curves to select the best model for ensuring potable water availability.

Hamzaoui et al. (2023) introduced the DTKNN + model, a hybrid approach combining decision tree and KNN algorithms for WQC in aquaculture. The DTKNN + model demonstrated superior accuracy and reduced error rates compared to simple KNN, highlighting its effectiveness in handling the complexity of aquaculture water systems. Almadani & Kheimi (2023) proposed stacking artificial intelligence models, achieving improved accuracy and performance in predicting water quality parameters. The meta-learner MLP model outperformed several other methods, demonstrating the effectiveness of stacking techniques in water quality modeling. Dong et al. (2023) developed a hybrid model based on signal decomposition and ensemble deep learning techniques, achieving high accuracy and robust performance in forecasting water quality in complex river systems. The model's improved generalizability and prediction accuracy make it a valuable tool for water quality management. Sathananthavathi et al. (2024) presented an intelligent water quality monitoring system using a hybrid classifier, achieving high accuracy, recall, precision, and F1-score. This system effectively assesses water quality for appropriate distribution, highlighting its potential for practical applications. Talukdar et al. (2024) evaluated various ML models for water quality management in Lake Loktak, with the random forest model demonstrating superior performance and interpretability. The study underscores the importance of model optimization and interpretability in effective water quality management. Liu & Li (2024) proposed an ML-based strategy using drone hyperspectral images for retrieving water quality parameters in urban rivers. Decision tree regression and XGBoost regression models showed promising performance, emphasizing the potential of unmanned aerial vehicle (UAV) technology in water quality monitoring.

Clements et al. (2024) demonstrated the effectiveness of multi-class supervised ML classification using online instrumentation to detect harmful algal blooms and de facto water reuse events at drinking water intakes. The Mechanics-Dynamics-Aesthetics (MDA) model achieved high accuracy, highlighting its robustness in detecting specific water quality events. Tian et al. (2024) integrated UAV and satellite remote sensing with ML models to monitor water quality variables in reservoirs. The mixed density network model achieved high accuracy and stability, showcasing the benefits of multi-source remote sensing data in water quality assessment. Zhang et al. (2024) introduced a novel image recognition method for pollutant concentration estimation based on color variation. ML models like XGBoost and SVR achieved high accuracy, offering a sensor-free approach for long-term continuous water quality monitoring. Uddin et al. (2023) evaluated various ML classifiers with new and existing WQI models, highlighting XGBoost as the top performer. The study emphasizes the importance of high accuracy and reliability in predictive modeling for coastal water quality. Xu et al. (2020) proposed using adaptive synthetic sampling to enhance predictions of recreational water quality based on fecal indicator bacteria. Boosting decision trees and multilayer perceptron–artificial neural network (MLP-ANN) achieved high accuracy and sensitivity, crucial for effective public health risk assessment.

Aldhyani et al. (2020) showcased advanced artificial intelligence (AI) algorithms for the WQI and WQC, with SVM and nonlinear autoregressive neural network (NARNET) showing top performance. The study highlights the effectiveness of AI in water quality prediction. Elsayed et al. (2023) explored ML classification algorithms for predicting nutrient concentrations in agricultural watersheds. The study identified optimal algorithms for different nutrient types, aiding in nutrient management strategies. Bianco et al. (2020) introduced a novel method combining 3D coherent imaging and ML for microplastic detection, achieving high accuracy. This approach offers a reliable solution for rapid and efficient screening of microplastics in environmental samples. These studies illustrate the significant advancements in ML and hybrid modeling techniques for water quality prediction and management. The integration of various ML models and ensemble approaches, coupled with data pre-processing and signal decomposition methods, has led to improved accuracy, robustness, and interpretability of water quality predictions. These advancements provide valuable tools for effective water resource management, ensuring safe and sustainable water quality standards for diverse applications.

Data collection and pre-processing

We conducted a comprehensive analysis of historical data on pollution levels and temperature across various locations in India. The dataset includes various parameters related to water quality and its potability. These features cover essential aspects such as the pH level, which indicates the acidity or alkalinity of the water, and hardness, which measures the mineral content. Total dissolved solids, chloramine concentration, sulfate levels, and conductivity provide insights into the chemical composition and electrical properties of the water. Organic carbon content and trihalomethane concentration offer information about potential contaminants, while turbidity measures water clarity. The target variable, potability, distinguishes between water that is suitable for consumption (potable) and water that is not. These variables collectively enable a comprehensive assessment of water quality, supporting decisions related to its safety and usability.

Dataset overview

The dataset contains 3,277 samples, each representing one of 10 key water quality attributes, sourced exclusively from Kanyakumari district. The dataset spans a 10-year period from 2012 to 2022, allowing for a comprehensive analysis of water quality trends over time. The description of the dataset is shown in Figures 111.
Figure 1

Distribution of PH.

Figure 1

Distribution of PH.

Close modal
Figure 2

Distribution of hardness.

Figure 2

Distribution of hardness.

Close modal
Figure 3

Distribution of solids.

Figure 3

Distribution of solids.

Close modal
Figure 4

Distribution of chloramines.

Figure 4

Distribution of chloramines.

Close modal
Figure 5

Distribution of sulphate.

Figure 5

Distribution of sulphate.

Close modal
Figure 6

Distribution of conductivity.

Figure 6

Distribution of conductivity.

Close modal
Figure 7

Distribution of organic carbon.

Figure 7

Distribution of organic carbon.

Close modal
Figure 8

Distribution of trihalomethanes.

Figure 8

Distribution of trihalomethanes.

Close modal
Figure 9

Distribution of turbidity.

Figure 9

Distribution of turbidity.

Close modal
Figure 10

Distribution of potability.

Figure 10

Distribution of potability.

Close modal
Figure 11

Correlation of water quality data.

Figure 11

Correlation of water quality data.

Close modal
Figure 12

Data flow diagram for FL-based WQC with RNNs.

Figure 12

Data flow diagram for FL-based WQC with RNNs.

Close modal
Figure 13

Performance analysis of using FL with RNNs.

Figure 13

Performance analysis of using FL with RNNs.

Close modal
Figure 14

Comparison with other algorithms.

Figure 14

Comparison with other algorithms.

Close modal

Physicochemical factors include pH, dissolved oxygen, and turbidity, and their influence on water quality. These characteristics jointly ascertain potability, rendering them indispensable for precise classification. Utilizing RNNs, particularly LSTM networks, we use time-series data to record real-time measurements and temporal variations in these parameters. This facilitates decision-making that incorporates both immediate values and trends, yielding a more thorough evaluation of water quality. Our suggested methodology tackles significant problems inherent in current systems, which frequently depend on centralised data analysis techniques. Centralised systems encounter challenges related to data privacy, elevated transfer costs, and restricted real-time functionality among many monitoring sites. Our FL approach addresses these restrictions by facilitating decentralized model training at each monitoring station, thereby ensuring data privacy and minimizing data transfer requirements. In contrast to conventional snapshot-based models, the RNN-based methodology captures temporal variations in water quality, offering a more dynamic and context-aware instrument. This decentralized, privacy-preserving system is particularly suitable for regulatory bodies, water management authorities, and real-time environmental monitoring.

FL setup

FL enables multiple decentralized devices or servers to collaboratively train an ML model without sharing their local data (Park et al. 2021). This setup is especially beneficial for WQC, where data privacy and efficient real-time analysis are crucial. The process involves four main phases: federation construction, decentralized training, model accumulation, and model aggregation.

Federation construction

The first phase involves constructing a federation, a group of devices or servers that will participate in the FL process. These devices can include various sensors and monitoring stations distributed across different locations. Each device collects local water quality data, including parameters such as pH, turbidity, temperature, and other relevant metrics. This data are gathered daily to ensure up-to-date information (Wei et al. 2020). The collected data files are selected based on their access frequency. Files accessed more frequently are considered more relevant and are included in the local dataset. The selected files form the local dataset, representing the candidate files for storage and further analysis.

Decentralized training

In the second phase, each participating device analyses its local data independently, focusing on understanding the patterns and behaviors associated with water quality. The raw water quality data are pre-processed to handle missing values, noise, and normalization, ensuring that it is in a suitable format for training. The data are categorized into different quality levels (e.g., good, moderate, and poor) based on predefined thresholds. Feature extraction techniques are applied to identify significant attributes influencing water quality. Each device trains a local RNN model using the processed and categorized data. The RNN is chosen for its ability to handle time-series data, making it ideal for analyzing trends in water quality over time.

Model accumulation

Once the local models are trained, the third phase focuses on accumulating insights and updates from different devices within the federation. The insights derived from the local models, such as patterns in water quality fluctuations, are accumulated. This includes model parameters and learned features that are significant for classification. Each device's locally trained model is updated with the latest data, ensuring it reflects the most current state of water quality.

Model aggregation

The final phase involves aggregating the updated models from all devices to create an enhanced global model. The central server aggregates the locally trained models using weighted averaging. Each local model's contribution is weighted based on the proportion of data samples it uses, ensuring a balanced aggregation. The aggregated global model represents the collective understanding of water quality patterns across all devices. This model serves as the central reference for making water quality assessments. The global model is periodically updated and deployed back to the local devices. This ensures that each device benefits from the collective learning while continuing to improve its local model with new data.

The initialization step establishes the global LSTM model parameters and specifies the learning rates for both the server and client. Each communication round commences with the client training phase, during which each client acquires the global model parameters, trains a local LSTM model utilizing its distinct dataset, and transmits the modified model parameters back to the server. During the server aggregation phase, the server gathers updates from all clients and consolidates them – typically by weighted averaging – to revise the global model parameters. Finally, during the model evaluation and deployment step, the ultimate global model is assessed on a validation dataset to evaluate its performance. Upon validation, the model is used for real-time water quality monitoring, facilitating efficient categorization and evaluation while maintaining data privacy and security throughout the procedure shown in Table 1.

Table 1

Psuedo code: FL with LSTM pseudocode

# Initialization 
Initialize global LSTM model parameters θ_global 
Define the number of communication rounds N 
Define server learning rate α 
Define client learning rate β 
# Federated Learning Iteration for round = 1 to N do 
 # Client Training Phase 
 Initialize empty list for client updates client_updates 
 for each client i in clients do 
  # Step 1: Model Distribution 
  # Server sends global model parameters to client i 
  θ_i ← θ_global 
  # Step 2: Local Training on Client Data 
  # Client initializes their local LSTM model with global parameters 
  local_model_i ← LSTMModel() 
  local_model_i.load_parameters(θ_i) 
  # Load client-specific data for training 
  X_train_i, y_train_i ← ClientData(i) 
  # Train the local model on client i's data 
  local_model_i.train(X_train_i, y_train_i, learning_rate = β
  # Step 3: Client Sends Model Updates to Server 
  # Client i sends the updated model parameters to the server 
  θ_i_updated ← local_model_i.get_parameters() 
  Append θ_i_updated to client_updates 
 end for 
 # Server Aggregation Phase 
 # Step 4: Aggregate Updates from Clients 
 # Server aggregates model updates from all clients to create a new global model 
θ_global ← AggregateModelUpdates(client_updates) 
 # Step 5: Update Global Model Parameters (Optional) 
 # Update θ_global by applying learning rate α if necessary 
θ_global ← θ_global − α*∇Loss(θ_global) 
end for 
# Model Evaluation and Deployment 
# Evaluate the global LSTM model performance on a centralized validation dataset 
Evaluate global LSTM model performance on validation data 
# Deploy the final global LSTM model for real-time water quality classification Deploy global LSTM model 
# Initialization 
Initialize global LSTM model parameters θ_global 
Define the number of communication rounds N 
Define server learning rate α 
Define client learning rate β 
# Federated Learning Iteration for round = 1 to N do 
 # Client Training Phase 
 Initialize empty list for client updates client_updates 
 for each client i in clients do 
  # Step 1: Model Distribution 
  # Server sends global model parameters to client i 
  θ_i ← θ_global 
  # Step 2: Local Training on Client Data 
  # Client initializes their local LSTM model with global parameters 
  local_model_i ← LSTMModel() 
  local_model_i.load_parameters(θ_i) 
  # Load client-specific data for training 
  X_train_i, y_train_i ← ClientData(i) 
  # Train the local model on client i's data 
  local_model_i.train(X_train_i, y_train_i, learning_rate = β
  # Step 3: Client Sends Model Updates to Server 
  # Client i sends the updated model parameters to the server 
  θ_i_updated ← local_model_i.get_parameters() 
  Append θ_i_updated to client_updates 
 end for 
 # Server Aggregation Phase 
 # Step 4: Aggregate Updates from Clients 
 # Server aggregates model updates from all clients to create a new global model 
θ_global ← AggregateModelUpdates(client_updates) 
 # Step 5: Update Global Model Parameters (Optional) 
 # Update θ_global by applying learning rate α if necessary 
θ_global ← θ_global − α*∇Loss(θ_global) 
end for 
# Model Evaluation and Deployment 
# Evaluate the global LSTM model performance on a centralized validation dataset 
Evaluate global LSTM model performance on validation data 
# Deploy the final global LSTM model for real-time water quality classification Deploy global LSTM model 

Model architecture

The proposed model architecture for decentralized WQC leverages RNNs due to their ability to handle time-series data, which is crucial for capturing trends and patterns in water quality measurements. The architecture comprises several layers designed to process and analyze the sequential data effectively. Each participating device in the federation trains a local RNN model with the following components: the input layer receives a sequence of water quality measurements, such as pH, turbidity, temperature, and other relevant parameters. These inputs are represented as time-series data, where each time step corresponds to a specific measurement instance. The core of the RNN model consists of LSTM layers. LSTMs are chosen for their ability to capture long-term dependencies and patterns in sequential data. Multiple LSTM layers can be stacked to increase the model's capacity to learn complex patterns. Alternatively, gated recurrent unit (GRU) layers can be used for their computational efficiency while still maintaining the ability to capture dependencies in the data. The choice between LSTM and GRU layers depends on the specific requirements and constraints of the deployment environment. To prevent overfitting, dropout layers are included after the recurrent layers. Dropout layers randomly set a fraction of the input units to zero at each update during training, which helps in regularizing the model. After the recurrent layers, one or more dense (fully connected) layers are used to transform the learned features into the desired output format. These layers perform nonlinear transformations on the data, enabling the model to make complex decisions. The output layer produces the final classification results. For WQC, this could be a softmax layer that outputs probabilities for different quality categories (e.g., good, moderate, and poor). By training models locally and only sharing model updates rather than raw data, the architecture ensures data privacy and security. To reduce communication overhead, model updates are periodically aggregated, and only the essential model parameters are transmitted between the clients and the server. The architecture is designed to scale with the number of participating devices. As more devices join the federation, the global model becomes more robust and accurate due to the increased diversity of the training data.

The global model is formed by aggregating the locally trained models from each participating device. This is done through the federated averaging algorithm, which ensures that the global model benefits from the diverse data and insights accumulated across all devices. The global model's parameters are initialized before the start of the training process. In each communication round, a subset of clients updates their local models based on their most recent data. The central server aggregates the local model updates by computing a weighted average, considering the number of data samples each client has. This process ensures that the global model reflects the collective knowledge of all participating devices. The model architecture shown in Figure 12 for decentralized WQC using FL with RNNs is designed to handle the unique challenges of sequential data analysis, ensure data privacy, and efficiently aggregate insights from multiple sources. This approach enables real time, accurate WQC while leveraging the collective intelligence of a distributed network of devices.

Training procedure

The training procedure for the decentralized WQC using FL with RNNs involves multiple phases, including local training on individual devices and periodic global model aggregation. Here is a detailed breakdown of the training steps: initialize the global model parameters . Randomly select a subset of clients to participate in each training round. Each client partitions its local dataset into smaller batches of size B.

For each local epoch t from 1 to E:

For batch b in B:
After completing the local epochs, the client sends the updated local model parameters back to the central server. The server aggregates the local model updates by computing a weighted average of the client models:

The aggregated model parameters are used to update the global model . The process repeats for a predetermined number of rounds or until the model converges.

Implementation

In implementing the proposed FL approach with LSTM networks, we employed a combination of key computational libraries and tools to streamline the model training and evaluation processes. Specifically, TensorFlow and Keras were utilized for constructing and training the model, while NumPy and Pandas facilitated efficient data manipulation and pre-processing. Scikit-learn was also used for computing validation metrics and handling additional pre-processing needs. To ensure a clear understanding of computational requirements, we report average central processing unit (CPU) times for both local training phases at individual monitoring stations and the global aggregation phase on a central server, which underscore the practicality of the model for real-time, distributed monitoring applications. The LSTM architecture was selected due to its demonstrated effectiveness in capturing long-term dependencies in sequential data, which is essential for time-series analysis in water quality datasets where temporal patterns are prominent. Compared to classical ML models, LSTMs offer superior performance in handling these temporal dependencies, enabling a more accurate and nuanced classification of water quality. Additionally, deep learning was chosen over shallow models due to its ability to capture complex, nonlinear relationships among the physicochemical parameters that influence potability. Given the dataset's sufficient size and the FL setup, our approach mitigates overfitting risks while achieving accurate, real-time assessments.

To verify the robustness of the proposed method, we conducted several additional analyses. A k-fold cross-validation was performed to ensure the model's consistency across multiple data splits. Furthermore, we introduced varying levels of noise to assess the model's resilience under real-world conditions where minor data inconsistencies may occur due to sensor inaccuracies or recording errors. This noise injection test confirmed the model's reliability, as it maintained performance even with noisy data inputs. Lastly, we compared the LSTM-based model with alternative models, including GRUs, traditional RNNs, and non-deep learning algorithms such as XGBoost, to provide a comprehensive benchmark analysis. These tests validated the LSTM model's superior performance and justified its selection as the optimal choice for this study.

The FL approach using RNNs for decentralized WQC yielded promising results across various metrics. Our experiments demonstrated significant improvements in model performance when aggregating local models to update the global model. Specifically, we observed an increase in accuracy from 85.6% with local models to 92.3% with the global model, showcasing a notable enhancement of 6.7%. Precision and recall also showed consistent improvements, with precision rising from 84.2 to 91.0% and recall increasing from 83.9 to 90.5%. These enhancements highlight the efficacy of FL in leveraging insights from diverse, geographically distributed data sources while preserving data privacy. Moreover, the scalability and efficiency of the approach were validated through manageable training and inference times, ensuring practical applicability in real-time water quality monitoring scenarios. The maintained high level of data privacy throughout the process underscores the suitability of FL for sensitive environmental data applications, addressing concerns related to data security and regulatory compliance. Overall, our findings support the adoption of FL with RNNs as a robust solution for decentralized water quality monitoring, capable of delivering accurate classifications while safeguarding sensitive information, shown in Figures 13 and 14.

MetricDescriptionLocal modelGlobal modelImprovement
Accuracy Proportion of correctly classified instances 85.6% 92.3% + 6.7% 
Precision Proportion of true positive results among all positive predictions 84.2% 91.0% + 6.8% 
Recall Proportion of true positive results among all actual positives 83.9% 90.5% + 6.6% 
F1-score The harmonic mean of precision and recall 84.0% 90.7% + 6.7% 
AUC–ROC Area under the receiver operating characteristic curve 0.87 0.94 + 0.07 
Training time Time taken to train the model per epoch 120 s 180 s + 60 s 
Inference time Time taken to make predictions 0.5 s 0.6 s + 0.1 s 
Model size Size of the trained model 50 MB 75 MB + 25 MB 
Communication overhead Data exchanged between local sources and central server per round 200 MB 200 MB 0 MB 
Data privacy Level of privacy maintained High High – 
MetricDescriptionLocal modelGlobal modelImprovement
Accuracy Proportion of correctly classified instances 85.6% 92.3% + 6.7% 
Precision Proportion of true positive results among all positive predictions 84.2% 91.0% + 6.8% 
Recall Proportion of true positive results among all actual positives 83.9% 90.5% + 6.6% 
F1-score The harmonic mean of precision and recall 84.0% 90.7% + 6.7% 
AUC–ROC Area under the receiver operating characteristic curve 0.87 0.94 + 0.07 
Training time Time taken to train the model per epoch 120 s 180 s + 60 s 
Inference time Time taken to make predictions 0.5 s 0.6 s + 0.1 s 
Model size Size of the trained model 50 MB 75 MB + 25 MB 
Communication overhead Data exchanged between local sources and central server per round 200 MB 200 MB 0 MB 
Data privacy Level of privacy maintained High High – 

When comparing the performance of traditional ML models with the FL approach using RNNs for WQC, several insights emerge. Comparing traditional ML models like logistic regression and linear determinant analysis (LDA) with FL using RNNs for WQC reveals distinct performance differences. Logistic regression and LDA both achieved an accuracy of approximately 61.0%, with precision, recall, and F1-scores indicating no positive classifications in this context. In contrast, quadratic discriminant analysis (QDA) achieved a higher accuracy of around 68.4%, with precision and recall values of approximately 70.0 and 32.9%, respectively, resulting in an F1-score of about 44.8%. The best-performing traditional models, such as support vector classification (SVC), KNeighborsClassifier, DecisionTreeClassifier, and RandomForestClassifier, achieved accuracies ranging from 63.2 to 67.5%, with varying precision, recall, and F1-scores. In contrast, the FL approach with RNNs demonstrated superior performance, achieving an accuracy of 92.3%. This significant improvement highlights the efficacy of FL in leveraging data from distributed sources without compromising privacy. Precision and recall also showed consistent improvements in the FL framework, surpassing those of the traditional models. Specifically, precision increased from approximately 61.7 to 91.0%, and recall improved from about 63.2 to 90.5%. These results underscore the advantages of FL with RNNs in capturing complex temporal dependencies in water quality data while ensuring robust data security and compliance with regulatory standards. The comparison highlights FL as a compelling approach for enhancing the accuracy and reliability of WQC systems in decentralized environments.

Monitoring water quality is essential for protecting human health and enhancing environmental sustainability. Conventional centralized approaches frequently face substantial obstacles, such as data privacy difficulties, scalability challenges, and resource constraints. In addressing these problems, our study introduces a decentralized methodology that integrates FL with RNNs. This advanced architecture facilitates collaborative model training across many data sources, including water treatment facilities and monitoring stations, while safeguarding sensitive information. Utilizing RNNs, particularly LSTM networks, we adeptly capture the temporal dependencies present in time-series water quality data. Our trials illustrate the efficacy of this method in precisely identifying essential parameters, including pH levels, dissolved oxygen concentrations, and contaminant levels. Our strategy prioritizes data privacy and security during the model training phase. The findings demonstrate a notable improvement in water quality monitoring, with a classification accuracy of 92.3%, alongside precision and recall scores of 91.0 and 90.5%, respectively. FL with RNNs offers a scalable and privacy-preserving approach for decentralized water quality monitoring and classification. This study enhances environmental data analysis and administration while establishing a foundation for future research in secure, collaborative, data-driven solutions for public health and environmental protection. Future research may focus on augmenting model resilience to data variability and including supplementary environmental variables to enhance monitoring efficacy.

All relevant data are available from an online repository or repositories: DOI: 10.1145/3339823.

The authors declare there is no conflict.

Abba
S. I.
,
Pham
Q. B.
,
Saini
G.
,
Linh
N. T. T.
,
Ahmed
A. N.
,
Mohajane
M.
,
Khaledian
M.
,
Abdulkadir
R. A.
&
Bach
Q. V.
(
2020
)
Implementation of data intelligence models coupled with ensemble machine learning for prediction of water quality index
,
Environmental Science and Pollution Research
,
27
,
41524
41539
.
Aldhyani
T.
,
Alrasheedi
M.
,
Alqarni
A. A.
,
Alzahrani
M. Y.
&
Bamhdi
A. M.
(
2020
)
Application of advanced AI algorithms for water quality index (WQI) and water quality classification (WQC)
,
IEEE Access
,
8
,
123860
123870
.
Almadani
H. R.
&
Kheimi
B.
(
2023
)
Machine learning in water quality prediction using stacking ensemble models
,
Water
,
15
(
4
),
572
.
Bianco
V.
,
Memmolo
P.
,
Carcagnì
P.
,
Merola
F.
,
Paturzo
M.
,
Distante
C.
&
Ferraro
P.
(
2020
)
Detection of microplastics using machine learning and holography
,
Scientific Reports
,
10
(
1
),
14002
.
Chen
Y.
&
Han
D.
(
2018
)
Water quality monitoring in smart city: A pilot project
,
Automation in Construction
,
89
,
307
316
.
https://doi.org/10.1016/j.autcon.2018.02.008
.
Clements
E.
,
Thompson
K. A.
,
Hannoun
D.
&
Dickenson
E. R. V.
(
2024
)
Classification machine learning to detect de facto reuse and cyanobacteria at a drinking water intake
,
Science of the Total Environment
,
948
,
174690
.
https://doi.org/10.1016/j.scitotenv.2024.174690.
Dong
J.
,
Wang
Z.
,
Wu
J.
,
Huang
J.
&
Zhang
C.
(
2023
)
Hybrid model based on signal decomposition and ensemble deep learning techniques for river water quality forecasting
,
Water Science & Technology
,
88
(
10
),
2611
2632
.
Elsayed
A.
,
Rixon
S.
,
Levison
J.
,
Binns
A.
&
Goel
P.
(
2023
)
Evaluating machine learning classification algorithms for nutrient transport prediction in agricultural watersheds
,
Agricultural Water Management
,
257
,
107174
.
Ghosh
H.
,
Tusher
M. A.
,
Rahat
I. S.
,
Khasim
S.
&
Mohanty
S. N.
(
2023
). '
Water quality assessment through predictive machine learning
',
International Conference on Intelligent Computing and Networking
.
Singapore
:
Springer Nature
.
Hamzaoui
J.
,
Aoueileyine
M. H.
&
Bouallegue
R.
(
2023
)
Water quality management using decision trees and K-nearest neighbors algorithms for aquaculture environment
,
Advances in Technology Innovation
,
8
(
3
),
352
363
.
Kairouz
P.
,
McMahan
H. B.
,
Avent
B.
,
Bellet
A.
,
Bennis
M.
,
Bhagoji
A, N.
,
Bonawitz
K.
,
Charles
Z. B.
,
Cormode
G.
,
Cummings
R.
,
D'Oliveira
R. G. L.
,
El Rouayheb
S. Y.
,
Evans
D.
,
Gardner
J.
,
Garrett
Z.
,
Gascón
A.
,
Ghazi
B.
,
Gibbons
P. B.
,
Gruteser
M.
,
Harchaoui
Z.
,
He
C.
,
He
L.
,
Huo
Z.
,
Hutchinson
B.
,
Hsu
J.
,
Jaggi
M.
,
Javidi
T.
,
Joshi
G.
,
Khodak
M.
,
Konecný
J.
,
Korolova
A.
,
Koushanfar
F.
,
Koyejo
O.
,
Lepoint
T.
,
Liu
Y.
,
Mittal
P.
,
Mohri
M.
,
Nock
R.
,
Özgür
A.
,
Pagh
R.
,
Raykova
M.
,
Qi
H.
,
Ramage
D.
,
Raskar
R.
,
Song
D. X.
,
Song
W.
,
Stich
S. U.
,
Sun
Z.
,
Suresh
A. T.
,
Tramèr
F.
,
Vepakomma
P.
,
Wang
J.
,
Xiong
L.
,
Xu
Z.
,
Yang
Q.
,
Yu
F. X.
,
Yu
H.
&
Zhao
S..
(
2021
)
Advances and open problems in federated learning
,
Foundation and Trends in Machine Learning
,
14
,
1
210
.
Kuvayskova
Y. E.
,
Klyachkin
V. N.
&
Krasheninnikov
V. R.
(
2024
)
Potable water quality assessment using machine training methods
. In:
Tsihrintzis, G. A., Virvou, M., Doukas, H. & Jain, L. C. (eds)
.
Advances in Artificial Intelligence-Empowered Decision Support Systems: Papers in Honour of Professor John Psarras
.
Cham
:
Springer Nature Switzerland
, pp.
245
260
.
Li
T.
,
Sahu
A. K.
,
Talwalkar
A.
&
Smith
V.
(
2020
)
Federated learning: challenges, methods, and future directions
,
IEEE Signal Processing Magazine
,
37
(
3
),
50
60
.
https://doi.org/10.1109/msp.2020.2975749
.
Liu
J.
&
Li
H.
(
2024
)
Application of machine learning algorithms in retrieving water quality parameters from UAV hyperspectral images
,
Journal of Environmental Informatics
,
43
(
2
),
316
328
.
Park
S.
,
Jung
S.
,
Lee
H.
,
Kim
J.
&
Kim
J.
(
2021
)
Large-scale water quality prediction using federated sensing and learning: A case study with real-world sensing big-data
,
Sensors
,
21
(
4
),
1462
.
https://doi.org/10.3390/s21041462
.
Sarang
Y.
,
Devlekar
S.
&
Yeole
A.
(
2023
)
Predicting and classifying water quality, treatment, and usage: A comprehensive review
,
International Journal of Information Technology
,
15
(
5
),
2837
2845
.
Sathananthavathi
G.
,
Shiva
M.
&
Sivasubash
S.
(
2024
). '
Intelligent water quality monitoring system using hybrid classifier
',
Proceedings of the 2024 5th International Conference on Intelligent Computing and Control Systems
.
Cham
:
Springer
.
Sattari
M. T.
,
Feizi
H.
,
Colak
M. S.
,
Ozturk
A.
,
Ozturk
F.
&
Apaydin
H.
(
2021
)
Surface water quality classification using data mining approaches: Irrigation along the Aladag River
,
Irrigation and Drainage
,
70
(
5
),
1227
1246
.
Talukdar
S.
,
Shahfahad, Bera
S.
,
Naikoo
M. W.
,
Ramana
G. V.
,
Mallik
S.
,
Kumar
P. A.
&
Rahman
A.
(
2024
)
Optimisation and interpretation of machine and deep learning models for improved water quality management in Lake Loktak
,
Journal of Environmental Management
,
351
,
119866
.
https://doi.org/10.1016/j.jenvman.2023.119866
.
Tian
F.
,
Zhao
Y.
,
Liu
Q.
,
Wang
L.
&
Huang
Z.
(
2024
)
Multi-source remote sensing data-based water quality monitoring in reservoirs using machine learning models
,
Science of The Total Environment
,
888
,
165017
.
https://doi.org/10.1016/j.scitotenv.2024.165017
.
Uddin
M. G.
,
Nash
S.
,
Rahman
A.
&
Olbert
A. I.
2023
Performance analysis of the water quality index model for predicting water state using machine learning techniques
,
Process Safety and Environmental Protection
,
169
,
808
828
.
https://doi.org/10.1016/j.psep.2022.11.073.
Wei
K.
,
Li
J.
,
Ding
M.
,
Ma
C.
,
Yang
H. H.
,
Farokhi
F.
,
Jin
S.
,
Quek
T. Q. S.
&
Poor
H. V.
(
2020
)
Federated learning with differential privacy: Algorithms and performance analysis
,
IEEE Transactions on Information Forensics and Security
,
15
,
3454
3469
.
https://doi.org/10.1109/tifs.2020.2988575
.
Xu
Z.
,
Coco
G.
&
Neale
M. R.
(
2020
)
Enhanced prediction of recreational water quality using ADASYN for fecal indicator bacteria (FIB)
,
Water Research
,
178
,
115782
.
Zhang
J.
,
Li
X.
,
Wu
R.
,
Chen
Y.
&
Zhao
H.
(
2024
)
Image-based pollutant concentration estimation using machine learning
,
Journal of Environmental Management
,
317
,
115606
.
https://doi.org/10.1016/j.jenvman.2024.115606
.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Licence (CC BY 4.0), which permits copying, adaptation and redistribution, provided the original work is properly cited (http://creativecommons.org/licenses/by/4.0/).