This paper presents a regional 3D geological modeling method based on the stacking ensemble technique to overcome the challenges of sparse borehole data in large-scale linear underground projects. The proposed method transforms the 3D geological modeling problem into a stratigraphic property classification problem within a subsurface space grid cell framework. Borehole data is pre-processed and trained using stacking method with five different machine learning algorithms. The resulting modelled regional cells are then classified, forming a regional 3D grid geological model. A case study for an area of 324 km2 along Xuzhou metro lines is presented to demonstrate the effectiveness of the proposed model. The study shows an overall prediction accuracy of 85.4%. However, the accuracy for key stratigraphy layers influencing the construction risk, such as karst carve strata, is only 4.3% due to the limited borehole data. To address this issue, an oversampling technique based on the synthetic minority oversampling technique (SMOTE) algorithm is proposed. This technique effectively increases the number of sparse stratigraphic samples and significantly improves the prediction accuracy for karst caves to 65.4%. Additionally, this study analyzes the impact of sampling distance on model accuracy. It is found that a lower sampling interval results in higher prediction accuracy, but also increases computational resources and time costs. Therefore, in this study, an optimal sampling distance of 1 m is chosen to balance prediction accuracy and computation cost. Furthermore, the number of geological strata is found to have a negative effect on prediction accuracy. To mitigate this, it is recommended to merge less significant stratigraphy layers, reducing computation time. For key strata layers, such as karst caves, which have a significant impact on construction risk, further on-site sampling or oversampling using the SMOTE technique is recommended.