This research presents a novel approach that utilizes the gradient boosting (GB) model to overcome the limitations in predicting settling of foundation pits ( \(\:SoFP\) ). In past studies, the sole criteria often used to forecast settlement was excavation timeframes. This is mostly because it is challenging to establish a relationship between excavation time and real-time excavation depth. In order to resolve this problem, it is necessary to accurately document the periods at which support is provided. By analyzing the duration of excavation and the depth between two neighboring supports, the rate of excavation depth may be determined. The internal friction angle, cohesion, bulk density, Poisson’s ratio, void ratio, water level fluctuations, permeability coefficient, number of supports, and excavation depth are some of the variables that can affect settlement that are taken into account in the present investigation. A computerized database with 188 test outcomes from earlier studies has been utilized to determine these parameters. Three distinct methodologies are used to estimate the \(\:SoFP\) . This study examines the performance of two hybrid optimization algorithms, namely the \(\:AHO\) ( \(\:\text{A}\text{r}\text{t}\text{i}\text{f}\text{i}\text{c}\text{i}\text{a}\text{l}\:\text{H}\text{u}\text{m}\text{m}\text{i}\text{n}\text{g}\text{b}\text{i}\text{r}\text{d}\:\text{O}\text{p}\text{t}\text{i}\text{m}\text{i}\text{z}\text{a}\text{t}\text{i}\text{o}\text{n}\) ) and the \(\:EEFO\) ( \(\:\text{E}\text{l}\text{e}\text{c}\text{t}\text{r}\text{i}\text{c}\:\text{E}\text{e}\text{l}\:\text{F}\text{o}\text{r}\text{a}\text{g}\text{i}\text{n}\text{g}\:\text{O}\text{p}\text{t}\text{i}\text{m}\text{i}\text{z}\text{a}\text{t}\text{i}\text{o}\text{n}\) ), when applied to the GB machine learning (ML) approach. Two gradient boosting models, namely gradient boosting (GB) optimized by EEFO (GBE) and gradient boosting optimized by AHA (GBA), are developed to predict foundation pit settlement. According to the results, both GBE and GBA demonstrate strong capability in predicting the SoFP. For the GBA model, the \(\:{\varvec{R}}^{2}\) values obtained in the training and testing phases were 0.9763 and 0.9748, respectively, indicating high predictive reliability and stable generalization performance. Similarly, the GBE model achieved \(\:{\varvec{R}}^{2}\) values of 0.9873 for the training dataset and 0.9878 for the testing dataset. These results confirm that the GBE model provides slightly improved prediction accuracy compared with GBA, while the close agreement between training and testing \(\:{\varvec{R}}^{2}\) values in both models suggests limited overfitting and good robustness.