This study aimed to predict the selected antipyrine compounds' inhibitory efficiencies and anticorrosion properties in a hydrochloric acid (HCl) environment. Molecular descriptors and input variables were obtained using density functional theory (DFT), and the variance inflation factor (VIF) was employed to reduce redundant variables, leading to the selection of seven quantum chemical descriptors as input variables. Using machine learning techniques such as K-nearest neighbor (KNN) and artificial neural network (ANN), a predictive model was built for 39 antipyrine compounds with known corrosion inhibition efficiencies for carbon and low alloy steel in hydrochloric acid solutions. The models' predictive capability was assessed using cross-validation, with the ANN model showing superior performance, achieving a coefficient of determination (R2) value of 0.715 compared to 0.548 for the KNN model. Performance metrics such as the mean square error (MSE), mean absolute error (MAE), and root-mean-square error (RMSE) further confirmed the superiority of the ANN model over the KNN model. The corrosion inhibition efficiencies (CIEs) of the selected antipyrine compounds ranged from 68.78 to 99.79%, with compound A1 demonstrating the highest CIE of 99.79% and compound A3 the lowest, as evaluated by the ANN model. Analysis of Fukui index parameters obtained from the Mulliken population analysis suggested that the nucleophilic and electrophilic sites play a crucial role in the interactions between the inhibitor and the metal atom through electron donor-acceptor interactions. Moreover, the energy of adsorption (Eads) in kcal·mol-1 decreased in the order of A1 (-187.8) > A2 (-132.0) > A2 (-84.4), with the high negative value of Eads indicating strong and spontaneous adsorption. Further analysis using radial distribution functions and molecular dynamics simulations revealed that inhibitor A1 exhibited predominantly chemisorption, inhibitor A2 showed a mixed type, and inhibitor A3 demonstrated predominantly physisorption, aligning well with the results of the predictive studies.