Online Detection of Water Contamination Under Concept Drift

Jin Li, Kleanthis Malialis, Stelios G. Vrachimis, Marios M. Polycarpou · DOI

Introduction

Water Distribution Networks (WDNs) are critical infrastructure components that require constant monitoring to ensure public safety. Chlorine sensors are typically deployed throughout these networks to detect potential contamination events. However, these sensors are notoriously sensitive to environmental factors, leading to a phenomenon known as concept drift. Concept drift—caused by sensor aging, power fluctuations, or natural hydraulic shifts—changes the underlying data distribution, often triggering false alarms.

This creates a "Boy Who Cried Wolf" scenario: if a system frequently flags harmless baseline shifts as contamination, operators may begin to ignore alerts, potentially missing a genuine crisis. To address this, we present AD&DD (Dual-Threshold Anomaly and Drift Detection), an unsupervised framework designed to distinguish between dangerous contamination events and harmless concept drift in real-time.

The AD&DD Framework

The AD&DD algorithm utilizes a decentralized architecture where each sensor node operates as an independent agent. The core of the system is built on a Variational Autoencoder with Long Short-Term Memory layers (LSTM-VAE). This architecture is specifically chosen to capture the complex time-series dependencies inherent in water quality data while learning a compressed "latent" representation of normal operating conditions.

The framework employs a novel Dual-Threshold Mechanism to separate anomalies from drift:

  1. Anomaly Detection (AD): This component monitors the reconstruction loss of the VAE. If the model cannot accurately reconstruct an incoming data point based on its learned patterns, the point is flagged as a potential contamination anomaly.
  2. Drift Detection (DD): Rather than looking at raw sensor values, drift detection occurs within the latent space. The algorithm compares a "reference window" of historical normal encodings to a "recent window." If the Euclidean distance between these windows exceeds a specific threshold, the system identifies the change as concept drift rather than a sudden anomaly.

When drift is confirmed, the system triggers an online adaptation process. The model automatically retrains using the most recent data to establish a "new normal," allowing the system to self-correct without human intervention and preventing persistent false alarms.

Experimental Setup

The effectiveness of AD&DD was evaluated using two simulated water networks via the EPyT-Flow tool:

  • Hanoi Network: A smaller-scale network consisting of 32 nodes and 34 pipes.
  • Zhi Jiang (ZJ) Network: A complex, large-scale network featuring 113 demand nodes and 164 pipes.

The simulations modeled arsenite contamination as the primary anomaly and sensor offsets as the source of concept drift. The models were pre-trained on six months of historical data and tested against a subsequent six-month "live" stream.

Key Insights

  • Latent Space Robustness: By performing drift detection in the latent space rather than on raw data, AD&DD captures the underlying "essence" of the water quality dynamics. This makes the system significantly more robust against statistical noise.
  • Decentralized Localization: Instead of a centralized monitoring approach, AD&DD treats sensors as local agents. By intersecting the upstream areas of sensors reporting anomalies with the downstream areas of those reporting normal status, the system can pinpoint the contamination source with high precision and low computational cost.
  • Unsupervised Learning: Because real-world contamination events are rare, labeled datasets are virtually non-existent. AD&DD’s ability to learn and adapt in an entirely unsupervised manner makes it uniquely suited for practical deployment in existing WDNs.

Results and Performance

In comparative testing against state-of-the-art methods—including iForest++, LOF++, and VAE4AS—AD&DD demonstrated superior performance, particularly in the complex ZJ network.

While other methods either suffered from high false alarm rates during drift events or failed to detect slow-moving contamination entirely, AD&DD maintained a high G-mean (a metric balancing true positives and true negatives). Specifically, while the similar VAE4AS method raised frequent false alarms during sensor offsets, AD&DD correctly identified the drift, updated its baseline, and maintained stable monitoring. In localization tests, the decentralized approach successfully narrowed the potential contamination source to a small subset of 2–5 nodes within the large-scale network.

Limitations and Future Work

Despite its successes, the framework has limitations. The current localization logic relies on known flow directions within the pipes; however, in some complex networks, flow can be bidirectional or change dynamically. Additionally, while AD&DD significantly reduces false positives compared to its peers, the rate remains "relatively high" in extreme drift scenarios due to the inherent difficulty of distinguishing subtle, slow-onset contamination from sensor drift. Future research will focus on adapting the model for dynamic flow conditions and exploring scenarios involving multiple simultaneous contamination sources.

Summary updated

BibTeX
@misc{li2025online,
  author = {Jin Li and Kleanthis Malialis and Stelios G. Vrachimis and Marios M. Polycarpou},
  title = {{Online Detection of Water Contamination Under Concept Drift}},
  year = {2025},
  eprint = {2501.02107},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.02107},
}
Figure