Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
47 views17 pages

Detection of Emergent Leaks Using Machine Learning

This document discusses the use of machine learning approaches for detecting leaks in district metered areas (DMAs) by analyzing time series data related to water inflow, consumption, and pressure. The study evaluates the effectiveness of various anomaly detection algorithms in identifying leaks quickly, potentially within hours, while minimizing false positives. The findings indicate that the proposed methods can significantly enhance leak detection capabilities in water distribution systems.

Uploaded by

apis21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views17 pages

Detection of Emergent Leaks Using Machine Learning

This document discusses the use of machine learning approaches for detecting leaks in district metered areas (DMAs) by analyzing time series data related to water inflow, consumption, and pressure. The study evaluates the effectiveness of various anomaly detection algorithms in identifying leaks quickly, potentially within hours, while minimizing false positives. The findings indicate that the proposed methods can significantly enhance leak detection capabilities in water distribution systems.

Uploaded by

apis21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Uncorrected Proof

© 2023 The Authors Water Supply Vol 00 No 0, 1 doi: 10.2166/ws.2023.118

Detection of emergent leaks using machine learning approaches

P. Głomb a, *, M. Cholewaa, W. Koralb,c, A. Madejc and M. Romaszewskia


a
Polish Academy of Sciences, Institute of Theoretical and Applied Informatics, Bałtycka 5, Gliwice 44-100, Poland
b
Faculty of Energy and Environmental Engineering, Silesian University of Technology, S. Konarskiego 18, Gliwice 44-100, Poland
c
AIUT Sp. z o.o., Wyczółkowskiego 113, Gliwice 44-100, Poland
*Corresponding author. E-mail: [email protected]

PG, 0000-0002-0215-4674

ABSTRACT

In this work, we focus on the detection of leaks occurring in district metered areas (DMAs). Those leaks are observable as a number of time-
related deviations from zone patterns over days or weeks. While they are detectable given enough time, due to the huge cost of water loss
resulting from an undetected leak, the main challenge is to find them as soon as possible, when the deviation from the zone pattern is small.
Using our collected observational data, we investigate the appearance of leaks and discuss the performance of several machine learning (ML)
anomaly detectors in detecting them. We test a diverse set of six anomaly detectors, each based on a different ML algorithm, on nine scen-
arios containing leaks and anomalies of various kinds. The proposed approach is very effective at quickly (within hours) identifying the
presence of a leak, with a limited number of false positives.

Key words: water leak detection, anomaly detection in time series, machine learning

HIGHLIGHTS

• We focus on the detection of leaks and anomalies occurring in the district metered areas (DMAs).
• We use machine learning anomaly detection algorithms on hourly inflow, loss, consumption and pressure data.
• We test the proposed approach on nine scenarios and show its good performance, potentially finding leaks within hours, with a limited
number of false positives.

GRAPHICAL ABSTRACT

1. INTRODUCTION
Growing human population, especially in urban areas, creates many new challenges for water distribution systems mainten-
ance, as growing demand requires them to be more efficient and limit water losses. In those, major factors are leakages and
burst in pipe networks, which occur between water treatment and delivery to customer locations. As quoted in Mamlook &

This is an Open Access article distributed under the terms of the Creative Commons Attribution Licence (CC BY-NC-ND 4.0), which permits copying and
redistribution for non-commercial purposes with no derivatives, provided the original work is properly cited (http://creativecommons.org/licenses/by-nc-nd/4.0/).

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 2

Al-Jayyousi (2003) and Beuken et al. (2008), water loss occurs in almost all water networks and starts from 3 to 7% in devel-
oped countries, rising to more than 50% in undeveloped ones. While this creates an obvious economical issue and is a major
concern for water delivery companies, the problems of water loss are also environmental, sustainability and potentially even
energy, health and safety issues (Colombo & Karney 2002). In recent years, there has been a significant amount of research
concerning leak management in water delivery systems (WDS), as seen in reviews (Puust et al. 2010; Xu et al. 2014).
Water leak management consists of: leak detection, localisation and repair (Islam et al. 2011); this paper is focused on the
first of those issues. While a large burst in a pipe network may sometimes be easily detected, e.g. by reported flooding or when
it causes a sudden pressure drop in the WDS, small leakages may stay undetected for days or even weeks. WDS are com-
monly segmented into zones, or district metered areas (DMAs).
Data-based leak detection is DMAs was typically based on inlet meter and pressure sensors. The inlet meter provides fre-
quent (e.g. hourly) information about the water inflow into the DMA, while pressure sensors provide information from
selected points within the DMA – often a single measure at the inlet. Inflow analysis methods (Buchberger & Nadimpalli
2004; Rahmat et al. 2017) are typically applied to such data by system operators. One of the most significant approaches
is the analysis of minimum night flow (MNF) (Farley & Trow 2003; Liemberger & Farley 2004; Alkasseh et al. 2013)
based on the observation that nightly DMA consumption is much lower than during the daytime, which means leakages
or pipeline bursts easier to observe. An approach, called BABE (Bursts and Background Estimates) was proposed in Lambert
(2007) and used both inflow information and annual losses data. Inflow was often used in conjunction with data from
pressure sensors, such as in a fuzzy approach presented in Islam et al. (2011), multi-scale neural networks proposed in
Hu et al. (2021) or in statistical anomaly detection (AD) in time series-based approach in Wu & He (2021).
Wider use of smart meters, which are able to provide frequent data from every single end-point of the water network,
resulted in a significant number of works on using such data to detect post-meter leaks (leaks within the internal network
of the consumer). Example approaches include the use of individual periods of null consumption and minimum night
usage to detect client leaks (Boudhaouia & Wira 2018) or building a user usage profile (Abate et al. 2019). Data from
smart meters can also be employed for DMA leak detections, it allows for calculating DMA’s joint consumptions and
using them along with the inflow values to obtain the DMA water loss value. A problem of detecting leaks using a smart
meter system is presented in Farah & Shahrour (2017), example approaches include the pressure-driven balance model pro-
posed in Yu et al. (2021), or graph partitioning methods (Rajeswaran et al. 2018).
In this work, we study the problem of leak detection using the DMA monitoring data. We use hourly data of DMA inflow,
total water consumption (computed from a smart meter grid) and a small number of pressure sensors (1–3, depending on the
particular DMA configuration). These hourly data vectors form an input to the detection algorithm while the output is a
binary value indicating that a leak is detected. Such detection can easily be integrated into the monitoring software (e.g.
through a dashboard notification for the DMA operator). The use of hourly DMA in this scenario differs from a more typical
scenario of MNF analysis, which may require three or more data points to detect consistent growth in loss values which
means that at least 72 h have to pass before the leak can be detected – as we show, usage of hourly data can lead to
much quicker reaction time.
Our proposition for detecting leaks is to detect the anomalies it causes in the DMA monitoring time series data. By treating
leak detection as an AD problem, we can use many well-researched machine learning (ML) algorithms, which have been suc-
cessfully applied in other domains. The ML methods have already been applied to leak detection: in Farah & Shahrour
(2017), the probability density function was applied to hourly water consumption on the customer level to detect local
leaks. Self-supervised leak detector (SSLD) was proposed in Blázquez-García et al. (2021), the method is based on differences
from normal system behaviour in hourly inflow data. An interesting approach is proposed by the authors of Sadeghioon et al.
(2018) who use AD methods on the pressure and temperature monitoring for the pipeline. However, a typical approach is to
use a physical pressure simulation model such as an EPANET simulation in Mashhadi et al. (2021) or Fan et al. (2021). Com-
pared to this approach, our method is simpler, easier to apply and less computationally expensive. In addition, it can be
applied to DMAs with a limited number of pressure sensors.
The main challenge that is to be expected when applying general AD methods for leak detection is the complex nature of
the input data. Most effective approaches to AD are based on ML, i.e. learning typical patterns from the data and detecting
outliers as non-conforming to those patterns. This usually requires a long history of stationary data for model learning. In
contrast to that, DMA monitoring data are heterogeneous (e.g. inflow or loss has different nature to pressure data), complex

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 3

(e.g. hourly and daily variations, irregular users) and frequently changing in character (due to e.g. maintenance and manage-
ment operations). Due to those difficulties, the performance of AD methods in a leak detection role is an open question.
In this paper, we present an experimental analysis of applying eight algorithms that represent the current state of the art of
AD to detection of two distinct classes of leaks: a build-up leak and a spike leak. We use a dataset of eight scenarios analysed
and confirmed by experts in three different DMAs. In addition to leaks, we investigate anomalous situations resulting from
pipeline maintenance. We show that the proposed approach is a promising method of leak detection with an ability to
capture a majority of tested leaks within the first 24 h.

2. METHODS
We focus on time series AD, the task of which is to identify patterns in time series data that do not correspond to a well-
defined notion of a normal or typical behaviour (Chandola et al. 2009).
Our detection scenario is based on the observation that DMA time series data are not stationary, i.e. its statistical properties
may change in time. A moment of such change is often visible as a distinct anomaly in data, e.g. a sharp change in pressure
readings, inflow or loss values. If such event is spotted by an operator, it is investigated or sometimes ignored, e.g. when it
results from a planned maintenance task. Typically, anomalous readings last for a time, from a few hours to even days,
until they stabilise. However, the new ‘normal’ DMA state is often distinctly different from its state before the anomaly
which may correspond to differences in mean values of pressures or loss, their variance or even a presence (or lack of) a
subset of pressure sensors. This indicates the need to retrain AD models, which work in a time-localised region of the
DMA data, i.e. between what the operator defines as a new normal state (after e.g. the previous leak is repaired) and the dis-
covery of a new one (reported by the AD and being investigated).

2.1. Time-localised AD for leak detection


Given a set Z of DMA time regions, our data are time series vtz [ Rdz where t [ H are hourly timestamps and dz is a number
of raw measured data streams and/or derived features in the DMA region z [ Z. In all cases considered in this paper, vtz
includes values of zone inflow, aggregated consumptions as well as hourly water loss value, computed as DMA inflow and
consumption difference. Some cases include also one of more pressure sensor data – minimum, average and maximum
values over hourly intervals.
Given a set of training vectors T train , Rdz representing a typical DMA behaviour, an anomaly detector is a function
D:Rdz ! R that for any input data vector returns a value of detection statistics (DS). High values of DS indicate the abnorm-
ality of a data vector compared to the statistical properties of the training set. Given some value of a detection threshold
g [ R, an anomaly is detected in the DMA region z and time t if D(vtz )  g.

2.1.1. Training set


Given a DMA region z, a detector D starts to process DMA data starting from time t0 . Vectors from t0 up to tn form a training
set T train ¼ {vtz0 , . . . , vtzn1 }, where n is a training set size. An anomaly can then be detected in time t  tn .

2.1.2. Detection accuracy metric


An anomaly in a dataset is labelled by its anomaly time tanomaly associated with the moment when the anomaly begins. The
(first) moment of detection by an algorithm is denoted as tdetection . The difference between the detection and anomaly times
Dt ¼ tdetection  tanomaly is the detection accuracy metric used to estimate the performance of the detector. Since the accuracy
metrics value can be negative (indicating a detection before the anomaly time) or positive, when this value is minimised, e.g.
in the case of detector parameter selection, its absolute value is used.

2.1.3. Anomaly threshold


Given a training set T train
z for a DMA region z [ Z, and a detector D, first the maximum and minimum values of the DS over
the training set, smax and smin , respectively, are computed. The anomaly threshold is estimated as g ¼ lsmax where l  1 is a
scaling parameter of the detection algorithm. Larger values of the scaling parameter may be used to lower the probability of
false alarms, especially for small training sets.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 4

The detection probability of a detector D for a data vector v is estimated as

 
max (D(v)  smin , 0)
P(v) ¼ min ,1 (1)
g  smin

In our experiments, a value of P(v) ¼ 1 corresponds to detecting an anomaly.

2.1.4. Parameter selection


The detection performance of every algorithm depends on its internal parameters, e.g. the number of neighbours k for a k-NN
detector, and the threshold scaling l parameter, common to all detectors. In order to select the parameters in the most objec-
tive and unbiased manner, for every scenario, parameter values are determined based on data from other scenarios and
without access to data from the currently tested scenario. This approach follows two assumptions: on one hand, a number
of examples of DMA leaks are available. On the other hand, parameters of the detectors should be general, which means
that all leaks can be detected (a detector is not trained for a particular class or type of leaks). In the presented experiments,
we require that a chosen set of detector parameters should work for both classes of leaks in our scenarios.
More formally, the parameters of the detector are estimated by performing a grid-search using a leave-one-scenario-out
approach: Given a set P of parameters in a searched parameter grid (i.e. a Cartesian product of the parameter grid), a par-
ameter candidate p [ P is evaluated by computing its averaged detection score. The averaged detection score is computed by
performing a detection experiment on a set of remaining scenarios Znz and averaging absolute values of their detection accu-
racy. The best parameters are chosen by minimising the averaged detection scores among all parameter candidates.

2.2. Detectors
We have chosen eight AD algorithms for our experiments. These algorithms include both well-known and recent methods
and represent a diverse set of approaches to AD problems with regard to both assumptions and detector complexity:
1. k-nearest neighbours (k-NN) (Angiulli & Pizzuti 2002) and local outlier factor (LOF) (Breunig et al. 2000) detectors are
examples of proximity-based detectors, where the abnormality of an example depends on the distance from its neighbours
in the feature space.
2. Isolation forest (IF) (Liu et al. 2012) is an ensemble approach which works on the principle of randomly choosing features
and generating ensembles of binary trees, measuring the abnormality of examples by the length of their paths in the trees.
3. One-class support vector machine (OCSVM) (Schölkopf et al. 2001) is a kernel-based approach based on the principle of
finding a maximal margin hyperplane separating the dataset from its origin after mapping data points into a high-dimen-
sional feature space (using a kernel function).
4. AutoEncoder (AE) (Charu 2019) is a neural-network, reconstruction-based approach, where an NN model is used to
encode and then reconstruct a dataset and the abnormality of examples depends on the value of the reconstruction error.
5. Principal component analysis (Shyu et al. 2003) is a subspace-based approach where the abnormality score of an example
is obtained as the sum of its projected distance on eigenvectors with small or large eigenvalues.
6. Unsupervised outlier detection using empirical cumulative distribution functions (ECOD) (Li et al. 2022) and copula-based
outlier detection (COPOD) (Li et al. 2020) are examples of probabilistic approaches which first estimate the distribution of
data and then estimate example abnormalities based on their tail distributions across dimensions.

2.3. Detection scenarios


The scenarios were selected from leak and anomaly events discovered during routine maintenance of WDS in one Polish city.
The events were taken from three DMAs (denoted as ‘zone A’, ‘zone B’, ‘zone C’) and numbered accordingly (e.g. A-1, A-2, B-1).
Expert’s knowledge and consultations with WDS operators were used to select the DMAs, events within the zones, their starting
times t0 and AD targets tanomaly . In order to test the performance of detectors in the absence of unusual events in data, one
additional scenario marked as N-1 was prepared.

2.3.1. Scenario A-1


The A-1 scenario (Figure 1) presents the leak that was caused by the break in the pipeline that was gradually growing under
the continuous pressure of water. This results in a consistent, growing trend in water loss. As the break gets bigger and the

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 5

Figure 1 | Scenario A-1, a leak that grows bigger as the break in the pipeline gets larger under water pressure which results in increasing loss
and decreasing pressure values. The loss plot is computed as the difference between zone inflow and the sum of consumptions of individual
customers. The pressure plot is hourly average and minimum of the sensor readout. The vertical dashed line denotes the target for anomaly
detectors (tanomaly ) set by the experts. Note that in this case the target was set by the experts 9 days earlier than the leak was originally
detected, as it is the recommended behaviour of a leak detection system.

leak increases, the average pressure in the zone drops noticeably. The leak was detected by the provider on the 1st of August,
located on the 4th and repaired on the 5th, which can be observed as a major drop in the water loss. The labelling visible in
the data was done post-factum by analysis of changes in MNF. The experts set the value tanomaly 9 days before it was actually
noticed in the DMA by human operators, as it is the recommended behaviour of a leak detection system.

2.3.2. Scenario A-2


The A-2 scenario (Figure 2) presents a leak that was located in the district of detached houses, originating in the break in the
PE-63 pipe. The lower diameter of the piping caused the increase in water loss to be smaller than in scenario A-1, which
resulted in the leak being detected long after it began – around the 22nd of September when a sudden growth in the
water can be observed, as the deterioration of the piping progressed. It is likely that this particular leak was caused by the
process of refilling the pipeline under high pressure after repairing the leak from scenario A-1, as they were located close
to each other. The repair of this leak was performed with the part of the district cut off from the main pipeline which can
be noticed by a sudden pressure loss when the pipes are cleaned and refilled.

Figure 2 | Scenario A-2, a slowly increasing leak resulting in a consistent, growing trend in the water loss. The presented leak followed the
one in scenario A-1.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 6

2.3.3. Scenario A-3


The A-3 scenario (Figure 3) presents the third case of a build-up leak. Compared to scenarios A-1 and A-2, this one is the most
dynamic, with an increase in water loss values from two to seven cubic meters per hour within 2 weeks. Similarly to scenario
A-1, a slight but noticeable pressure loss can be observed. The leak was located 4th of November and repaired on the follow-
ing day. During the repair, a part of the district was cut off from the main pipeline which can be seen as a sudden drop in
pressure on the 4th of November.

2.3.4. Scenario A-4


The A-4 scenario (Figure 4) presents a leak that was not caused by pipeline damage, but according to experts, it could be a
result of improperly performed maintenance – an operation of cleaning and refilling a DMA fragment after repairing an actual
leak (the leak in scenario A-2). A sudden inflow from the main pipeline resulted in a sudden drop in pressure values followed
by a sharp spike in water loss values as the water was filling empty pipes. This water was not registered by clients’ meters;
therefore, it is still considered a loss.

Figure 3 | Scenario A-3, a dynamically increasing leak resulting in a consistent, growing trend in the water loss and small but noticeable
pressure drop.

Figure 4 | Scenario A-4, a sharp drop followed by a spike in DMA water loss values. The most probable cause of this anomaly is the
maintenance of the pipeline.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 7

2.3.5. Scenario A-5


The A-5 scenario (Figure 5) shares similarities with scenario A-4 – the event follows the leak from scenario A-3. The decrease
in loss and pressure values is the result of pipeline repair. They are followed by a sharp spike in the loss function. According to
experts, the fact that this spike occurred after a few hours may indicate that it resulted from a new pipeline break, which was
immediately noticed and repaired – perhaps by the same crew that performed the first maintenance. The scenario may be
considered a special, challenging case for anomaly detectors, as it is composed of two events; a build-up and a spike leak.

2.3.6. Scenarios A-6 and B-1


Scenarios A-6 and B-1 (Figure 6) present two points of view on the same event, which is the closure of the gate valves between
two DMAs, one of which is part of the other. The DMA A which is usually supplied through DMA B has been temporarily
connected to a different DMA. The gate between DMAs B and A was closed which caused a drop of pressure in the pipe
connecting them. There is no consistent increase in loss values after the event which may differentiate this situation from
an obvious leak. The characteristic feature of this anomaly is a sharp drop in minimum pressure values of the sensor located
between DMAs – this sensor is the input sensor of DMA A and the output sensor of DMA B. According to experts, the rela-
tively large water loss value in the DMA B may be caused by a ‘stable’, undetected leak of approximately 5 m3 of water per
hour.

2.3.7. Scenario C-1


Scenario C-1 (Figure 7) presents a clear case of a pipeline break. The leak results in an increase in losses and a decrease in
pressure values in the DMAs. In contrast to scenarios A-4, A-5 and A-6, the pressure drop is not a single peak but lasts for a
longer period.
The visible pressure values come from sensors located in the provider’s pipes (the highest pressure value, with values con-
sistently above 6,000 mbar), the sensor located after the pressure reducer and the third one located deep within the DMA. The
first two sensors do not show any major changes which indicate that the anomaly is located within the DMA, far from the
source.

2.3.8. Scenario N-1


Scenario N-1 (Figure 8) was prepared to test the sensitivity of detectors to FP errors. The scenario consists of 20 selected time
series of water meter consumptions, examined by experts and containing no anomalous events. The inflow was artificially
generated by adding the hourly consumptions of individual meters and subtracting the scaled loss value, sampled from the
distribution derived from the DMA.

Figure 5 | Scenario A-5, a challenging case of two anomalies: a build-up and a spike leak one after another.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 8

Figure 6 | Scenarios A-6 (top plot) and B-1 (bottom plot): an anomaly resulting from pipeline maintenance in two connected DMAs with a
sharp drop in minimum pressure values in the pipe connecting them.

Figure 7 | Scenario C-1, a break in the pipeline located in the DMA, indicated by an increase in DMA loss values and a decrease in values on
one of the pressure sensors, lasting for a long period of time.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 9

Figure 8 | Scenario N-1, with no anomalous events present in the data.

3. EXPERIMENTS AND RESULTS


3.1. Experiments
Experiments were implemented in Python 3.9 using NumPy, SciPy, pandas, Matplotlib libraries, as well as PyOD library
(Zhao et al. 2019). For every scenario, the length of the training set T train was set to half of the period between its first time-
stamp t0 and the timestamp of the anomaly tanomaly . Only the moment of the first detection for each detector is evaluated.

3.1.1. Features
The data features consisted of hourly values of DMA consumptions, raw inflow, and loss (difference between consumptions
and inflow), as well as min, max and mean values of pressures from all DMA pressure sensors. This set of features was chosen
as one of the best after initial experiments.
In every scenario, the features were standardised, by subtracting the mean and dividing them by the standard deviation, the
values of which were estimated on the training set. The features with zero variance in the training set were removed.

3.1.2. Parameters
The ranges of parameters used in our experiments were as follows:
1. For every detector, the range threshold scaling parameter l [ h1, 1:5i
2. k-NN: the number of neighbours, k [ h3, 11i three approaches to outlier score estimation were tested: a distance to the
k-th neighbour and both average and median distances to all k-neighbours.
3. LOF: the number of neighbours k [ h5, 20i.
4. IF: the size of the ensemble n [ h50, 150i
5. OCSVM: RBF kernel, parameters n [ h0:1, 0:9i, g [ {102 , 102 }
6. AE: four hidden layers [64, 32, 32, 64] neurons, bath size bs [ h4, 16i, learning rate lr [ 101 , 104
7. PCA: the number of components is estimated using the heuristics described in Minka (2000)
8. ECOD, COPOD: the methods are nonparametric.

3.2. Results
Overall results of the experiments in the form of the detection accuracy are presented in Table 1. Negative values of accuracy
correspond to early detection, while positive values to late detection of an anomaly. The absolute value of the accuracy score,
i.e. the distance to the denoted anomaly time, may be viewed as the performance score of the scenario/detector pair. Detec-
tion results of individual detectors are presented in Figures 9–11.
Our scenarios can be divided into four ‘types’ of events:
1. Scenarios A-1, A-2 and A-3 are examples of typical leaks resulting from breaks in the pipeline. This type of leak is usually
detected through analysis of MNF which requires a minimum of two or three values from consecutive days. In this context,

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 10

Table 1 | Results of detection experiments with all features

Detector A-1 A-2 A-3 A-4 A-5 A-6 B-1 C-1 Avg

copod 24 71 0 35 7 7 6 16 20:75


Ecod 24 167 24 x 7 x x 4 45:2
Knn 5 27 19 2 58 25 1 1 17:25
Lof 5 27 94 2 34 25 1 1 23:63
Pca 20 27 1 2 7 25 1 2 10:63
ocsvm 5 152 19 2 38 25 1 1 30:38
Ae 23 28 0 2 70 25 1 1 18:75
iforest 25 80 1 x x x x 2 27
Avg 16:38 72:38 19:75 7:5 31:57 22 1:83 3:5
Values in the table represent the detection accuracy, i.e. the difference between the actual and detected starting time of an anomaly (in hours) with ‘x’ denoting no detection. The last
row and last column present values averaged over their absolute value.

leak detection in less than 48 h can be considered a good result compared to the MNF analysis. A majority of tested detec-
tors achieved this result with only three higher values of detection scores. In scenarios A-1 and A-3, the detection time of
almost all detectors was lower than 24 h. Scenario A-2 proved to be challenging which is indicated by its high mean detec-
tion score compared to other scenarios. The relatively late response of most detectors in this scenario may result from a
large variance in the values of loss and pressure in the training set. As a result, some detectors reacted only to strong
changes in the trend visible in Figure 8(b) after about 4 and 7 days.
2. Scenarios A-4 and A-5 are examples of rapid, huge losses which cannot be detected by MNF analysis. In the case of A-4, a
majority of detectors reacted to the sudden drop in loss values 2 h before the actual leak – the early activation of the copod
detector can be considered a false positive. Scenario A-5 was clearly a challenge for half of the detectors, which is indi-
cated by its second-worst mean detection score. However, looking at Figure 9(b), it seems that detectors that activated
early were triggered by rising loss values. Since rising losses are also an indication of leaks in scenarios A-1, A-2 and A-
3, it can be expected that algorithms trained to detect both kinds of leaks may be sensitive to such anomalies.
3. Scenarios A-6 and B-1 are an example of the same event observed in two connected DMAs. The event was a result of pipe-
line maintenance works but exhibited clearly anomalous characteristics with sharp changes in both loss and pressure
values. Interestingly, while in B-1 scenario, all detectors captured the event within 1 h, in A-6, a majority of detectors
reacted to a sharp spike in loss values 25 h earlier. Only a copod detector reacted almost the same in both scenarios,
which may indicate that it was triggered by changes in pressure values instead of loss (notice that both DMAs share a
pressure sensor at the point of their connection). The difference in performance may result from the fact that B-1 DMA
contains more water meters and has significantly higher raw inflow; therefore, the DMA consumption and loss functions
have lower variance.
4. Scenario C-1 is an example of a confirmed break in the pipeline resulting in a sharp spike in loss values and a drop in
minimal and average pressures. A majority of detectors activated within 2 h which can be considered an acceptable
result. Interestingly, both ECOD and COPOD detectors which share similarities in their design, acted differently – one
activated early while the other activated late.

Regarding the scores of individual detectors:

• When considering detection scores presented in Table 1, the PCA, k-NN, AE, COPOD and LOF detectors were on average
able to capture anomalies within 24 h time. On the other hand, ECOD and IFOREST detectors performed relatively poorly
with regard to their mean score.
• Two detectors: ECOD and IFOREST were not able to detect anomalies in multiple scenarios which may indicate their low
sensitivity.
• Activation times of the COPOD detector are visibly different from the remaining algorithms while its mean detection score
is fourth among tested methods. When considering averaging scores of multiple detectors in some form of ensemble learn-
ing, this diversity makes COPOD a valid candidate for such an ensemble.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 11

Figure 9 | Detection results for experimental scenarios with annotated responses of individual detectors. Values near the detector name are
the detection accuracy scores. (a) A1, (b) A2, (c) A3.

• Figure 12 presents the detection probability of three example detectors in the A-3 scenario. In this example, the COPOW
detector estimated probability function seems to be primarily correlated with average pressure values, while PCA and LOF
functions follow the change in both the pressure and loss functions of DMA. A comparison of detection probabilities of all
detectors and scenarios reveals that this is a common pattern: responses of COPOD and ECOD detectors share similarities
and are less correlated with loss values than responses of the remaining detectors.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 12

Figure 10 | Detection results for experimental scenarios with annotated responses of individual detectors. Values near the detector name
are the detection accuracy scores. (a) A4, (b) A5.

The output of detectors in a scenario that does not contain anomalous events is presented in Figure 13. In the experiment,
half of the data (300 h) was used for training and parameters were selected using all remaining scenarios. Every detection in
the other half is a false positive. Most of the detectors made no errors or only one error. The exception is detector ECOD,
which made six errors. This corresponds to false-positive ratio (FPR) of 0:3% for detectors that triggered once and 2% for
the ECOD.

3.3. Discussion
Results indicate that on average, a large subset of anomaly detectors captures both the gradually growing and the sudden
DMA leaks within the first 24 h. Compared to the MNF analysis which requires 2 or 3 days, the overall response time of
anomaly detectors should be considered short.
Despite these promising results, the presented scenarios show the complexity of the leak detection problem in hourly data.
Hourly consumption and pressure data show significant variance. The nature of the anomalies themselves is also varied,
which makes it difficult to describe and classify them. It is even more difficult as the cases of actual, confirmed leakages,
which may constitute training data for ML methods, are relatively rare. In addition, anomalies resulting from both leakages
and other events may occur directly after each other or coexist, as in scenario A-5.
Considering the complexity of DMA hourly data and lack of training examples, one of the major problems of using anomaly
detectors for detecting DMA leaks is their parametrisation, i.e. finding parameters that will allow for accurate detection while
keeping the number of false alarms low. Since our approach to parameter selection involves averaging detection accuracy
scores over several example scenarios (see Section 2.1.4), we can treat the aggregated score of the best parameter set as a

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 13

Figure 11 | Detection results for experimental scenarios with annotated responses of individual detectors. Values near the detector name
are the detection accuracy scores. (a) A6, (b) B1, (c) C1.

measure of expected detector performance. The results of parameter selection are presented in Table 2. Comparing these
scores with the final results in Table 1, it can be concluded that they are a good estimation of detector performance, especially
with regard to the best (PCA) and the worst (ECOD, IFOREST) detectors. They are, however, not a good estimation of a data-
set performance which can be expected, since the estimation of these scores for a dataset is performed using the remaining
datasets. The results for scenario N-1 indicate that the FPR of the detectors with the proposed parametrisation scheme is

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 14

Figure 12 | Detection results for scenario A-3 with estimated probability and an annotated moment of activation of three example detectors.
The probability of PCA and LOF detectors is correlated with the loss function; therefore at some point, it becomes, saturated. The COPOD
detector probability seems to depend more on pressure values. (a) COPOD detector, 0 h difference (b) PCA detector, 1 h difference (c) LOF
detector, 94 h difference.

~
relatively low (0:3% for the majority of algorithms tested). In practice, the detector parameters, and in particular, the detec-
tion threshold, are manually adjusted for most DMAs, which helps to keep the FPR low.
Possible approaches to better detector parameterisation include extending the set of training scenarios by examples where
anomalies do not exist – these examples are more common than ones with anomalies present and their inclusion may lower
the number of false positives; allowing for periodic detector retraining; employing an ensemble of multiple detectors which
vote for the final score.
Regarding the problem of feature selection, the set of features in our experiments was chosen as a result of initial exper-
iments. Example alternative candidate sets included an extended set with additional features characterising missing values
in hourly consumptions of individual DMA sensors. The incompleteness of data results from physical constraints related
to the acquisition process, e.g. loss of packets transmitted over the radio which results in underestimated DMA consumption

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 15

Figure 13 | Detection results for scenario N-1 testing the detectors for false positives (FP). Vertical lines denote every case of detection.

Table 2 | Results of parameter selection described in section 2.1.4

Detector A-1 A-2 A-3 A-4 A-5 A-6 B-1 C-1 Avg

copod 20:3 13:6 23:7 18:7 22:7 22:7 22:9 21:4 20:8
Ecod 100:4 35:0 100:4 80:0 102:9 80:0 80:0 103:3 85:3
Knn 15:4 12:3 13:4 15:9 7:9 15:4 16:0 16:0 14:0
Lof 16:3 13:1 10:0 16:7 12:1 13:4 16:9 16:9 14:4
Pca 9:3 8:3 12:0 11:9 11:1 8:6 12:0 11:9 10:6
ocsvm 11:7 8:6 9:7 12:1 9:0 8:9 12:3 12:3 10:6
Ae 21:6 22:3 27:9 20:9 14:3 24:3 27:7 27:0 23:2
iforest 353:9 98:3 354:0 357:3 356:4 194:9 194:9 345:4 281:9
Avg 68:6 26:4 68:9 66:7 67:1 46:0 47:8 69:3
The table presents averaged scores of detectors over training scenarios (using the leave-one-scenario-out approach) for the best set of parameters that were used in the final
experiment. Values in the table can be treated as a measure of the expected performance of the detector in a given scenario. Note that the value in the table for a given scenario/
detector pair is estimated i.e. it is created without access to this scenario data.

values which must be corrected with data imputation. However, compared to the set of parameters used in experiments, the
extended set was on average 2:13 times worse than the chosen set with regard to mean scenario scores in Table 1 and 2:02
times worse with regard to mean detector scores. Another example was a reduced set including only DMA loss and raw
inflow values as well as minimal and average DMA input pressures; this set of parameters was worse than the chosen one
1:7 times with regards to mean scenario scores and 1:6 times with regards to mean detector scores.

4. CONCLUSIONS
The goal of our experiments was to test the performance of anomaly detectors applied to detecting leaks in hourly DMA loss
and pressure data. We focus on two types of leaks: the gradually growing breaks resulting in a rise in DMA losses over an
extended period and sudden leaks resulting in sharp changes in loss and/or pressure values. We used eight unique datasets
with examples of anomalies and leaks collected by the analysis of the annual data of four real DMAs in Poland and eight
representative SOA anomaly detectors.
Our results suggest that on average, anomaly detectors can detect both types of leaks in less than 24 h and sometimes
within 1–2 h of the incident. This is a promising result when compared with MNF analysis which usually requires data
from 2 or 3 days. On the other hand, parametrisation of detectors is challenging due to variance in hourly DMA data and
a small number of example incidents which can be used as training data.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 16

The main topics of future work will be: improving the parameterisation of detectors, examining their performance in a scen-
ario where incidents occur one after another, and the classification of detected leaks.

ACKNOWLEDGEMENTS
This work has been partially supported by the Polish National Centre for Research and Development grant POIR.01.01.01-00-
1414/20-00, ‘Intelligence Augumentation Ecosystem for analysts of water distribution networks’.

DATA AVAILABILITY STATEMENT


Data cannot be made publicly available; readers should contact the corresponding author for details.

CONFLICT OF INTEREST
The authors declare there is no conflict.

REFERENCES

Abate, F., Carratù, M., Liguori, C. & Pietrosanto, A. 2019 Smart meters and water leakage detection: a preliminary study. In: 2019 IEEE
International Instrumentation and Measurement Technology Conference (I2MTC). IEEE, pp. 1–6.
Alkasseh, J., Adlan, M. N., Abustan, I., Aziz, H. A. & Hanif, A. B. M. 2013 Applying minimum night flow to estimate water loss using
statistical modeling: a case study in Kinta Valley, Malaysia. Water Resources Management 27 (5), 1439–1455.
Angiulli, F. & Pizzuti, C. 2002 Fast outlier detection in high dimensional spaces. In: European Conference on Principles of Data Mining and
Knowledge Discovery. Springer, pp. 15–27.
Beuken, R. H. S., Lavooij, C., Bosch, A. S. & Schaap, P. G. 2008 Low leakage in the Netherlands confirmed. In: 8th Annual Water
Distribution Systems Analysis Symposium.
Blázquez-García, A., Conde, A., Mori, U. & Lozano, J. A. 2021 Water leak detection using self-supervised time series classification.
Information Sciences 574, 528–541. ISSN 0020-0255. https://doi.org/10.1016/j.ins.2021.06.015.
Boudhaouia, A. & Wira, P. 2018 Water consumption analysis for real-time leakage detection in the context of a smart tertiary building.
In: 2018 International Conference on Applied Smart Systems (ICASS). pp. 1–6. doi:10.1109/ICASS.2018.8651976.
Breunig, M. M., Kriegel, H.-P., Ng, R. T. & Sander, J. 2000 Lof: identifying density-based local outliers. In: Proceedings of the 2000 ACM
SIGMOD International Conference on Management of Data. pp. 93–104.
Buchberger, S. G. & Nadimpalli, G. 2004 Leak estimation in water distribution systems by statistical analysis of flow readings. Journal of
Water Resources Planning and Management 130 (4), 321–329.
Chandola, V., Banerjee, A. & Kumar, V. 2009 Anomaly detection: a survey. ACM Computing Surveys (CSUR) 41 (3), 1–58.
Charu, C. A. 2019 Outlier Analysis. Springer.
Colombo, A. & Karney, B. 2002 Energy and costs of leaky pipes: toward comprehensive picture. Journal of Water Resources Planning and
Management 128, 441–450. doi:10.1061/(ASCE)0733-9496(2002)128:6(441).
Fan, X., Zhang, X. & Yu, B. 2021 Machine learning model and strategy for fast and accurate detection of leaks in water supply network.
Journal of Infrastructure Preservation and Resilience 2. doi:10.1186/s43065-021-00021-6.
Farah, E. & Shahrour, I. 2017 Smart water for leakage detection: Feedback about the use of automated meter reading technology. In: 2017
Sensors Networks Smart and Emerging Technologies (SENSET). IEEE, pp. 1–4.
Farley, M. & Trow, S. 2003 Losses in Water Distribution Networks. IWA Publishing.
Hu, X., Han, Y., Yu, B., Geng, Z. & Fan, J. 2021 Novel leakage detection and water loss management of urban water supply network using
multiscale neural networks. Journal of Cleaner Production 278, 123611. ISSN 0959-6526. https://doi.org/10.1016/j.jclepro.2020.
123611. Available from: https://www.sciencedirect.com/science/article/pii/S0959652620336568.
Islam, M. S., Sadiq, R., Rodriguez, M. J., Francisque, A., Najjaran, H. & Hoorfar, M. 2011 Leakage detection and location in water
distribution systems using a fuzzy-based methodology. Urban Water Journal 8 (6), 351–365.
Lambert, A. 2007 Accounting for losses: the bursts and background concept. Water and Environment Journal 8, 205–214. doi:10.1111/j.1747-
6593.1994.tb00913.x.
Li, Z., Zhao, Y., Botta, N., Ionescu, C. & Hu, X. 2020 Copod: copula-based outlier detection. In: 2020 IEEE International Conference on Data
Mining (ICDM). IEEE, pp. 1118–1123.
Li, Z., Zhao, Y., Hu, X., Botta, N., Ionescu, C. & Chen, G. H. 2022 Ecod: Unsupervised outlier detection using empirical cumulative
distribution functions. arXiv preprint arXiv:2201.00382.
Liemberger, R. & Farley, M. 2004 Developing A non-Revenue Water Reduction Strategy, Part 1: Investigating and Assessing Water Losses.
Liu, F. T., Ting, K. M. & Zhou, Z.-H. 2012 Isolation-based anomaly detection. ACM Transactions on Knowledge Discovery From Data
(TKDD) 6 (1), 1–39.
Mamlook, R. & Al-Jayyousi, O. 2003 Fuzzy sets analysis for leak detection in infrastructure systems: a proposed methodology. Clean
Technologies and Environmental Policy 6 (1), 26–31.

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest
Uncorrected Proof

Water Supply Vol 00 No 0, 17

Mashhadi, N., Shahrour, I., Attoue, N., El Khattabi, J. & Aljer, A. 2021 Use of machine learning for leak detection and localization in water
distribution systems. Smart Cities 4 (4), 1293–1315.
Minka, T. 2000 Automatic choice of dimensionality for PCA. In: Advances in Neural Information Processing Systems. p. 13.
Puust, R., Kapelan, Z., Savic, D. & Koppel, T. 2010 A review of methods for leakage management in pipe networks. Urban Water Journal 7(1),
25–45.
Rahmat, R. F., Satria, I. S., Siregar, B. & Budiarto, R. 2017 Water pipeline monitoring and leak detection using flow liquid meter sensor. IOP
Conference Series: Materials Science and Engineering 190, 012036. https://doi.org/10.1088/1757-899x/190/1/012036.
Rajeswaran, A., Narasimhan, S. & Narasimhan, S. 2018 A graph partitioning algorithm for leak detection in water distribution networks.
Computers & Chemical Engineering 108, 11–23. ISSN 0098-1354. https://doi.org/10.1016/j.compchemeng.2017.08.007.
Sadeghioon, A. M., Metje, N., Chapman, D. & Anthony, C. 2018 Water pipeline failure detection using distributed relative pressure and
temperature measurements and anomaly detection algorithms. Urban Water Journal 15 (4), 287–295.
Schölkopf, B., Platt, J. C., Shawe-Taylor, J., Smola, A. J. & Williamson, R. C. 2001 Estimating the support of a high-dimensional distribution.
Neural Computation 13 (7), 1443–1471.
Shyu, M.-L., Chen, S.-C., Sarinnapakorn, K. & Chang, L. 2003 A Novel Anomaly Detection Scheme Based on Principal Component Classifier.
Technical Report, Miami Univ Coral Gables Fl Dept of Electrical and Computer Engineering.
Wu, Z. Y. & He, Y. 2021 Time series data decomposition-based anomaly detection and evaluation framework for operational management of
smart water grid. Journal of Water Resources Planning and Management 147 (9), 04021059.
Xu, Q., Liu, R., Chen, Q. & Li, R. 2014 Review on water leakage control in distribution networks and the associated environmental benefits.
Journal of Environmental Sciences 26 (5), 955–961. ISSN 1001-0742. https://doi.org/10.1016/S1001-0742(13)60569-0.
Yu, J., Zhang, L., Chen, J., Xiao, Y., Hou, D., Huang, P., Zhang, G. & Zhang, H. 2021 An integrated bottom-up approach for leak detection in
water distribution networks based on assessing parameters of water balance model. Water 13 (6). ISSN 2073-4441. doi:10.3390/
w13060867.
Zhao, Y., Nasrullah, Z. & Li, Z. 2019 Pyod: a Python toolbox for scalable outlier detection. Journal of Machine Learning Research 20 (96),
1–7. Available from: http://jmlr.org/papers/v20/19-011.html.

First received 1 December 2022; accepted in revised form 2 May 2023. Available online 18 May 2023

Downloaded from http://iwaponline.com/ws/article-pdf/doi/10.2166/ws.2023.118/1221262/ws2023118.pdf


by guest

You might also like