How to improve the prediction accuracy of compressional wave speed has always been one of the basic research subjects in geoacoustics study field. Due to the stability of granularity, whether in the laboratory or in the seabed environment, the regression relationship between compressional wave speed and granularity is an important sound speed inversion method. Machine Learning (ML) provides a new solution for more efficient sound speed prediction systems. In this study, two ML algorithm, Random forest (RF) and Support Vector Regression (SVR), combined with nine granularity parameters (mean grain size, median grain size, skewness, kurtosis, sorting coefficient, gravel, sand, silt, and clay content respectively.) to analysis the effect of granularity property on sound speed. As a result, the sound speed-granularity predictive models were established, and the sound speed accuracy obtained based on the predictive models are higher than that of the regression equations, and the RF model has a higher accuracy than the SVR model. Based on the RF predictive model, the feature selection was conducted and the results show that the most influential parameter of granularity is mean grain size. Furthermore, the RF model can also predict the sound speed with high precision in the absence of partial parameters, which can be a useful tool for ocean engineering and seismic inversion.INDEX TERMS Geoacoustic inversion, granularity, machine learning, random forest, sound speed.