O. Bouhacina, Abdelwahhab Khatir, Soumia Anfal Matoug, Tawfik Tamine
Accurate prediction of shallow soil temperature is essential for agriculture, geotechnical design, and ground-coupled energy systems. This study proposes a novel hybrid machine-learning framework in which four tree-based regressors (Decision Tree, Random Forest, XGBoost, and Bagging) are optimized using a newly developed Tri-phase Opposition Adaptive Random Search (TOARS) algorithm. Soil temperature measurements collected in 2024 at depths of 1.0 m and 2.0 m were combined with meteorological variables to train and evaluate the models. TOARS optimization reduced prediction errors by up to 32% for MAE and 28% for RMSE compared with default hyperparameters. At 1.0 m, the optimized Decision Tree achieved MAE = 0.29 °C, RMSE = 0.41 °C, and R2 = 0.9993, while at 2.0 m, XGBoost reached MAE = 0.35 °C, RMSE = 0.47 °C, and R2 = 0.9991. The TOARS-based hybrid ensemble provided the most stable performance across both depths. The results demonstrate that integrating TOARS with tree-based models substantially enhances predictive accuracy and offers a robust solution for soil-temperature forecasting in shallow layers.