A machine learning framework that pairs support vector regression with ten different nature-inspired optimization algorithms has emerged as a surprisingly accurate way to forecast how much total nitrogen will remain in the treated water leaving a full-scale municipal wastewater treatment plant. In a study published in Applied Water Science, researchers led by Hang Yin and Meysam Alizamir report that their best hybrid model, SVR-HFA, predicted effluent total nitrogen with a root mean square error of 1.285 milligrams per liter and a correlation coefficient of 0.905 during validation, outperforming both standalone support vector regression and multiple linear regression. What sets the work apart is not just the accuracy but the transparency: the team applied two interpretability tools, SHAP and LIME, to show exactly which measurements drive each prediction.
The study site was a large urban wastewater treatment plant in Zhejiang Province, China, which purifies sewage through an ecological combination pond system designed to handle up to 60,000 cubic meters of wastewater per day. The ponds are organized into thirteen interconnected sections with an average water depth of 8.8 meters, arranged into four functional zones: an aerobic stage covering Zones 1 through 5 with a total volume of 143,458 cubic meters, an anoxic stage in Zones 6 through 8 holding 97,075 cubic meters, a second aerobic stage in Zones 9 through 12 with 142,266 cubic meters, and a final settling unit in Zone 13 with 74,800 cubic meters. To boost denitrification, an external polymer-based carbon source is injected into the first and second anoxic compartments, Zones 6 and 7, and mixed liquor from the settling section is recirculated back to Zone 6.
The researchers assembled 1,095 consecutive daily datasets spanning January 1, 2021 through December 31, 2023. Thirteen variables were tracked: external carbon source dosing, influent ammonium nitrogen, influent total nitrogen, influent flowrate, dissolved oxygen in Zones 5 and 7, total nitrogen in Zones 5, 6, and 7, chemical oxygen demand in Zones 6 and 7, energy consumption, and effluent total nitrogen as the prediction target. The data were split into 80 percent training and 20 percent validation subsets, and the models were tested under eight different combinations of input variables, with the most complex scenario using all twelve predictors and the simplest using only two.
Before modeling, the team checked whether the training and validation sets came from similar distributions using three statistical tests: the Kolmogorov-Smirnov test, the Jensen-Shannon distance, and the energy distance. Most variables, including effluent total nitrogen, total nitrogen in Zones 5, 6, and 7, external carbon source, influent total nitrogen, and influent ammonium, showed highly similar distributions with non-significant KS test results. Only energy consumption differed significantly between the two sets, with a p-value of 0.0409, while dissolved oxygen in Zone 7 showed a marginal deviation at 0.0741. Energy consumption and influent flowrate also displayed the largest Jensen-Shannon and energy distances, flagging them as the least consistent variables across the split.
The ten hybrid architectures each wrapped support vector regression inside a different metaheuristic optimizer: the tunicate swarm algorithm, snake optimization, hyena spotted optimization, human felicity algorithm, beetle antennae search, manta ray foraging optimization, lightning search algorithm, grey wolf optimizer, bat algorithm, and teaching-learning-based optimization. Each optimizer tuned the SVR hyperparameters, including the regularization parameter, epsilon, and gamma, to minimize the gap between forecasted and observed effluent nitrogen values. Performance was judged with four metrics: mean absolute error, root mean square error, correlation coefficient, and Nash-Sutcliffe efficiency.
During training, SVR-HSO and SVR-TLBO with all twelve predictors led the field, each achieving a correlation coefficient of 0.997, a Nash-Sutcliffe efficiency of 0.992, an RMSE of roughly 0.264 to 0.265 milligrams per liter, and a mean absolute error of 0.251 milligrams per liter. But the validation phase told a different story. There, SVR-HFA1 proved the strongest model, reaching a correlation coefficient of 0.905, a Nash-Sutcliffe efficiency of 0.814, an RMSE of 1.285 milligrams per liter, and a mean absolute error of 0.865 milligrams per liter, along with the highest coefficient of determination, 0.819, among all evaluated models. SVR-GWO followed with an RMSE of 1.293 milligrams per liter and a correlation of 0.902, and SVR-TSA took third with 1.316 milligrams per liter and 0.898. Among the hybrids, SVR-MRFO performed worst at 1.397 milligrams per liter and 0.893, while multiple linear regression trailed the entire field with an RMSE of 2.300 milligrams per liter and a correlation of 0.644.
Measured against each rival’s RMSE, SVR-HFA1 improved predictive performance by 78.99 percent over MLR1, 12.06 percent over standalone SVR, and smaller margins over the other hybrids, ranging from 0.62 percent against SVR-GWO1 to 8.72 percent against SVR-MRFO1. A Kruskal-Wallis test comparing predicted and observed values found no statistically significant differences among the SVR-based variants, all with p-values above 0.05, meaning their performance was statistically comparable. Notably, none of the developed models fully reproduced the statistical distribution of the measured effluent nitrogen concentrations, including the minimum, maximum, mean, median, and interquartile range, in the boxplot comparison.
The interpretability analysis yielded the study’s most operationally interesting findings. SHAP analysis identified total nitrogen in Zone 7 as the single most influential predictor, followed by chemical oxygen demand in Zone 6 and influent total nitrogen. The authors explain this from a process perspective: Zone 7 is the final treatment stage immediately before discharge, so a high nitrogen value there signals that upstream nitrification and denitrification have not sufficiently proceeded, acting as a last warning before effluent standards are breached. LIME analysis of individual test samples reinforced the pattern, finding that dissolved oxygen in Zone 7, total nitrogen in Zone 7, and influent total nitrogen predominantly pushed predictions upward, while chemical oxygen demand in Zone 6, dissolved oxygen in Zone 5, and influent flowrate pushed them downward across most modeling frameworks.
Those directional relationships make engineering sense. Denitrification requires an oxygen-free, anoxic environment and relies on organic matter as a carbon source, so a high dissolved oxygen concentration in Zone 7 indicates that excessive aeration is inhibiting denitrification, while low chemical oxygen demand in Zone 6 suggests a shortage of the carbon source that denitrifying microbes need. The authors translate these insights into practical guidance: adjust blower output when dissolved oxygen in Zone 7 is the main driver of rising effluent nitrogen, inject external carbon preemptively when influent nitrogen climbs or Zone 6 carbon demand falls, and treat Zone 7 and Zone 6 nitrogen readings as key management indicators that trigger adjustments to sludge recirculation or internal recirculation rates.
The team is candid about the study’s limits. The dataset comes from a single plant in a specific region over three years, which may restrict broader generalizability and could encourage overfitting during training. They suggest that future work could address this with datasets spanning wider value ranges, k-fold cross-validation, and dropout techniques, and they plan to compare weekly versus daily sampling frequency, run sensitivity analyses, and apply time-series decomposition for routine effluent tracking. Even so, the combination of a validated hybrid predictor with SHAP and LIME explanations offers plant operators something rare in wastewater machine learning: a model whose forecasts come with a readable account of why they were made, turning black-box output into actionable signals about aeration, carbon dosing, and recirculation before compliance is compromised.
Subject of Research: Hybrid machine learning models with SHAP and LIME interpretability for predicting effluent total nitrogen at a full-scale wastewater treatment plant
Article Title: Predicting effluent total nitrogen removal in full-scale WWTPs using a novel optimized machine learning model: SVR enhanced by SHAP and LIME explainability
Article References: Yin, H., Alizamir, M., Heddam, S., Kim, S., & Ikram, R. M. A. (2026). Predicting effluent total nitrogen removal in full-scale WWTPs using a novel optimized machine learning model: SVR enhanced by SHAP and LIME explainability. Applied Water Science, 16(11), Article 298. https://doi.org/10.1007/s13201-026-02972-1
Image Credits: AI Generated
DOI: 10.1007/s13201-026-02972-1
Keywords: wastewater treatment, machine learning, support vector regression, total nitrogen, SHAP, LIME, metaheuristic optimization, denitrification, water quality prediction, ecological combination pond, effluent monitoring, explainable AI
Cite Scienmag News
Teresa Odom. (October 28, 2026). Machine Learning Model Predicts Nitrogen in Treated Wastewater with SHAP and LIME Explanations. Scienmag. https://scienmag.com/machine-learning-model-predicts-nitrogen-in-treated-wastewater-with-shap-and-lime-explanations/
Teresa Odom. "Machine Learning Model Predicts Nitrogen in Treated Wastewater with SHAP and LIME Explanations." Scienmag, 28 October 2026, https://scienmag.com/machine-learning-model-predicts-nitrogen-in-treated-wastewater-with-shap-and-lime-explanations/. Accessed 28 October 2026.
Teresa Odom. "Machine Learning Model Predicts Nitrogen in Treated Wastewater with SHAP and LIME Explanations." Scienmag. October 28, 2026. https://scienmag.com/machine-learning-model-predicts-nitrogen-in-treated-wastewater-with-shap-and-lime-explanations/

