Expansive soils pose significant challenges to structural integrity, primarily due to volumetric changes that can lead to detrimental consequences and substantial economic losses. This study delves into the intricate dynamics of expansive soils through loaded swelling pressure experiments conducted under diverse conditions, encompassing variations in the sand content, initial dry unit weight, and initial degree of saturation. The findings underscore the pronounced influence of these factors on soil swelling. To address these challenges, a novel method leveraging machine learning prediction models is introduced, offering an efficient and cost-effective framework to mitigate potential hazards associated with expansive soils. Employing advanced algorithms such as decision tree regression (DTR), random forest regression (RFR), gradient boosting regression (GBR), extreme gradient boosting (XGBoost), support vector regression (SVR), and artificial neural networks (ANN) in the Python software 3.11 environment, this study aims to predict the optimal applied stress and dry unit weight required for soil swelling mitigation. Results reveal that XGBoost and ANN stand out for their precision and superior metrics. While both performed well, ANN demonstrated exceptional consistency across training and testing phases, making it the preferred choice. In the tested dataset, ANN achieved the highest R-squared values (0.9917 and 0.9954), lowest RMSE (7.92 and 0.086), and lowest MAE (5.872 and 0.0488) for predicting optimal applied stress and dry unit weight, respectively.