✅
International Research Platform
Serving Researchers Since 2012

Explainable AI-Based Water Leakage Detection and Consumption Forecasting for Smart Buildings with an Early Warning System

DOI : 10.5281/zenodo.24709254
Download Full-Text PDF Cite this Publication

Text Only Version

Explainable AI-Based Water Leakage Detection and Consumption Forecasting for Smart Buildings with an Early Warning System

Jayshree Ghorpade Aher

DCET, SoCSE, MIT WPU Pune, India

Girija Dahiphale

DCET, SoCSE, MIT WPU Pune, India

Anshul Dhore

DCET, SoCSE, MIT WPU Pune, India

Siddharth Desai

DCET, SoCSE, MIT WPU Pune, India

Pratik Lokhande

DCET, SoCSE, MIT WPU Pune, India

Abstract – This paper presents an explainable AI (XAI) frame- work that combines water-leak detection, day-ahead consumption forecasting and a tiered early warning system for smart buildings, evaluated on a reproducible simulated dataset of six buildings

TABLE I

System Architecture Layers and Components

Layer Component(s) Function

with one year of hourly smart-meter readings and 68 labelled leak events. On a held-out nal fth of the year, XGBoost detects leak hours with an F1-score of 0.711 and ROC-AUC of 0.892, ahead of Random Forest, logistic regression and Isolation Forest. The early warning layer raised an alert for all 13 leak events in

the test period, with a median delay of 3 hours for bursts, and

Data Smart meters, ow/pressure sensors

Processing ETL pipeline, feature

engineering

Modeling Detection model, forecasting model

Explainability

Continuous acquisition of raw consumption data Cleaning, resampling, feature extraction

Leak classication and demand prediction

81 percent of alert episodes coincided with a real leak. For 24-

SHAP, LIME Feature attribution for

hour forecasting, gradient boosting (mean absolute error 0.334 cubic metres per hour) and a stacked LSTM (0.357 cubic metres per hour) clearly outperform ARIMA and SARIMA. SHAP and LIME show that night-time minimum ow, line pressure and recent ow history drive the predictions.

Decision Rule engine

Presentation Dashboard, notication service

every prediction Maps predictions and

explanations to alert tiers Visualisation and

real-time alerting

Keywordssmart water management; leak detection; con- sumption forecasting; explainable AI; XGBoost; LSTM; SHAP; LIME; early warning system

  1. Introduction

    Smart meters track building water use in near real time, yet leaks can go unnoticed for days because raw readings do not produce actionable warnings. Visual inspection, xed- threshold alarms and Minimum Night Flow (MNF) analysis are labour-intensive, miss small leaks, or misre under night- time occupancy. Machine learning (ML) can learn normal behaviour, but black-box outputs are hard for facility staff to trust.

    This work builds one pipeline that (i) detects abnormal water use linked to leaks, (ii) forecasts hourly consumption 1 to 24 hours ahead, (iii) explains each decision with SHAP and LIME, and (iv) turns model outputs into tiered alerts. Because labelled building leak records are rarely public, all experiments use a documented, seeded simulation so that results are reproducible.

  2. Literature Survey

    Romano et al. [1] detected pipe bursts in district metered areas by combining wavelet de-noising, neural-network ow forecasting, statistical process control and Bayesian inference. Candelieri [2] used time-series clustering with Support Vector

    Regression for both water demand forecasting and anomaly de- tection. Random Forest, SVM and neural networks have been applied to leak detection [3] and localisation [4]. Deep models include CNNs on vibration spectra [5], transient frequency response with deep learning [6] and Transformers on simulated pressure data [7]. Lee and Yoo [8] predicted inow with an RNN-LSTM [9] and agged leaks when observations exceeded thresholds. SHAP [10] and LIME [11] explain individual predictions but are rarely applied to building water systems. Detection and forecasting have thus been combined before [2], [8], but explanations and graded alerts are seldom part of the same pipeline, which is the gap this work addresses.

  3. Proposed System

    The framework is a ve-stage pipeline: data acquisition, preprocessing and feature engineering, model training (two parallel tracks for leak detection and forecasting), explanation generation and alert dissemination (Table I, Fig. 1). The dashboard and notication layer is designed but not evaluated here.

    1. Simulated Dataset

      Six buildings (two ofces, two residential blocks, two hos- tels) were simulated hourly for 2025, giving 52,560 records. Demand follows building-specic occupancy proles scaled by temperature, with weekend and Indian public-holiday ef- fects, random night activity, early-morning irrigation in three

      TABLE II

      Early Warning Alert Tiers ( : tuned decision threshold)

      Tier Trigger Condition Action

      Informational p 0.5 Logged on dashboard; no notication

      Fig. 1. Modular system architecture of the explainable leak detection and forecasting pipeline.

      buildings and 8% noise. Line pressure falls with total ow

      Warning p for 3 consecutive hours

      Critical Warning, p 0.9 and ow

      1.5× hourly baseline

      TABLE III

      Dashboard alert + email to facility manager Immediate SMS/push, recommended shutoff

      and drops further during leaks. Three leak types were injected: background leaks (412% of mean ow, 28 days), bursts (35 120%, 430 h) and gradually growing leaks (1030%, 310 days), giving 68 events and 16.5% leak hours. Sensor spikes and gaps were also added.

    2. Preprocessing and Features

      Gaps up to 2 h are forward-lled; longer gaps use the same hour of the previous day or week. A reading is removed as an outlier only if both the IQR rule and a z-score test (|z| > 3, z = (x )/) ag its residual from a 24 h rolling median, so genuine leak spikes survive (41 readings removed). Features include ow, line pressure, deviation and ratio from an hour- of-week baseline learned on training data, 6 h and 24 h rolling statistics, rate of change, lags, night-time (14 a.m.) minimum ow over the last 24 h, pressure drop, and hour, weekday, holiday, rain and temperature. Each buildings year is split chronologically into 60%/20%/20% training, validation and test sets.

    3. Leak Detection and Consumption Forecasting

      Leak detection is hourly binary classication with Random Forest [12] and XGBoost [13], compared with logistic regres- sion and an unsupervised Isolation Forest. XGBoost adds trees sequentially while minimising a regularised objective:

      n

      i 2

      L(k) = L l yi, y(k1) + fk(xi) + T + 1 w 2 (1)

      i=1

      where T is the number of leaves and w the leaf weights. Fore- casting predicts the next 24 hourly values from the previous 168 h of ow and calendar and temperature context, using a two-layer stacked LSTM. Baselines are ARIMA, SARIMA and a direct multi-horizon gradient boosting regressor.

    4. Explainability and Early Warning

    [

    SHAP TreeExplainer attributes each XGBoost prediction to features through Shapley values,

    Tools and Technology Stack

    Category Tools / Libraries

    Language / Data Python 3.13, pandas, NumPy, Matplotlib ML / Deep Learning scikit-learn 1.9, XGBoost 3.4, PyTorch 2.15 Time Series statsmodels 0.15 (ARIMA, SARIMA)

    Explainability SHAP 0.54, LIME 0.2

    Alerting (design) Dashboard, email/SMS alerts (not evaluated)

    TABLE IV

    Leak Detection Results on the Tes Period

    Model Acc. Prec. Recall F1 AUC

    Logistic Regression

    0.904

    0.789

    0.501

    0.613

    0.862

    Isolation Forest

    0.353

    0.147

    0.681

    0.242

    0.486

    Random Forest

    0.920

    0.843

    0.580

    0.687

    0.890

    XGBoost

    0.925

    0.852

    0.610

    0.711

    0.892

    TABLE V

    24-Hour Forecasting Results (432 Rolling-Origin Forecasts)

    Model

    MAE (m3/h)

    RMSE

    MAPE (%)

    ARIMA

    1.347

    1.757

    123.3

    SARIMA

    0.546

    1.021

    33.8

    Gradient Boosted Regressor

    0.334

    0.621

    20.6

    Stacked LSTM

    0.357

    0.734

    22.7

  4. Implementation

    Table III lists the software stack. Random Forest and XG- Boost were tuned by a small grid search on validation F1, class imbalance was handled with class weighting, and each models decision threshold was chosen on the validation set. The LSTM (64 hidden units, dropout 0.2) was trained with Adam (learning rate 103, batch 128) and early stopping (patience 8). ARIMA(2,0,1) and SARIMA(1,0,1)(1,1,1)24 were tted on the six weeks before the test period. Forecasts were issued at every midnight of the 72 test days for each building (432 forecasts).

  5. Results and Discussion

    Leak detection: XGBoost gives the best accuracy, precision,

    i =

    L

    SN \{i}

    |S|! (|N | |S| 1)!

    |N |!

    f (S {i}) f (S)

    (2)

    F1 and AUC, closely followed by Random Forest (Table IV,

    Figs. 23); the tree ensembles clearly beat logistic regression, while Isolation Forest performs at chance level because normal

    both globally (feature ranking) and locally (why one reading was agged). LIME explains individual LSTM forecasts with a local surrogate g:

    (x) = arg min L(f, g, x)+ (g) (3)

    gG

    A rule engine maps the leak probability p and the explanation into three alert tiers (Table II); every alert carries its top three SHAP features so the manager can sanity-check it before acting.

    demand peaks look more unusual than small leaks. Precision is high (0.852) but hourly recall is moderate (0.610): most missed hours (623, Fig. 4) are early hours of small background and gradual leaks.

    Early warning: All 13 leak events in the test period raised a Warning or Critical alert, with a median delay of 3 h for bursts, 17.5 h for background leaks and 46.5 h for gradual leaks. Of 73 alert episodes, 81% overlapped a real leak, and all 16 Critical episodes were genuine.

    Fig. 2. Leak detection performance of the four models on the test period.

    Fig. 3. ROC curves of the leak detection models. Fig. 4. Confusion matrix of XGBoost on the 10,512

    test building-hours.

    Fig. 5. 24 h forecasting error (MAE, RMSE, MAPE) across models.

    Fig. 6. LSTM training and validation loss; best validation epoch 34, training stopped at epoch 42.

    Fig. 7. Global SHAP feature importance of the XGBoost leak detector.

    TABLE VI

    Qualitative Comparison with Prior Approaches

    is moderate; alert thresholds are xed; and the dashboard and notications were not evaluated.

    Approach Live

    Detect.

    Forecast Explainability

  6. Conclusion and Future Scope

This paper presented a reproducible framework uniting XG-

Minimum Night Flow (rule-based)

Night only

No Rule-based

Boost leak detection, LSTM and gradient boosting forecasting and SHAP/LIME explanations in tiered alerts. On simulated

Clustering + SVR [2] Yes Yes No

CNN on vibration spectra [5]

Transformer on pressure data [7]

RNN-LSTM ow

prediction [8]

Yes No No

Yes No No

Yes Yes No

data from six buildings it agged every test leak event, with physically meaningful explanations. Future work includes validation on real meter data, adaptive thresholds and acoustic leak localisation.

References

Proposed system Yes Yes Yes (global + local)

Forecasting: Gradient boosting achieved the lowest error, with the stacked LSTM close behind (MAE 6.7% higher); both reduce MAE by 3539% relative to SARIMA and 7475% relative to non-seasonal ARIMA (Table V, Fig. 5). SARIMA is competitive for the rst 6 hours (MAE 0.263) but degrades over longer horizons (0.498 at 1924 h), whereas gradient boosting (0.353) and the LSTM (0.354) stay stable. MAPE is inated by low night ows; the LSTM converged without overtting (Fig. 6).

Explainability: Globally, SHAP ranks night-time minimum ow, line pressure and the 24 h mean deviation from the hourly baseline highest (Fig. 7), matching the physical signature of a leak: water keeps owing and pressure drops when little use is expected. Locally, for a conrmed night-time leak in building B1 (leak probability 0.92), the ratio of ow to its hourly baseline was the strongest contributor. For ve explained LSTM forecasts, LIMEs ve most inuential inputs were always past ow values from the previous 9 to 57 hours, while calendar and temperature inputs never entered the top ve.

Comparison: Unlike prior work, the system explains and grades every alert (Table VI).

Limitations: Results come from simulated data and must be conrmed on real building meters; hourly recall for small leaks

  1. M. Romano, Z. Kapelan, and D. A. Savic´, Automated detection of pipe bursts and other events in water distribution systems, J. Water Resour. Plann. Manage., vol. 140, no. 4, 2014.

  2. A. Candelieri, Clustering and support vector regression for water demand forecasting and anomaly detection, Water, vol. 9, no. 3, p. 224, 2017.

  3. J. A. Coelho, A. Glória, and P. Sebastião, Precise water leak detection using machine learning and real-time sensor data, IoT, vol. 1, no. 2, pp. 474493, 2020.

  4. N. Mashhadi et al., Use of machine learning for leak detection and localization in water distribution systems, Smart Cities, vol. 4, no. 4,

    pp. 12931315, 2021.

  5. J. Choi and S. Im, Application of CNN models to detect and classify leakages in water pipelines using magnitude spectra of vibration sound, Applied Sciences, vol. 13, no. 5, p. 2845, 2023.

  6. Z. Liao et al., Deep learning identies leak in water pipeline system using transient frequency response, Process Saf. Environ. Prot., vol. 155, pp. 355365, 2021.

  7. J. Luo, C. Wang, J. Yang, and X. Zhong, A Transformer-based approach to leakage detection in water distribution networks, Sensors, vol. 24, no. 19, p. 6294, 2024.

  8. C.-W. Lee and D.-G. Yoo, Development of leakage detection model and its application for water distribution networks using RNN-LSTM, Sustainability, vol. 13, no. 16, p. 9262, 2021.

  9. S. Hochreiter and J. Schmidhuber, Long short-term memory, Neural Computation, vol. 9, no. 8, pp. 17351780, 1997.

  10. S. M. Lundberg and S.-I. Lee, A unied approach to interpreting model predictions, in Proc. NeurIPS, 2017.

  11. M. T. Ribeiro, S. Singh, and C. Guestrin, Why should I trust you? Explaining the predictions of any classier, in Proc. ACM SIGKDD, 2016.

  12. L. Breiman, Random forests, Machine Learning, vol. 45, no. 1, pp. 532, 2001.

  13. T. Chen and C. Guestrin, XGBoost: A scalable tree boosting system, in Proc. ACM SIGKDD, 2016.