Rock Uniaxial Compressive Strength (UCS) is an important parameter for almost all aspects of geomechanics and geotechnical designs and analysis. Traditionally, it was determined by laboratory experiments or calculated from the sonic log (e.g., Sonic Transit Time (STT)) using empirical or curve fitting correlations. However, due to the complex mineral composition and heterogeneous porosity in sedimentary rocks, the data distribution pattern of the UCS-STT relation could not be precisely described by the empirical equations with simple fitting curves. To overcome this challenge, machine learning methods have been increasingly adopted in the literature to predict the UCS from the geophysical logging data. The accuracy of the machine learning predictions relies on the quality of training data, and it may vary with rock type. In this paper, the “prediction based on group classification” concept was adopted, and a Group-based Machine Learning (GML) method was introduced to predict the UCS, which has demonstrated better performance than the conventional machine learning methods. The data analysis procedure to achieve high-quality training input data was demonstrated, and the techniques of data cleaning before the training was recommended. The implementation of the GML method requires using unsupervised learning models to classify the group of rock types firstly, and then the UCS values are predicted by the machine learning models trained for different groups; for each group, multiple machine learning models are evaluated. Finally, the previous two steps were integrated for the automatic group-based UCS prediction from the geophysical logs.