As important research for drilling engineering, the prediction of oil and gas shaft lining conditions is changing from the traditional method based on the mechanism model to the intelligent prediction method combining the mechanism model with the data model. Therefore, this paper establishes a stacking integrated model for predicting the uniaxial compression strength (UCS) of rock based on four basic parameters that can reflect the characteristics of rock mass. At the same time, the expectation-maximation (EM) algorithm is used to optimize the hidden Markov models (HMM), and a fuzzy random model of the ultimate bearing capacity of oil and gas shaft lining is established. The uncertain distribution of main parameters of rock mass is analyzed, and the corresponding fuzzy random distribution law is obtained. The experimental results show that the stacking integration algorithm is of great help to improve the prediction effect of rock mass compressive strength. The EM-HMM model has the advantages of small error, high efficiency, and fast convergence after two fuzzy random processes. Using this algorithm is helpful to analyze the stress state and parameter response mechanism of the shaft lining, dynamically generate optimized parameters, and provide technical support for reducing the incidence of complex drilling accidents, shortening the well construction period and lowering the drilling cost.