Next Article in Journal
Quartz Enhanced Photoacoustic Spectroscopy on Solid Samples
Previous Article in Journal
Structural Design and Parameter Optimization of Magnetic Gradient Tensor Measurement System
Previous Article in Special Issue
Smart City as Cooperating Smart Areas: On the Way of Symbiotic Cyber–Physical Systems Environment
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Towards Reliability in Smart Water Sensing Technology: Evaluating Classical Machine Learning Models for Outlier Detection

by
Mimoun Lamrini
1,2,*,
Bilal Ben Mahria
3,*,
Mohamed Yassin Chkouri
2 and
Abdellah Touhafi
1,4
1
Department of Engineering Sciences and Technology (INDI), Vrije Universiteit Brussel (VUB), 1050 Brussels, Belgium
2
SIGL Laboratory, National School of Applied Sciences of Tetuan, Abdelmalek Essaadi University, Tetuan 93000, Morocco
3
SIA Laboratory, Faculty of Science and Technology, Sidi Mohamed Ben Abdellah University, Fez 30000, Morocco
4
Department of Electronics and Informatics (ETRO), Vrije Universiteit Brussel (VUB), 1050 Brussels, Belgium
*
Authors to whom correspondence should be addressed.
Sensors 2024, 24(13), 4084; https://doi.org/10.3390/s24134084
Submission received: 27 May 2024 / Revised: 20 June 2024 / Accepted: 21 June 2024 / Published: 24 June 2024

Abstract

:
In recent years, smart water sensing technology has played a crucial role in water management, addressing the pressing need for efficient monitoring and control of water resources analysis. The challenge in smart water sensing technology resides in ensuring the reliability and accuracy of the data collected by sensors. Outliers are a well-known problem in smart sensing as they can negatively affect the viability of useful analysis and make it difficult to evaluate pertinent data. In this study, we evaluate the performance of four sensors: electrical conductivity (EC), dissolved oxygen (DO), temperature (Temp), and pH. We implement four classical machine learning models: support vector machine (SVM), artifical neural network (ANN), decision tree (DT), and isolated forest (iForest)-based outlier detection as a pre-processing step before visualizing the data. The dataset was collected by a real-time smart water sensing monitoring system installed in Brussels’ lakes, rivers, and ponds. The obtained results clearly show that the SVM outperforms the other models, showing 98.38% F 1 -score rates for pH, 96.98% F 1 -score rates for temp, 97.88% F 1 -score rates for DO, and 98.11% F 1 -score rates for EC. Furthermore, ANN also achieves a significant results, establishing it as a viable alternative.

1. Introduction

In recent years, the advancement of smart water sensing technology has revolutionized water management practices, offering efficient solutions for monitoring and controlling water resources. Poor water quality poses a severe threat to human health, ecosystems, plants, and animals, emphasizing the critical importance of monitoring water quality in environmental systems [1]. Traditionally, manual laboratory-based testing has been the primary method for water quality monitoring, but it is often costly, time-consuming, and lacks real-time feedback. Thus, the intersection of technology and environmental sustainability has become imperative for ensuring efficient water management [2].
Smart water sensing technology represents a pivotal milestone in water management, leveraging data collected by various sensors deployed in diverse aquatic environments. However, the reliability and accuracy of the collected data are often confounded by anomalies caused by technical issues, which can hinder fault detection and diagnosis [1,3]. Addressing this challenge, our study focuses on detecting outliers to ensure efficient water management, employing machine learning techniques for anomaly detection [4].
Specifically, we evaluate the performance of four key sensors pH, Dissolved Oxygen (DO), Electrical Conductivity (EC), and Temperature (Temp) using classical Machine Learning (ML) algorithms: Support Vector Machine (SVM), Artificial Neural Network (ANN), Decision Tree (DT), and Isolated Forest-based (iForest) outlier detection. Our evaluation is based on data collected from a real-time smart water sensing monitoring system deployed across various environments in Brussels, including lakes, rivers, and ponds.
Our experimental findings underscore the superior efficiency of SVM, demonstrating exceptional F 1 -score rates across multiple sensors. Additionally, we highlight the noteworthy performance of ANN, suggesting its potential capability as a primary alternative for addressing the challenge of outlier detection in water quality monitoring.
In this paper, we present a comprehensive exploration of outlier detection techniques in the context of smart water sensing technology. By assessing the efficacy of classical ML models, we aim to provide valuable insights into enhancing the reliability and accuracy of water quality data analysis, thus contributing to the advancement of water resource management practices.
The rest of this paper is organized as follows: The related study that is relevant to our issue is covered in Section 2. Section 3 an overview of the various types of anomalies is provided, and different indicators have been used to classify anomaly detection techniques. In Section 4 we provide a description of the sensors used in this research as well as the water quality standards provided by the world health organization. The evaluation methodology is also provided in Section 5. In Section 6 outline the evaluation flow of the experiments and the experimental setup utilized. Section 7 contains the results and discussion of the experimental. Finally, we conclude this paper in Section 8.

2. Related Work

We conducted a detailed analysis of the literature on ML-based approaches and anomaly detection used in water sensor technology, this domain has gained more attention in recent years due to the increasing importance of this vital substance. Furthermore, this section covers the critical aspects of collection data and pre-processing steps. It aims to provide an overview of the literature concerning the implementation of sensors, communication and research on the ML-techniques for smart water technologies. Our main objectives were to understand about the most effective approaches being used and to identify existing gaps.
Anomalies within water quality data from river sensors can be automatically identified using advanced detection methods. The authors in [5] demonstrate that distinct anomalies, such as abrupt spikes and level alterations, can be reliably detected using regression-based techniques. However, these techniques become less effective when multiple water quality parameters are analyzed concurrently. Their framework focuses on automated anomaly detection within high-frequency datasets, particularly for turbidity, conductivity, and river level metrics from rivers feeding into the Great Barrier Reef. Similarly, the study by [6] addresses the critical need to mitigate the spread of harmful substances within river systems. The authors propose a methodology that combines a Bayesian autoregressive model with the Isolation Forest algorithm, effectively predicting variations in water quality and detecting anomalies. In another notable study, ref. [7] evaluates different outlier detection methods for water sensor data from Dutch water authorities. Among these methods, the QR-MLP model is identified as the most effective, detecting both simulated and real anomalies without requiring specific rules for each type of outlier. ML techniques have proven to be powerful tools in the detection of anomalies in water quality data. The study in [8] investigates ML techniques for detecting anomalies in water quality data from a treatment plant in Kenya. It highlights the Local Outlier Factor algorithm as particularly effective for identifying outliers in turbidity and pH parameters and compares four time-series anomaly detection methods. Further expanding on anomaly detection in water treatment, ref. [4] compares Deep Neural Networks (DNNs) and Support Vector Machines (SVMs) within a Cyber-Physical System (CPS). The study finds that while DNNs produce fewer false positives, SVMs detect slightly more anomalies, indicating that each method has distinct advantages depending on the application context. The application of the One-Class Support Vector Machine (OC-SVM) technique in water supply data is explored in [9], where high abnormality scores are attributed to entries with extreme values and unusual sequences. This study, based on data from the Ministry of Water Resources of China, highlights the effectiveness of OC-SVM in identifying significant anomalies. Real-time monitoring for drinking water quality is crucial, as illustrated in [10], which proposes the ADWICE data mining algorithm. Integrated into SCADA systems, this algorithm enhances anomaly detection accuracy by analyzing sensor data from multiple locations, addressing issues such as missing and inaccurate data. Building on the importance of early and accurate anomaly detection, in [11], the OddWater method utilizes statistical transformations and unsupervised outlier scoring to identify outliers caused by technical errors in sensor data, maintaining low false detection rates. This method is particularly effective for early detection in water quality monitoring systems. An innovative approach in environmental monitoring is presented in [12], where machine learning techniques and correlated sensor data improve outlier detection. By modeling individual sensor behavior and leveraging data correlations, this method significantly enhances data quality and reliability. For smart city applications, ref. [13] emphasizes the use of low-cost, low-power IoT sensors for water monitoring. The proposed anomaly detection system employs one-class classifiers to differentiate between harmless and hazardous substances in wastewater, demonstrating the potential for cost-effective and efficient monitoring solutions. The integration of IoT technologies in water management is further explored in [14], which uses ARIMA and HOT-SAX techniques to detect anomalies in consumption patterns from smart meters. This approach aims to prevent water waste and optimize resource use. In [15], a novel algorithm for real-time anomaly detection leverages historical patterns and prediction intervals to reduce false alarms and improve performance. The study emphasizes balancing time and space complexity to enhance the algorithm’s efficiency. Additionally, ref. [1] introduces MCN-LSTM, a deep learning-based technology for real-time water quality monitoring, achieving high accuracy in anomaly detection. This advancement supports decision-making and environmental protection in automated monitoring systems. Finally, in [16], the authors present a prototype water quality monitoring system based on IoT technologies, incorporating a LoRa repeater and an anomaly detection algorithm. By extending LoRa communication coverage and improving long-range wireless communication distance, the system enhances monitoring reliability while addressing communication and detection challenges. In conclusion, these studies collectively underscore the importance of developing sophisticated, reliable, and efficient methods for anomaly detection in water quality monitoring. The integration of machine learning, IoT technologies, and advanced algorithms offers promising solutions to address the challenges of environmental monitoring and protection.

3. Anomaly Detection

In this section, the background of anomaly detection is initially established, outlining the different types, before being linked to the methodology used in this work.
An anomaly is a collection of occurrences that deviate significantly from the remainder of the dataset. They are often referred to as outliers, novelties, or noise. Measurement variability or certain experimental mistakes that are often removed from the dataset might result in an outlier [17].
An anomaly might result in incorrect conclusions and major issues with data analysis. Anomalies might enter the dataset for a number of causes. For example, hardware that is utilized to take measurements may briefly malfunction. Data transfer mistakes might happen from time to time. In addition, system behavior variations, instrument malfunctions, human influences, and dishonest activity can all result in anomalies.

3.1. Anomaly Detection Framework

A general anomaly detection framework [18] is depicted in Figure 1 and was developed from a generic intrusion detection framework. A dataset of data instances with data characteristics is the input used in an anomaly detection system. The data may need to be pre-processed before continuing, depending on the detection strategy. After that, data processing is used to create a normal profile by applying either a training technique or past knowledge. An established threshold can be used to identify a test instance as anomalous once a normal profile has been created.
Several indicators may be used to classify anomaly detection techniques. A common indicator used to categorize them is the model employed in detection techniques. In this context, parametric (or statistical) and non-parametric models are the two general types of models [19]. When the data distribution is well-known and unlikely to vary often, parametric approaches are appropriate in stable contexts. Non-parametric models can be applied in dynamic settings with new and uncertain statistical distributions. Faster detection is offered by the first category, while detection generality is provided by the second. A comparison of parametric and non-parametric systems is presented in Table 1.
Additionally, there are two general categories of anomaly detection schemes: those that need previous knowledge of the system data and those that do not [20]. Similar to the prior classification, the first category offers quicker detection, and the second category offers more general detection. Supervised or semi-supervised learning can be used by the classifier in the first category [21]. When a system’s typical behavior changes, the former requires a large training set and requires retraining, but the latter generalizes findings from a smaller dataset and can instantly adjust to system changes. The second category employs unsupervised learning and makes the assumption that aberrations are quite different from the norm. It does not require prior information. Figure 2 provides a summary of this section and compares the various training techniques in Table 1. This work concentrates on one type since it highlights the data that designers must have before using the algorithm, which is important for anomaly detection techniques as will be discussed later.
There are three general types of anomalies: point anomalies, contextual anomalies, and collective anomalies [18].

3.1.1. Point Anomalies

A single data point that is isolated from other data points and is deemed unusual is called a point anomaly. Point anomalies are the most basic kind of anomaly and are often referred to as global anomalies. The majority of research focuses mostly on point anomaly detection.
The most basic kind of anomalies are point anomalies, commonly referred to as global anomalies. Most research focuses on point anomaly detection. As shown as in Figure 3. Being distinct from other normal data points, the red point is a point anomaly as it is located beyond the borders of the normal data cluster, which are represented by the grey points.

3.1.2. Contextual Anomalies

Contextual anomalies are those instances that are deemed abnormal within a specific context. A point is examined in several settings in order to ascertain whether or not it is abnormal. For instance, the context is nearly always temporal in the case of time-series data, which are recordings of a certain amount across time. Contextual outliers, on the other hand, are data points that significantly deviate from other data within the same context. Anomalous observations in a time series are those that deviate considerably from the observed pattern and do not follow the pattern in the time-series data. Figure 4 shows an example for contextual anomalies.

3.1.3. Collective Anomalies

An anomalous collection of data points is one that includes associated, linked, or sequential examples that dramatically deviate from the rest of the data.
When a subset of data points in a data collection have values that collectively deviate significantly from the values of the entire dataset but the individual data points’ values are normal in both a contextual and global sense, this is referred to as a collective anomaly. In Figure 5 showns a group of points.

4. Sensing Parameters

Water quality is described by the physical, chemical, and biological characteristics of water (Figure 6). It is a measure of the condition of water relative to the requirements of one or more biotic species and or to any human need or purpose. The most common standards used to assess water quality relate to the health of ecosystems, safety of human contact, and drinking water. The physical quality of water affects the aesthetic quality of water in the context of appearance, color, taste, foam, smell, EC, turbidity, total dissolved solids, and temp. Besides that, the chemical quality of water is used to determine the concentration of the dissolved chemicals and is crucial to ascertain its health and condition. Finally, the microbiological quality of water describes the occurrence of invisible organisms in water, such as bacteria and viruses. The microbes are contaminants that cause devastating effects on the health of humans when the water containing these microbes is ingested. Measuring each parameter is in most of the cases unnecessary. One way to track the status and changes of these dynamic systems is through indicators. An indicator represents the state or trend of specific environmental conditions over a given area and a specified period. For example, for the National Aquatic Resource Surveys (NARS), biological, chemical, and physical indicators were chosen to assess biological integrity, trophic state, recreational suitability, and key stressors impacting quality. Although there are more indicators and stressors, these are among the most representative nationally. Monitoring the temp, EC, turbidity, and DO level in conjunction with the pH deliver enough information on whether sanitation is required or, for example, if public access should be granted [23].
In this section, we provide an overview of the sensor used in this research (Figure 7). We employed four sensors sourced from Atlas-Scientific, Long Island, NY, USA, a company specializing in water monitoring and environmental robotics, offering laboratory-grade accuracy. These sensors will detect the following chemical indicators:
  • pH
  • Temp
  • EC
  • DO
The main sources of chemicals that reduce pH are acid rain and acid mine drainage. On the other hand, significant concentrations of organic substances or the presence of flora that produces acid can also cause this to occur naturally. Most living things are found in the pH range of 6.5 to 8.5. Numerous species, such as neutrophile bacteria, are susceptible to pH disturbances. Air and aquatic plants provide oxygen to water resources. Compared with motionless water in a pond or lake, running water dissolves more oxygen. Microorganisms may break down surplus organic materials, such massive algal blooms, to produce low oxygen levels (hypoxia), or no oxygen at all (anoxia). During this decomposition process, oxygen in the water is consumed. As DO clearly shows whether an aquatic resource can sustain aquatic life, it is regarded as a crucial indicator of water quality. Turbid waters absorb and scatter light, whereas clear waterways have minimal amounts of suspended soil particles or algae. Water purity affects the diversity and productivity of aquatic life significantly, as it is directly tied to light penetration. For instance, more sunshine can reach submerged aquatic plants in cleaner water. Thus, the vegetation creates food for fish, animals, and ducks, as well as habitats for fish and shellfish. It also produces oxygen. Furthermore, people often favor clean waterways for recreational and aesthetic reasons. Natural variations in wind patterns, sunshine levels, tides, and storm activity can all affect the purity of the water. It is impacted by a number of physical, chemical, and biological elements related to the natural geology and human usage of the surrounding watershed. Certain waterways have turbidity by nature. However, water that is very nutrient-rich (from fertilizers, for example) and sediment-rich (from building materials, for example) tends to be murky and less translucent. Conductivity rises with salinity because dissolved salts and other inorganic substances conduct electricity. Oil and other organic molecules, on the other hand, have a lower conductivity. Every body of water has a generally consistent range of conductivity, which can serve as a reference point for doing routine conductivity tests. Considerable changes in conductivity may be a sign that the aquatic resource has been contaminated by another source. Table 2 lists the used parameters and their standards.

5. Methodology

This section provides an overview of the methodology used to handle the data according to the approach utilized for outlier detection, based on four sensors highlighted in Section 4. These sensors are part of a real-time monitoring system designed for smart sensing of water bodies lakes, rivers, and ponds in Brussels. The collected data consist of environmental parameters collected and then sent to cloud infrastructure.
Our methodology starts with the data collecting process that involves using LoRa technology for wireless communication, where each sensor transmitted their observations to a central gateway. Subsequently, the collected data are transmitted to the server for in-depth analysis via the LoRaWAN protocol.
After receiving the data on the server, our analysis pipeline begins with data storage, preceding the division of the dataset into an 80% portion for training and a 20% portion for testing. Prior to the split operation, the data labeling process are performed before applying the machine learning models. Subsequently, we evaluated the used models relying on F 1 -score.
Finally, the phase of data visualization involved to clearly represent the collected data, ensuring an accurate interpretation and actionable insights. Figure 8 serves as an illustration of this process.

5.1. Deployment

In Brussels, various types of water bodies exist, including lakes, rivers, and ponds. Samples have been taken from five locations to test the sensors in different environments, as shown in Figure 9. These locations include the Brussels Royal Yacht Club (BRYC) on the Brussels canal (Figure 10b), the Brussels Sewer Museum, Wiels Swamps, Leybeek Ponds (Figure 10a), and the pond at Tournay-Solvay Park. A large number of dead fish were found floating on the surface of the Brussels canal (Figure 10c). During this period, significant increases in temperatures and sudden drops in DO levels were observed. Temp is a physical parameter that affects the equilibrium of the aquatic environment, influencing water density and altering water flow speed. Moreover, rising temp reduces the amount of DO in water, potentially leading to anoxia. Elevated water temp can also stimulate bacterial growth, which may contribute to the spread of diseases within the aquatic ecosystem [27,28]. Additionally, wastewater was discharged into the canal on that day, exacerbating the issue.

5.2. Datasets Selection

To enable the recognition of anomalies, classifiers used for sensors require training. For this purpose, datasets containing labeled water sensor information are crucial. The dataset utilized in this research was gathered from various locations via robots manufactured in our laboratory. This dataset consists of 2971 rows of data, and 4 columns, representing data from 14 robots, each transmitting the data to the cloud every 10 min; furthermore, the datasets are heterogeneous enough to be representative for the water sensors.

5.3. Fine-Tuning and Classifiers

There are several classical machine learning (ML) techniques that can perform well in the context of anomaly detection. For this study, supervised ML techniques, which use correctly labelled data during the classifiers’ training, are used. They are known to deliver a good performance when classifying the data of sensors. These are the selected supervised ML techniques:
  • ANN: It is a set of interconnected nodes designed to imitate the functioning of the human brain. Each node has a weighted connection to several other nodes in neighboring layers. Individual nodes take the input received from the connected nodes and use the weights together with a simple function to compute output values. Neural networks can be constructed for supervised or unsupervised learning. The user specifies the number of hidden layers as well as the number of nodes within a specific hidden layer. Depending on the application, the output layer of the neural network may contain one or several nodes. The multilayer perceptions (MLP) neural networks have succeeded in various applications and produced more accurate results than other computational learning models. They can approximate any continuous function to a random accuracy as long as they contain enough hidden units. Such models can form any classification decision boundary in feature space and thus act as a non-linear discriminate function [29]. ANN is known to be a good technique for the classification of complex datasets. In this study, we used ANN with two hidden layers and an output layer with a single neuron for binary classification, where the ReLu activation function is used in the hidden layer and a sigmoid activation function is used in the output layer. To train the model, we used the Adam optimizer, with a learning rate equal to 0.0001 and regularization parameter equal to 0.1.
  • SVM: SVM is a supervised machine learning algorithm introduced by [30], which can be used for classification and regression problems. The SVM technique separates the data belonging to different classes by fitting a hyperplane between them, which maximizes the separation. The data are mapped into a higher dimensional feature space where a hyperplane can easily separate it. Furthermore, a kernel function approximates the dot products between the mapped vectors in the feature space to find the hyperplane. In addition, using the binary classification approach, SVM uses one-class quarter sphere to reduce the effort of computational complexity and locally identify outliers generated by the sensors. Consequently, the sensor data outside the quarter sphere are considered as the outlier [31]. We tested different variants using SVM by changing the parameters kernel, regularization parameter, and gamma. After parameter tunning, kernel = ‘rbf’, regularization parameter = 0.1, and gamma = 0.001 achieved one of the best F 1 -score.
  • DT: The DT algorithm is considered a powerful technique for detecting and manipulating outliers within datasets. It is a type of supervised machine learning algorithm that can be used for both classification and regression. When a DT is trained on datasets, it learns to recursively split the data based on feature values that minimize some measure of impurity [32]. During this process, the DT may isolate certain observations into internal nodes (leaf nodes) that are distinct from the majority of data points. These isolated instances could potentially be outliers. The DT algorithm can be effectively used for outliers detection because of its capability to partition the feature space and isolate instances that deviate significantly from the majority of data points [33]. In this study, we used DT with its default parameters, because after the fine tuning of its parameters, the model provided approximately the same values. In this context, we decided to go with the default parameters: Nestmators = 50, MinSampleSplit = 2, MinSampleLeaf = 1, Maxfeatures = auto.
  • iForest: The iForest algorithm relies on creating a set of binary decision trees. Unlike the decision trees, the iForest trees randomly selected features and split points to create partitions. This process of randomly finding the trees can sometimes be powerful as outliers are often located in sparsely populated regions of the feature space. More specifically, the isolation forest algorithm gives an isolation score to each data point based on its average path length across all the trees in the forest. Data points with shorter average path length are considered outliers, as they demand fewer splits to isolate [34]. For the iForest, we used contamination with a value of 0.1 and N-estimators with 50 as the value.

5.4. Metrics

To conduct a comprehensive assessment of the various classifiers, a variety of metrics, including accuracy, are utilized to ensure their thorough evaluation. On the one hand, fair comparison of the classifiers is achieved using accuracy measurements like the F 1 -score [35,36,37].

Accuracy

The evaluation of the accuracy utilized the F 1 -score, a metric well-suited for multi-classifiers and imbalanced data. The accuracy and recall metrics, which are based on true positives, false positives, and false negatives, are harmonic means that provide the F 1 -score. Precision (Equation (1)) evaluates a classifier’s ability to correctly identify instances belonging to each class and recall (Equation (2)) is the classifier’s capacity to locate every accurate instance in each class. They are expressed as follows:
P r e c i s i o n = t p t p + f p
R e c a l l = t p t p + t n
where t p and t n are the number of true positives and true negatives, respectively, while f p is the number of false positives. Both parameters are used to obtain the F 1 score as follows:
F 1 s c o r e = 2 × P r e c i s i o n × R e c a l l P r e c i s i o n + R e c a l l
The value of the F 1 -score is normalized between 0 and 1, with a score of 1 indicating a perfect balance, as precision and recall are inversely related [38]. Moreover, the F 1 -score takes into account imbalanced class distribution, such as that which occurs with the evaluated classifiers in Section 7.
The micro average ( F 1 -micro), macro average ( F 1 -macro), and weighted average ( F 1 -weighted) are three techniques for averaging the F 1 -score. The performance is calculated by the F 1 -micro using the individual true positives, false positives, and false negatives. The F 1 -micro can be a deceptive statistic in situations where the class distribution is unbalanced, such as in our dataset, because it is not sensitive to the correctness of individual classes. When a classifier has a high micro average, it indicates a good overall performance. The performance of individual classes is used to calculate the F 1 -macro, which is based on bigger groupings. As a result, it works better when the data show an unequal distribution of classes. When the F 1 -macro is high, the classifier works well for every single class. The F 1 -weighted is computed using the individual class performance, the same as the F 1 -macro, but it modifies the outcome to take label imbalance into consideration [39]. In this evaluation of classifiers, we utilize the F 1 score.

6. Evaluation and Platforms

In this section, we provide details on the pre-processing of sensor data related to water technology, the training procedure, and the platforms and libraries utilized.

6.1. Dataset Pre-Processing

The dataset mentioned earlier in Section 5.2 consists of 2971 rows and 4 columns. It is divided into two parts: 80% for training and 20% for testing. There is no dataset augmentation applied. An additional column representing labels is appended to the dataset, resulting in a total of 5 columns. The labels are generated based on Table 2.

6.2. Platforms and Experimental Setup

In this section, we provide an overview of the various tools and materials used in our research. The Python 3.10 package includes the Scikit-learn 1.4 library, which is instrumental in implementing our models. Additionally, we utilize the TensorFlow framework, which plays a crucial role in developing, training, and deploying our models. Moreover, we employ the ChirpStack (v4) platform as an open-source LoRaWAN server, facilitating communication between LoRaWAN devices and applications. The data from robots are stored in InfluxDB, a time-series database suitable for IoT applications. Additionally, InfluxDB enables us to monitor and analyze data. However, for this research, we use Grafana. This powerful visualization and analytics platform provides us with numerous options to create intuitive and interactive dashboards. We utilize version 10.1.17 of Grafana for visualization purposes. The laptop used in the experiments features an Intel(R) Core(TM) i7-9850H CPU (Intel, Santa Clara, CA, USA) running Windows 10.

7. Results and Discussion

In this section, a comparison will be conducted among four sensors—pH, temperature, EC, and DO—utilizing four different models—SVM, iForest, DT, and ANN.
Considering the results presented in Table 3, it is clearly seen that the SVM model achieved excellent results in the outlier detection context relying on pH measures. It exhibited high precision, recall, and F 1 -score on the training and test sets, with a notably high F 1 -score (0.9838) on the test set. Conversely, the iForest showed lower precision, recall, and F 1 -score across training and test sets, presenting limitations in effectively identifying outliers. The decision tree model performed well, boasting high precision and reasonably good recall and F 1 -score. While ANN displayed good precision and recall values, its F 1 -score was comparatively lower than SVM and DT, particularly on the test set. As a result, using a simpler model such as DT or SVM might yield superior results, unless additional optimization or fine-tuning enhances the performance of the ANN.
As depicted in Table 4, SVM showcased strong capabilities in detecting outliers based on temperature measures, maintaining high precision, recall, and F 1 -scores on the training and test sets. On the other hand, iForest displayed a moderate performance, with lower precision, recall, and F 1 -scores compared with SVM. The decision tree exhibited an acceptable capability, though slightly lower than SVM. Although slightly lower than SVM, ANN showed a competitive performance, with solid accuracy, recall, and F 1 -scores.
By analyzing the results of Table 5, SVM demonstrated a strong performance in outlier detection based on DO measures, maintaining consistently high precision, recall, and F 1 -scores on both the training and test sets. iForest displayed lower precision, recall, and F 1 -scores compared with SVM. DT exhibited a decent performance, slightly lower than SVM but still effective. ANN demonstrated a strong and competitive performance, similar to SVM. SVM and ANN emerged as top performers in outlier detection based on DO measures, demonstrating consistently high precision, recall, and F 1 -scores on both the training and test sets.
Concerning the electrical conductivity in Table 6, SVM demonstrated a robust performance in outlier detection, showcasing high precision, recall, and F 1 -scores on both the training and test sets. Isolation Forest displayed lower precision, recall, and F 1 -scores than SVM. In the same context, the decision tree also lower values than SVM. ANN is closely aligned with SVM. Therefore, SVM and ANN can be considered the best solutions in the context of outlier detection based on conductivity measures, demonstrating consistently high precision, recall, and F 1 -scores on both the training and test sets.
Overall, the analysis of different measures of pH, temp, EC, and DO revealed that SVM consistently performed well in outlier detection across the different measures, showcasing strong precision, recall, and F 1 -scores on both the training and test sets. The ensemble methods of decision tree and ANN also exhibited a competitive performance, indicating potential alternatives depending on specific requirements.
In this study, we evaluated four machine learning models—SVM, iForest, DT, and ANN—to assess their effectiveness in predicting critical water quality parameters—pH, temperature, DO, and EC. Our evaluation focused on interpreting the implications of the models’ performance metrics, particularly F 1 -scores, across both the training and test datasets. Across all of the evaluated parameters, SVM consistently emerged as the top-performing model in terms of F 1 -score. This metric combines precision and recall, offering a balanced measure of a model’s predictive capability. SVM’s robust F 1 -scores on both training and test datasets indicate its reliability in accurately predicting water quality metrics. The superior performance of SVM can be attributed to several factors inherent to its algorithmic design. SVM effectively constructs hyperplanes or decision boundaries that maximize the margin between different classes, leading to strong generalization capabilities. This attribute is particularly advantageous in complex datasets where a clear separation between classes is critical.
iForest, DT, and ANN also demonstrated a competitive performance across specific parameters. However, their overall F 1 -scores were consistently lower than SVM. Isolation forest, despite its anomaly detection strength, struggled to capture the complex patterns present in water quality data, resulting in comparatively lower precision and recall. Decision Tree and ANN, while showing promise in certain metrics, did not consistently match SVM’s robustness across all parameters.
The choice of SVM as the preferred model for water quality prediction bears significant practical implications. Its ability to maintain high accuracy and reliability across diverse datasets suggests its suitability for deployment in real-world applications such as environmental monitoring and management. Reliable predictions of pH, temperature, dissolved oxygen, and EC are crucial for decision-making processes aimed at safeguarding aquatic ecosystems and public health.
Despite SVM’s strong performance, there are avenues for further exploration. Future research could delve into optimizing SVM parameters or exploring ensemble methods to enhance its predictive accuracy further. Additionally, investigating the scalability of SVM to larger datasets or its adaptability to changing environmental conditions would be beneficial for extending its applicability.
In conclusion, our comparative analysis underscores SVM’s effectiveness as a robust predictive model for water quality parameters. Its consistent performance across multiple metrics and datasets positions SVM as a valuable tool in advancing environmental informatics, offering reliable insights into water quality dynamics crucial for sustainable resource management and ecosystem preservation. Future research efforts should continue to explore and refine SVM’s capabilities to address the evolving challenges in water quality assessment and monitoring.

8. Conclusions

Poor water quality is a severe problem threatening human health, ecosystems, plants, and animals. Therefore, monitoring water quality has become a primary concern in water resources and environmental systems. Traditionally, to monitor water quality, manual laboratory-based testing can be costly, time-consuming, and lack real-time feedback. For this reason, the intersection of technology and environmental sustainability has turned into a necessity in order to ensure the efficient monitoring and controlling of water. In this context, using smart water sensing technology has become a pivotal milestone in managing water, relying on the data collected by different sensors and deployed in various aquatic environments. However, the collected data are confounded by anomalies caused by technical issues, which can lead to fault detection and diagnosis. In light of this challenge, this work specifically focused on the detection of outliers to ensure the efficient management of water using machine learning techniques. As a result, the monitoring of four key sensors, namely, PH, DO, EC, and Temp, are each evaluated through the lens of four essential classical machine learning algorithms: support vector machine, artificial neural network, decision tree, and isolated forest-based outlier detection.
The dataset utilized in this study originates from a real-time smart water sensing monitoring system deployed across different environments, including lakes, rivers, and ponds in Brussels. The experimental study has shown the superior efficiency of SVM, which demonstrates an exceptional F 1 -score rate across multiple sensors. In addition, we highlight the noteworthy performance of ANN, suggesting its potential capability as a main alternative to address the problem of outlier detection.

Author Contributions

Conceptualization, M.L., B.B.M., M.Y.C. and A.T.; methodology, M.L. and B.B.M.; software, M.L. and B.B.M.; validation, M.L. and B.B.M.; investigation, M.L. and B.B.M.; data curation, M.L. and B.B.M.; writing—original draft preparation, M.L. and B.B.M.; writing—review and editing, M.L. and B.B.M.; visualization, M.L. and B.B.M.; supervision, M.Y.C. and A.T. All authors have read and agreed to the published version of the manuscript.

Funding

This research received external funding from Innoviris Belgium for the project “Smart Water” under reference 2020-EPF-06 started on 1 January 2021. SmartWater is a collaborative, citizen-based project [40].

Data Availability Statement

The data are available upon request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. El-Shafeiy, E.; Alsabaan, M.; Ibrahem, M.I.; Elwahsh, H. Real-Time Anomaly Detection for Water Quality Sensor Monitoring Based on Multivariate Deep Learning Technique. Sensors 2023, 23, 8613. [Google Scholar] [CrossRef] [PubMed]
  2. Liu, Y.; Yu, W.; Rahayu, W.; Dillon, T. An Evaluative Study on IoT ecosystem for Smart Predictive Maintenance (IoT-SPM) in Manufacturing: Multi-view Requirements and Data Quality. IEEE Internet Things J. 2023, 10, 11160–11184. [Google Scholar] [CrossRef]
  3. Salemdawod, A.; Aslan, Z. Water and air quality in modern farms using neural network. In Proceedings of the 2017 International Conference on Engineering and Technology (ICET), Antalya, Turkey, 21–23 August 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 1–4. [Google Scholar]
  4. Inoue, J.; Yamagata, Y.; Chen, Y.; Poskitt, C.M.; Sun, J. Anomaly detection for a water treatment system using unsupervised machine learning. In Proceedings of the 2017 IEEE International Conference on Data Mining Workshops (ICDMW), New Orleans, LA, USA, 18–21 November 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 1058–1065. [Google Scholar]
  5. Leigh, C.; Alsibai, O.; Hyndman, R.J.; Kandanaarachchi, S.; King, O.C.; McGree, J.M.; Neelamraju, C.; Strauss, J.; Talagala, P.D.; Turner, R.D.; et al. A framework for automated anomaly detection in high frequency water-quality data from in situ sensors. Sci. Total Environ. 2019, 664, 885–898. [Google Scholar] [CrossRef] [PubMed]
  6. Liu, J.; Wang, P.; Jiang, D.; Nan, J.; Zhu, W. An integrated data-driven framework for surface water quality anomaly detection and early warning. J. Clean. Prod. 2020, 251, 119145. [Google Scholar] [CrossRef]
  7. van de Wiel, L.; van Es, D.M.; Feelders, A. Real-time outlier detection in time series data of water sensors. In Proceedings of the International Workshop on Advanced Analytics and Learning on Temporal Data, Ghent, Belgium, 14 September 2020; Springer: Berlin/Heidelberg, Germany, 2020; pp. 155–170. [Google Scholar]
  8. Mokua, N.; Maina, C.; Kiragu, H. Anomaly Detection for Raw Water Quality—A Comparative Analysis of the Local Outlier Factor Algorithm and the Random Forest Algorithms. Int. J. Comput. Appl. 2021, 174, 49–54. [Google Scholar] [CrossRef]
  9. Fang, S.; Sun, W.; Huang, L. Anomaly Detection for Water Supply Data using Machine Learning Technique. J. Phys. Conf. Ser. 2019, 1345, 022054. [Google Scholar] [CrossRef]
  10. Raciti, M.; Cucurull, J.; Nadjm-Tehrani, S. Anomaly detection in water management systems. In Critical Infrastructure Protection: Information Infrastructure Models, Analysis, and Defense; Springer: Berlin/Heidelberg, Germany, 2012; pp. 98–119. [Google Scholar]
  11. Talagala, P.D.; Hyndman, R.J.; Leigh, C.; Mengersen, K.; Smith-Miles, K. A feature-based procedure for detecting technical outliers in water-quality data from in situ sensors. Water Resour. Res. 2019, 55, 8547–8568. [Google Scholar] [CrossRef]
  12. Jesus, G.; Casimiro, A.; Oliveira, A. Using machine learning for dependable outlier detection in environmental monitoring systems. ACM Trans. Cyber-Phys. Syst. 2021, 5, 29. [Google Scholar] [CrossRef]
  13. Bourelly, C.; Bria, A.; Ferrigno, L.; Gerevini, L.; Marrocco, C.; Molinara, M.; Cerro, G.; Cicalini, M.; Ria, A. A preliminary solution for anomaly detection in water quality monitoring. In Proceedings of the 2020 IEEE International Conference on Smart Computing (SMARTCOMP), Bologna, Italy, 14–17 September 2020; IEEE: Piscataway, NJ, USA, 2020; pp. 410–415. [Google Scholar]
  14. González-Vidal, A.; Cuenca-Jara, J.; Skarmeta, A. IoT for water management: Towards intelligent anomaly detection. In Proceedings of the 2019 IEEE 5th World Forum on Internet of Things (WF-IoT), Limerick, Ireland, 15–18 April 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 858–863. [Google Scholar] [CrossRef]
  15. Zhang, J.; Zhu, X.; Yue, Y.; Wong, P.W. A real-time anomaly detection algorithm/or water quality data using dual time-moving windows. In Proceedings of the 2017 Seventh International Conference on Innovative Computing Technology (INTECH), Luton, UK, 16–18 August 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 36–41. [Google Scholar]
  16. Jáquez, A.D.B.; Herrera, M.T.A.; Celestino, A.E.M.; Ramírez, E.N.; Cruz, D.A.M. Extension of LoRa Coverage and Integration of an Unsupervised Anomaly Detection Algorithm in an IoT Water Quality Monitoring System. Water 2023, 15, 1351. [Google Scholar] [CrossRef]
  17. Grubbs, F.E. Procedures for detecting outlying observations in samples. Technometrics 1969, 11, 1–21. [Google Scholar] [CrossRef]
  18. Chandola, V.; Banerjee, A.; Kumar, V. Anomaly detection: A survey. ACM Comput. Surv. (CSUR) 2009, 41, 15. [Google Scholar] [CrossRef]
  19. Rajasegarar, S.; Leckie, C.; Palaniswami, M. Anomaly detection in wireless sensor networks. IEEE Wirel. Commun. 2008, 15, 34–40. [Google Scholar] [CrossRef]
  20. Garcia-Teodoro, P.; Diaz-Verdejo, J.; Maciá-Fernández, G.; Vázquez, E. Anomaly-based network intrusion detection: Techniques, systems and challenges. Comput. Secur. 2009, 28, 18–28. [Google Scholar] [CrossRef]
  21. Görnitz, N.; Kloft, M.; Rieck, K.; Brefeld, U. Toward supervised anomaly detection. J. Artif. Intell. Res. 2013, 46, 235–262. [Google Scholar] [CrossRef]
  22. Types of Data Anomalies. Available online: https://medium.com/datadailyread/types-of-data-anomalies-2f6fb1747eb1 (accessed on 22 February 2024).
  23. Uddin, M.G.; Nash, S.; Olbert, A.I. A review of water quality index models and their use for assessing surface water quality. Ecol. Indic. 2021, 122, 107218. [Google Scholar] [CrossRef]
  24. Quevy, Q.; Lamrini, M.; Chkouri, M.; Cornetta, G.; Touhafi, A.; Campo, A. Open Sensing System for Long Term, Low Cost Water Quality Monitoring. IEEE Open J. Ind. Electron. Soc. 2023, 4, 27–41. [Google Scholar] [CrossRef]
  25. World Health Organization. Guidelines for Drinking-Water Quality; World Health Organization: Geneva, Switzerland, 2012; Volume 1. [Google Scholar]
  26. Das Kangabam, R.; Bhoominathan, S.; Kanagaraj, S.; Govindaraju, M. Development of a water quality index (WQI) for the Loktak Lake in India. Appl. Water Sci. 2017, 7, 2907–2918. [Google Scholar] [CrossRef]
  27. Ito, Y.; Momii, K. Impacts of regional warming on long-term hypolimnetic anoxia and dissolved oxygen concentration in a deep lake. Hydrol. Process. 2015, 29, 2232–2242. [Google Scholar] [CrossRef]
  28. Hendriarianti, E.; Wulandari, C.D.; Novitasari, E. River water quality performance from carbondeoxygenation rate. Int. J. Eng. Manag. 2017, 1, 28–34. [Google Scholar]
  29. Chandola, V.; Banerjee, A.; Kumar, V. Outlier detection: A survey. ACM Comput. Surv. 2007, 14, 15. [Google Scholar]
  30. Boser, B.E.; Guyon, I.M.; Vapnik, V.N. A training algorithm for optimal margin classifiers. In Proceedings of the Fifth Annual Workshop on Computational Learning Theory, Pittsburgh, PA, USA, 27–29 July 1992; pp. 144–152. [Google Scholar]
  31. Agrawal, S.; Agrawal, J. Survey on anomaly detection using data mining techniques. Procedia Comput. Sci. 2015, 60, 708–713. [Google Scholar] [CrossRef]
  32. Panasov, V.; Nechitaylo, N. Decision Trees-based Anomaly Detection in Computer Assessment Results. J. Phys. Conf. Ser. 2021, 2001, 012033. [Google Scholar] [CrossRef]
  33. Reif, M.; Goldstein, M.; Stahl, A.; Breuel, T.M. Anomaly detection by combining decision trees and parametric densities. In Proceedings of the 2008 19th International Conference on Pattern Recognition, Tampa, FL, USA, 8–11 December 2008; IEEE: Piscataway, NJ, USA, 2008; pp. 1–4. [Google Scholar]
  34. Ding, Z.; Fei, M. An anomaly detection approach based on isolation forest algorithm for streaming data using sliding window. IFAC Proc. Vol. 2013, 46, 12–17. [Google Scholar] [CrossRef]
  35. Goutte, C.; Gaussier, E. A probabilistic interpretation of precision, recall and F-score, with implication for evaluation. In Proceedings of the European Conference on Information Retrieval, Santiago de Compostela, Spain, 21–23 March 2005; Springer: Berlin/Heidelberg, Germany, 2005; pp. 345–359. [Google Scholar]
  36. Lipton, Z.C.; Elkan, C.; Naryanaswamy, B. Optimal thresholding of classifiers to maximize F1 measure. In Proceedings of the Machine Learning and Knowledge Discovery in Databases: European Conference, ECML PKDD 2014, Nancy, France, 15–19 September 2014; Proceedings, Part II 14. Springer: Berlin/Heidelberg, Germany, 2014; pp. 225–239. [Google Scholar]
  37. Fujino, A.; Isozaki, H.; Suzuki, J. Multi-label text categorization with model combination based on f1-score maximization. In Proceedings of the Third International Joint Conference on Natural Language Processing, Hyderabad, India, 7–12 January 2008; Volume-II. [Google Scholar]
  38. Evaluating Multi-Class Classifier. Available online: https://medium.com/apprentice-journal/evaluating-multi-class-classifiers-12b2946e755b (accessed on 1 March 2024).
  39. Performance Measures for Multi-Class Problems. Available online: https://www.datascienceblog.net/post/machine-learning/performance-measures-multi-class-problems/ (accessed on 7 March 2024).
  40. Experimental Platforms 2020: SmartWater: SmartWater Monitoring in Brussels. Available online: https://researchportal.vub.be/en/projects/experimental-platforms-2020-smartwater-smartwater-monitoring-in-b (accessed on 12 March 2024).
Figure 1. Framework of Anomaly detection.
Figure 1. Framework of Anomaly detection.
Sensors 24 04084 g001
Figure 2. Taxonomy of anomaly detection.
Figure 2. Taxonomy of anomaly detection.
Sensors 24 04084 g002
Figure 3. Point anomaly [22].
Figure 3. Point anomaly [22].
Sensors 24 04084 g003
Figure 4. Contextual Anomaly [22].
Figure 4. Contextual Anomaly [22].
Sensors 24 04084 g004
Figure 5. Collective Anomaly [22].
Figure 5. Collective Anomaly [22].
Sensors 24 04084 g005
Figure 6. Water quality described by the physical, chemical, and biological characteristics [24].
Figure 6. Water quality described by the physical, chemical, and biological characteristics [24].
Sensors 24 04084 g006
Figure 7. pH and temperature sensor (a). Dissolved oxygen sensor (b). Electrical conductivity sensor (c).
Figure 7. pH and temperature sensor (a). Dissolved oxygen sensor (b). Electrical conductivity sensor (c).
Sensors 24 04084 g007
Figure 8. Steps Involved in the data collection, pre-processing, and data visualization process.
Figure 8. Steps Involved in the data collection, pre-processing, and data visualization process.
Sensors 24 04084 g008
Figure 9. Map of Brussels highlighting areas where samples were taken.
Figure 9. Map of Brussels highlighting areas where samples were taken.
Sensors 24 04084 g009
Figure 10. Collecting samples from the leybeek ettang (a). Brussels canal (b). Death fish found on the canal (c).
Figure 10. Collecting samples from the leybeek ettang (a). Brussels canal (b). Death fish found on the canal (c).
Sensors 24 04084 g010
Table 1. Comparison of anomaly detection training methods.
Table 1. Comparison of anomaly detection training methods.
SupervidedSemi-SupervisedUnupervised
Prior-Knowledge?YesYesNo
Environment?StaticDynamicDynamic
Detection speed?fastFast/ModerateModerate/slow
Detection generality?NoYesYes
Table 2. Water quality standards provide by World Health Organization.
Table 2. Water quality standards provide by World Health Organization.
ParametersUnitsWHO Standards [25]Analytical Methods [26]
pH-6.5–8.5pH meter
ECμs/cm400Electrometric
Temp°C12–25Digital thermometer
DOmg/L4–6Winkler method
Table 3. F 1 scores for pH are measured for the four models. The solution with the highest F 1 score is indicated.
Table 3. F 1 scores for pH are measured for the four models. The solution with the highest F 1 score is indicated.
Models PrecisionRecall F 1 -Score
    SVMTrain0.959910.9796
Test0.968110.9838
    iForestTrain0.7754870.821540.7978
Test0.7548750.8000140.7767
    DTTrain0.95990.970020.9649
Test0.96810.960040.9640
    ANNTrain0.90.950.9243
Test0.89250.94220.9167
Table 4. F 1 scores for temperature is measured for the four models. The solution with the highest F 1 score is indicated.
Table 4. F 1 scores for temperature is measured for the four models. The solution with the highest F 1 score is indicated.
Models PrecisionRecall F 1 -Score
    SVMTrain0.971450.9844210.9778
Test0.959980.979990.9698
    iForestTrain0.78230.8255740.8033
Test0.765450.80212540.7833
    DTTrain0.880.90.8898
Test0.87320.88540.8792
    ANNTrain0.940.960.9498
Test0.93540.95880.9469
Table 5. F 1 scores for dissolved oxygen is measured for the four models. The solution with the highest F 1 score is indicated.
Table 5. F 1 scores for dissolved oxygen is measured for the four models. The solution with the highest F 1 score is indicated.
Models PrecisionRecall F 1 -Score
    SVMTrain0.98320.97450.9788
Test0.97200.96100.9666
    iForestTrain0.80540.78990.7976
Test0.79210.78850.7903
    DTTrain0.90.920.9098
Test0.8990.91250.9076
    ANNTrain0.98770.97510.9813
Test0.98350.97420.9788
Table 6. F 1 scores for EC is measured for the four models. The solution with the highest F 1 score is indicated.
Table 6. F 1 scores for EC is measured for the four models. The solution with the highest F 1 score is indicated.
Models PrecisionRecall F 1 -Score
    SVMTrain0.984000.978970.9814
Test0.97520.96950.9723
    iForestTrain0.82880.77560.8013
Test0.724000.77660.7494
    DTTrain0.89200.88540.8871
Test0.89120.87660.8839
    ANNTrain0.99000.98450.9872
Test0.98020.98200.9811
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Lamrini, M.; Ben Mahria, B.; Chkouri, M.Y.; Touhafi, A. Towards Reliability in Smart Water Sensing Technology: Evaluating Classical Machine Learning Models for Outlier Detection. Sensors 2024, 24, 4084. https://doi.org/10.3390/s24134084

AMA Style

Lamrini M, Ben Mahria B, Chkouri MY, Touhafi A. Towards Reliability in Smart Water Sensing Technology: Evaluating Classical Machine Learning Models for Outlier Detection. Sensors. 2024; 24(13):4084. https://doi.org/10.3390/s24134084

Chicago/Turabian Style

Lamrini, Mimoun, Bilal Ben Mahria, Mohamed Yassin Chkouri, and Abdellah Touhafi. 2024. "Towards Reliability in Smart Water Sensing Technology: Evaluating Classical Machine Learning Models for Outlier Detection" Sensors 24, no. 13: 4084. https://doi.org/10.3390/s24134084

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop