As a new type of environmentally friendly building material, cemented sand and gravel (CSG) has advantages distinct from those of concrete. Compressive strength is an important mechanical property of CSG. However, his method of testing is mainly by doing experiments. For this reason, a deep learning algorithm, long short-term memory (LSTM) model, was proposed to predict the compressive strength of CSG by using four input variables, namely cement content, sand rate, water-binder ratio, and fly ash content, with a total of 114 sample data. Three metrics – coefficient (R
2), root mean square error (RMSE), and mean absolute error (MAE) – were used to evaluate the model’s performance, and the predicted results were compared with the traditional machine learning algorithm, namely the random forest (RF) model. Finally, SHapley Additive exPlanations can be combined to explain the contribution degree of each input feature in the machine learning inquiry model to the prediction results. The results show that the prediction accuracy and reliability of LSTM are higher. The LSTM model has R
2 = 0.9940, RMSE = 0.1248, and MAE = 0.0960, while the RF model has R
2 = 0.9147, RMSE = 0.4809, and MAE = 0.4397. The LSTM model can accurately predict CSG compressive strength. Cement and sand rate contribute more to the predicted results than other input characteristics.