The combined impact of freeze-thaw cycles and dynamic loads significantly influences the long-term durability of rock engineering in high-cold regions. Consequently, investigating the dynamic compressive strength (DCS) of rocks subjected to freeze-thaw cycles has emerged as a crucial area of scientific research to advance rock engineering construction in cold regions. Presently, the determination of the DCS of rocks under freeze-thaw cycles primarily relies on indoor experiments. However, this approach has faced criticism due to its drawbacks, including prolonged duration, high costs, and reliance on rock samples. To address these limitations, the exploration of using artificial intelligence technology to develop more accurate and convenient DCS prediction models for rocks under freeze-thaw cycles is a promising attempt. In this context, this paper introduces a DCS prediction model for rocks under freeze-thaw cycles, which integrates the Sparrow Search Algorithm (SSA) with Random Forest (RF). Firstly, employing a dataset of 216 samples, Principal Component Analysis (PCA) is utilized to reduce the dimensionality of ten influential factors. Subsequently, five optimization algorithms are employed to optimize the hyperparameters of both the BP and RF algorithms. Finally, a comprehensive evaluation and comparative analysis are carried out to assess the predictive performance of the optimized model, using evaluation metrics such as Root Mean Square Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and Coefficient of Determination (R2).The research findings demonstrate that the SSA-RF model exhibits the best predictive performance, surpassing the other nine models in terms of generalization. The prediction model proposed in this study has good applicability for predicting DCS of freeze-thaw rock in cold regions, and also provides new ideas for the combination of machine learning and rock mass engineering in cold regions.