This study explores the reduction of carbamates (CAs) and pyrethroids (PYs) − commonly used pesticides − in lettuce using various immersion solutions and ultrasonic processing. It also examines the role of machine learning and molecular docking in understanding the mechanisms of pesticide reduction. The results revealed that the highest reduction of both CAs and PYs exceeded 80 % on lettuce leaves. In most samples, the reduction increased with the power of ultrasonic processing and processing time. The results of machine learning models (XGBoost and SHAP) showed that during the immersion cleaning of CAs and PYs, as well as during both immersion cleaning and ultrasonic processing of CAs + PYs, the reduction was most influenced by the initial pesticide levels and immersion time. Gas Chromatography-Mass Spectrometry (GC–MS) analysis of lettuce’s wax layer identified 24 compounds, including fatty alcohols, fatty acids, fatty acid esters, and triterpenoids. Despite the absence of active sites, the lipophilic nature of long-chain aliphatic compounds aids in pesticide binding, while triterpenoids form strong hydrogen bonds with pesticides, indicating a robust adsorption on the lettuce surface. This study aims to offer insights into the efficient removal of chemical pesticide residues from fruits and vegetables, addressing critical concerns for food safety and human health.