During the construction of deep foundation pits in subways, it is crucial to closely monitor the horizontal displacement of the pit enclosure to ensure stability and safety, and to reduce the risk of structural damage caused by pit deformations. With advancements in machine-learning (ML) techniques and correlation analysis in engineering, data-driven methods that combine ML with engineering monitoring data have become increasingly popular. These methods offer benefits such as high prediction accuracy, efficiency, and cost effectiveness. The main goal of this study was to develop a machine-learning method for predicting the enclosure deformation of deep foundation pits. This was achieved by analyzing the factors influencing deep foundation-pit enclosure deformation and incorporating historical cases and monitoring reports. The performance of each machine-learning prediction model was systematically analyzed and evaluated using K-Fold cross validation. The results revealed that the random forest model outperformed the other models. The result of the test data showed that the random forest model achieved an R2 of 0.9905, an MAE of 0.8572 mm, and an RMSE of 1.9119 mm. Feature importance analysis identified the depth of enclosure structure, water level, surface settlement, axial force, and exposure time as the most critical factors for accurate prediction. The depth of the enclosure structure had an especially significant impact on the prediction of enclosure deformation.