Sanitation remains one of the most stubborn public-health challenges in developing nations, and South Africa is no exception. Despite significant investment in sanitation facilities, many municipalities still struggle with fragmented data gathering, manual reporting, poor interoperability and the absence of real-time monitoring across the sanitation service chain. Now, a team of South African researchers has proposed a framework that could fundamentally change how cities understand and manage their sanitation systems — by teaching artificial intelligence to explain itself.
The framework, called XAI-SFD (Explainable Artificial Intelligence for intelligent digitalisation of Shit Flow Diagrams), was developed by Rotimi-Williams Bello and colleagues at Tshwane University of Technology together with the Water Research Commission. It was published in Frontiers in Environmental Science as a methods article. Shit Flow Diagrams, or SFDs, are internationally recognised tools that map how excreta and wastewater move through the stages of containment, emptying, conveyance, treatment and disposal or reuse. They highlight both safe and unsafe flows, allowing governments, municipalities and development partners to detect weak spots in sanitation systems. The problem, however, is that traditional SFDs are built manually, relying on household surveys, expert opinions and institutional data. The process is resource-intensive, expensive and infrequent, with updates often coming years apart — leaving rapidly growing cities blind to changing conditions.
XAI-SFD aims to turn these static snapshots into living digital assets. The proposed architecture integrates Internet of Things sensors, GIS-based spatial analysis, machine learning, explainable artificial intelligence, Digital Twin technology, computer vision and dashboard-based decision support into a single end-to-end system. Rather than sporadic field surveys, cities would draw on continuous data streams from smart sensors, satellite imagery, UAV surveys, wastewater monitoring systems and geospatial databases. The framework was also designed to interoperate with South Africa’s National Integrated Water Information System (NIWIS), potentially transforming it from an ordinary information system into an intelligent, predictive and explainable national sanitation management platform.
What makes the approach distinctive is its insistence on transparency. Many AI models used in sanitation management are black boxes that produce results without explaining the factors behind their decisions. This lack of interpretability erodes stakeholder trust, complicates regulatory acceptance and can lead municipal authorities to ignore AI recommendations altogether. XAI-SFD addresses this by embedding SHAP (SHapley Additive exPlanations), a technique rooted in cooperative game theory that assigns each input feature a value showing its impact on the model’s output. SHAP provides both global explanations of overall model behaviour and local explanations of why a particular site is classified as dangerous or safe, with mathematical properties such as local accuracy, consistency and attribution fairness.
To test the feasibility of selected components, the team carried out a controlled proof-of-concept at municipal scale using 247 monitoring stations from the City of Cape Town’s Routine Inland Water Quality Monitoring network. The dataset included geographic coordinates, monitoring type, waterbody type, catchment or coastline, planning region, district and monitoring status. Rivers dominated the network with 103 sites (41.70 percent), followed by canals with 50 sites (20.24 percent) and vleis and wetlands with 33 sites (13.36 percent). Chemical and bacterial monitoring accounted for 165 sites (66.80 percent), while 47 sites (19.03 percent) added algal assessment and 13 sites (5.26 percent) included toxicity testing. Spatially, 107 sites (43.32 percent) sat in the South planning region, 58 (23.48 percent) in Central, 42 (17.00 percent) in East and 40 (16.19 percent) in North.
The researchers applied K-means clustering to the spatial and categorical variables, testing configurations from two to five clusters. The four-cluster solution performed best, achieving a silhouette coefficient of 0.3133 and a Davies-Bouldin index of 1.3324, with a Calinski-Harabasz score of 83.46. The silhouette value indicates moderate internal cohesion rather than sharply separated groups — the clusters represent spatial-context groupings, not confirmed sanitation-risk zones. Nearest-neighbour distance statistics revealed a median of 670.2 metres, a mean of 1,151.5 metres and a 95th percentile of 3,495.2 metres, showing considerable variation in how isolated the monitoring sites are from one another.
For prioritisation, the team constructed an intrinsically explainable composite priority score from five metadata-derived dimensions: waterbody sensitivity (weighted 30 percent), monitoring complexity (25 percent), regional coverage gap (15 percent), catchment monitoring density (15 percent) and spatial isolation (15 percent). Scores across the 247 sites ranged from 25.97 to 77.06, with a median of 47.02. Using the 90th percentile (62.89) as the high-priority threshold, 25 stations (10.12 percent) were classified as high priority, 99 (40.08 percent) as medium priority and 123 (49.80 percent) as low priority. Waterbody sensitivity contributed the largest average share (18.17 points), followed by monitoring complexity (12.58 points), catchment density (8.54 points), regional coverage gap (7.48 points) and spatial isolation (1.53 points). Among the top 25 sites, monitoring complexity and waterbody sensitivity each contributed roughly 20.86 and 20.83 points respectively. The highest-scoring sites were concentrated in the Diep catchment within the Central and North planning regions, dominated by rivers, estuaries and vleis requiring complex chemical, bacterial, algal and toxicity monitoring.
The authors are careful about what these results do and do not demonstrate. Because the dataset lacks labelled sanitation-flow outcomes and timestamped water-quality measurements at the monitoring sites, the findings must be regarded as prototyping results rather than validation of sanitation risk prediction models. No accuracy, precision, recall, F1-score, RMSE or MAE figures can be reported, and the researchers explicitly state that doing so would be methodologically wrong. The clustering outputs are spatial-context segments, not sanitation-risk classes, and the priority scores are decision-support outputs based on pre-defined weights, not measured pollution-risk scores. Components requiring live IoT data, labelled outcomes, automated SFD generation, Digital Twin operations, remote sensing and computer vision integration, and NIWIS interoperability remain future implementation modules.
The framework aligns with broader movements such as Water 4.0, Industry 4.0 and smart-city paradigms, and speaks directly to Sustainable Development Goal Target 6.2 on access to adequate sanitation and hygiene. A fully operational XAI-SFD system would allow municipalities to move from reactive management — driven by complaints and periodic inspections — to proactive, risk-based decision support informed by sensor readings, infrastructure condition, GIS data and environmental measurements. It would also support SDG reporting, regulatory compliance, benchmarking and municipal comparison through automated dashboards.
The researchers outline a four-phase roadmap from proof-of-concept to operational validation: data preparation and spatial analysis (demonstrated here), a pilot incorporating sanitation flows and water-quality ground truth, live municipal implementation with IoT and automated SFD models, and finally operational validation using labelled outcomes and system-level metrics such as data completeness, processing delay and stakeholder acceptance. Future directions include multi-municipal prototypes, supervised and deep learning risk prediction, multimodal AI combining GIS layers and sensor data, federated learning across municipalities, reinforcement learning for maintenance scheduling, and Digital Twin-driven climate adaptation scenarios. Ethical and governance considerations — data ownership, cybersecurity, privacy, fairness and human oversight — are flagged as essential conditions for socially acceptable intelligent sanitation. The XAI-SFD framework, in short, offers a realistic pathway toward smarter, continuously evolving sanitation management built on data South African cities already collect.
Subject of Research: XAI-SFD: an explainable artificial intelligence framework for intelligent digitalisation of shit flow diagrams and smart sanitation management in South Africa
Article Title: XAI-SFD: an explainable artificial intelligence framework for intelligent digitalisation of shit flow diagrams and smart sanitation management in South Africa
Article References: Bello, R.-W., Ogundokun, R. O., Owolawi, P. A., Lekalakala, R. G., Mpenyana‐Monyatsi, L., Petja, B. M., & van Wyk, E. A. (2026). XAI-SFD: an explainable artificial intelligence framework for intelligent digitalisation of shit flow diagrams and smart sanitation management in South Africa. Frontiers in Environmental Science, 14, Article 1962477. https://doi.org/10.3389/fenvs.2026.1962477
Image Credits: AI Generated
DOI: 10.3389/fenvs.2026.1962477
Keywords: XAI-SFD, explainable, artificial, intelligence, framework, intelligent, digitalisation, shit, flow, diagrams, smart, sanitation
Cite Scienmag News
Violet Maxwell. (October 16, 2026). Explainable AI Turns Static Sanitation Maps Into Living Systems for South Africa. Scienmag. https://scienmag.com/explainable-ai-turns-static-sanitation-maps-into-living-systems-for-south-africa/
Violet Maxwell. "Explainable AI Turns Static Sanitation Maps Into Living Systems for South Africa." Scienmag, 16 October 2026, https://scienmag.com/explainable-ai-turns-static-sanitation-maps-into-living-systems-for-south-africa/. Accessed 16 October 2026.
Violet Maxwell. "Explainable AI Turns Static Sanitation Maps Into Living Systems for South Africa." Scienmag. October 16, 2026. https://scienmag.com/explainable-ai-turns-static-sanitation-maps-into-living-systems-for-south-africa/

