Soil contamination by heavy metals is very important for environmental scientists due to the greater mobilization of metals and the possibility of contamination of groundwater. One of the most effective tools for evaluating the risk is the combination of experimentation with computer modeling. Modeling techniques are important in assessing the potential risks associated with heavy metals in the environment. Determination of models that can precisely evaluate the heavy metals in soils is an important need of agricultural researches, which could eradicate the weaknesses in the measurement of heavy metals in soils. The purpose of the present study is to test and compare different models according to their suitability for describing the estimation of heavy metals. The models used in this study were multilayer perceptron neural network (MLP), M5 model tree (M5) and bagging approach (BM5P). The data from 164 sampling sites from Neyshabur and Mashhad plains were taken in this study. The inputs combination according to feature selection-based correlation was used to feed the models. To model soil heavy metals, soil attributes, namely sand, silt, clay (as texture fractions), organic carbon, pH and available phosphorus, were entered in some models. To evaluate the performance of various techniques used in this study, several statistical indexes, including the correlation coefficient, root-mean-square error, Nash-Sutcliffe coefficient, Willmott's index (d) and mean absolute error, were assessed. Comparison of different models for Fe, Cu, Mn and Zn indicated that MLP is the most suitable method for estimations of Fe and Mn, whereas BM5P and M5P are the most suitable models for determinations of Cu and Zn, respectively. This study concluded that machine learning models can be successfully applied to the rapid prediction of soil heavy metals using soil variables.