The uniaxial compressive strength (UCS) of rocks is one of the key parameters for evaluating the safety and stability of civil and mining structures. In this study, 386 rock samples containing four properties named the load strength (PLS), the porosity (Pn), the P-wave velocity (Vp), and the Schmidt hardness rebound number (SHR) are utilized to predict the UCS using several typical empirical equations (EA) and artificial intelligence (AI) methods, i.e., 16 single regression (SR) equations, 2 multiple regression (MR) equations, and the random forest (RF) models optimized by grey wolf optimization (GWO), moth flame optimization (MFO), lion swarm optimization (LSO), and sparrow search algorithm (SSA). The root mean square error (RMSE), determination coefficient (R2), Willmott’s index (WI), and variance accounted for (VAF) are used to evaluate the predictive performance of all developed models. The evaluation results show that the overall performance of AI models is superior to empirical approaches, especially the LSO-RF model. In addition, the most important input variable is the Pn for predicting the UCS. Therefore, AI techniques are considered as more efficient and accurate approaches to replace the empirical equations for predicting the UCS of these collected rock samples, which provides a reliable and effective idea to predict the rock UCS in the filed site.