Due to the location of the Yungang Grottoes, freeze–thaw cycles contribute significantly to the degradation of the mechanical properties of the sandstone. The factors influencing the freeze–thaw cycle are classified into two categories: external environmental conditions and the inherent properties of the rock itself. Since the parameters of rock properties are inherent to each rock, the effect of rock properties on freeze–thaw degradation cannot be investigated by the control variates method. An adaptive multi-output gradient boosting decision trees (AMGBDT) algorithm is proposed to fit nonlinear relationships between mechanical properties and physical factors. The hyperparameters in the GBDT algorithm are set as variables, and the Sequential quadratic programming (SQP) algorithm is applied to solve the hyperparameter optimization, which means finding the maximum Score. The case study illustrates that the AMGBDT algorithm can precisely determine the effect of each independent factor on the output. The patterns of mechanical properties are similar when the number of freeze–thaw cycles and porosity are used as variables separately and when both are used simultaneously. The uniaxial compressive strength decay rate is positively correlated with the number of freeze–thaw cycles and porosity. The modulus of elasticity is negatively correlated with the number of freeze–thaw cycles and porosity. The results show that the number of freeze–thaw cycles is the main factor influencing the freeze–thaw cycling action, and the porosity is minor. In addition, the fitting accuracy of the AMGBDT algorithm is generally higher than neural networks (NN) and random forests (RF). Studying the influence of porosity and other rock properties on the freeze–thaw cycle will help to understand the failure mechanism of rock freeze–thaw cycles.