Abstract
Microbial communities play essential roles in shaping ecosystem functions and predictive modeling frameworks are crucial for understanding, controlling, and harnessing their properties. Competition and cross-feeding of metabolites drives microbiome dynamics and functions. Existing mechanistic models that capture metabolite-mediated interactions in microbial communities have limited flexibility due to rigid assumptions. While machine learning models provide flexibility, they require large datasets, are challenging to interpret, and can overfit to experimental noise. To overcome these limitations, we develop a physics-constrained machine learning model, which we call the neural species mediator (NSM), that combines a mechanistic model of metabolite dynamics with a machine learning component. The NSM outperforms mechanistic or machine learning components on in vitro experimental datasets and provides insights into direct biological interactions. In summary, carefully embedding a neural network into a mechanistic model of microbial community dynamics improves prediction performance and interpretability compared to its constituent mechanistic or machine learning components.