Groundwater, a pivotal water resource in numerous regions worldwide, confronts formidable challenges posed by severe nitrate pollution. Traditional research methodologies aimed at addressing groundwater nitrate contamination frequently struggle to accurately depict the intricate conditions of the groundwater environment, particularly when dealing with high variability and nonlinear data. However, the advent of machine learning (ML) has heralded an innovative approach to simulating groundwater dynamics. In this study, six ML algorithms were deployed to model the concentrations of shallow groundwater nitrates in the Shaying River Basin. The efficacy of each model was assessed through comprehensive metrics including the coefficient of determination (R