Background: The quality of groundwater as the most important source for domestic, irrigation, and industrial purposes is affected by discharge of the chemicals from the anthropogenic resources. Therefore, the current study aimed at predicting heavy metals (As, Pb, Cu, and Zn) contamination in groundwater resources of Toyserkan Plain as an important agricultural area in Hamedan Province, West of Iran using artificial neural network -particle swarm optimization (ANN-PSO) approach. Methods: In the current study, samples were randomly selected from 20 groundwater wells with depth of 10 -90 m. The samples were filtered and kept cool in polyethylene bottles and then taken for the analysis of metal contents; they were acidified using nitric acid to reach pH < 2. Finally, element contents were determined using inductively coupled plasma -optical emission spectrometry (ICP-OES). Also, the performance of the PSO model was compared with that of ANN using Bayesian regulation (BR) training algorithm in terms of accuracy and model prediction efficiency.