Explainable AI for Smart Characterization of Dairy-Lagoon Wastewater Using Farm-Held-Out Validation

Commercial dairy farms are essential to milk production, food security, and rural economies, but they also generate large volumes of manure and wastewater requiring reliable characterization. Measuring solids, organic matter, and dissolved constituents is important for pollution control, nutrient management, and resource recovery. Artificial intelligence may reduce analytical burden, although its usefulness depends on demonstrating that predictions generalize across farms and that model explanations are scientifically credible. This study evaluated 205 lagoon-manure samples collected between May and August 2021, within a four-year project, from 18 commercial dairies in California’s Central Valley. Sample availability varied among measurements and modeling tasks because of missing observations. Gravimetric and chemical measurements were analyzed using polynomial ridge regression, random forest, and XGBoost with farm-held-out cross-validation; validated models were interpreted using SHAP and LIME. All 205 samples had complete gravimetric records, and chemical measurements were available for 155 samples. Samples averaged 96.02% moisture, 3.98% total solids, and 3.06% organic matter. Organic matter was predicted from the combined gravimetric measurements (R2 = 0.975, RMSE = 0.97 percentage points, MAE = 0.39, and RPD = 6.32). Total solids alone produced similar pooled performance (R2 = 0.979; RPD = 6.86), and a linear regression on total solids performed comparably (R2 = 0.980). However, prediction errors were strongly concentration dependent. For the linear benchmark, mean absolute errors represented approximately 56%, 21%, and 11% of mean organic-matter concentrations in samples containing <1%, 1–10%, and >10% total solids, respectively. These findings indicate that strong pooled performance does not establish reliable screening accuracy for highly dilute samples. In contrast, nitrate, sodium, salinity, calcium, and pH could not be predicted reliably (R2 = −0.431 to 0.091; RPD = 0.84–1.05). SHAP identified moisture–solids as the dominant contributor to organic-matter predictions, whereas LIME supported sample-level interpretation. These findings apply to flush-based dairies in California’s Central Valley, and this approach can support low-cost screening of dairy-lagoon manure for organic matter while directing chemically governed properties to laboratory measurement.

Authors

Institutions

Publication Details

Journal
AgriEngineering
Published
2026-11-16
DOI
https://doi.org/10.3390/agriengineering8110492
Primary Topic
Water Quality Monitoring and Analysis
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
article

Explainable AI for Smart Characterization of Dairy-Lagoon Wastewater Using Farm-Held-Out Validation

Prachi Pandey, Pramod Pandey, Abdullah Al Rawi, Behrooz Pakzadeh
5 links
AgriEngineering
Water Quality Monitoring and Analysis
article

Explainable AI for Smart Characterization of Dairy-Lagoon Wastewater Using Farm-Held-Out Validation

Prachi Pandey, Pramod Pandey, Abdullah Al Rawi, Behrooz Pakzadeh
article en

Abstract

Commercial dairy farms are essential to milk production, food security, and rural economies, but they also generate large volumes of manure and wastewater requiring reliable characterization. Measuring solids, organic matter, and dissolved constituents is important for pollution control, nutrient management, and resource recovery. Artificial intelligence may reduce analytical burden, although its usefulness depends on demonstrating that predictions generalize across farms and that model explanations are scientifically credible. This study evaluated 205 lagoon-manure samples collected between May and August 2021, within a four-year project, from 18 commercial dairies in California’s Central Valley. Sample availability varied among measurements and modeling tasks because of missing observations. Gravimetric and chemical measurements were analyzed using polynomial ridge regression, random forest, and XGBoost with farm-held-out cross-validation; validated models were interpreted using SHAP and LIME. All 205 samples had complete gravimetric records, and chemical measurements were available for 155 samples. Samples averaged 96.02% moisture, 3.98% total solids, and 3.06% organic matter. Organic matter was predicted from the combined gravimetric measurements (R2 = 0.975, RMSE = 0.97 percentage points, MAE = 0.39, and RPD = 6.32). Total solids alone produced similar pooled performance (R2 = 0.979; RPD = 6.86), and a linear regression on total solids performed comparably (R2 = 0.980). However, prediction errors were strongly concentration dependent. For the linear benchmark, mean absolute errors represented approximately 56%, 21%, and 11% of mean organic-matter concentrations in samples containing <1%, 1–10%, and >10% total solids, respectively. These findings indicate that strong pooled performance does not establish reliable screening accuracy for highly dilute samples. In contrast, nitrate, sodium, salinity, calcium, and pH could not be predicted reliably (R2 = −0.431 to 0.091; RPD = 0.84–1.05). SHAP identified moisture–solids as the dominant contributor to organic-matter predictions, whereas LIME supported sample-level interpretation. These findings apply to flush-based dairies in California’s Central Valley, and this approach can support low-cost screening of dairy-lagoon manure for organic matter while directing chemically governed properties to laboratory measurement.

AgriEngineeringVol. 8(11)
University of California, Davis (US)
Zero hunger
Water Quality Monitoring and Analysis
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon