Undrained shear strength serves as one of the crucial indicators for analyzing the strength and assessing the stability of clay. To enhance the predictive capability of undrained shear strength, we introduced a hybrid stacking model, the KSMRX, which leverages the Bayesian optimization algorithm. Comparative analyses against base models revealed that the KSMRX model significantly enhanced prediction accuracy, elevating it from 51.3% to 72.5%. This substantial improvement underscored the efficacy of our approach in predicting drained shear strength. Moreover, when compared with the prediction accuracies of 15 other hybrid models, the KSMRX hybrid stacking model consistently demonstrated superior performance. Therefore, this study not only presents a novel and more convenient computational approach, facilitating the acquisition of highly accurate geotechnical parameters, but also serves as a reference for the implementation of geotechnical engineering projects.