This study employed machine learning (ML) to thoroughly investigate the impact of informal mining activities on the distribution and pollution status of heavy metals in soils near private gold mines in Hainan Province, southern China, a region known for its ecological sensitivity and economic importance. By systematically collecting surface soil samples and samples at depths of 0.5-1m from 175 drilling sites, a comprehensive quantitative analysis was conducted on major heavy metal elements, including lead (Pb), copper (Cu), cadmium (Cd), nickel (Ni), mercury (Hg), chromium (Cr), arsenic (As), and zinc (Zn). Combined with evaluation methods such as the Pollution Load Index (PLI), Normalized Pollution Index (NIPI), and Ecological Risk Index (ERI), the study revealed a high level of soil pollution at informal mining sites. The findings indicated that the average concentrations of Pb, Cd, Hg, As, and Zn in surface soils significantly exceeded the background values for soils in China, with a pronounced positive correlation observed between these heavy metal elements in both surface and deep soil profiles (r > 0.5). Furthermore, leveraging the heavy metal content in surface soils and the constructed environmental indicators, the predictive accuracy for metal content in deep soils was found to range from R2 = 0.27 to 0.68, suggesting that informal mining activities have led to substantial variations in metal content across different soil profiles. Through the application of a random forest model for predictive analysis of the PLI, NIPI, and ERI, high prediction accuracy was achieved (R2 = 0.78, 0.86, and 0.60, respectively). The study demonstrates that informal mining activities not only elevate the risk of soil pollution but also alter the distribution patterns of heavy metals. Also, this study provides a crucial foundation for the scientific assessment of soil quality and potential environmental hazards, while also affirming the efficacy of ML techniques in forecasting soil quality parameters.