In order to quickly and accurately predict borehole spontaneous combustion danger and avoid borehole spontaneous combustion fires, a borehole spontaneous combustion prediction model combining the Hunger Games search optimization algorithm (HGS) and Random Forest (RF) algorithm was introduced. The number of trees and the minimum number of leaf nodes in RF were optimized by HGS. Based on the data obtained from the temperature rise experiment of spontaneous combustion characteristics in a Shandong mine laboratory, O2, CO, C2H4, CO/∆O2 and C2H4/C2H6 were selected as the input indexes for the prediction of borehole spontaneous combustion, and the spontaneous combustion temperature was selected as the output indexes to train the built model. The prediction performance and accuracy of the model were evaluated using four indexes: the mean absolute error (MAE), mean absolute percentage error (MAPE), root mean square error (RMSE) and coefficient of determination (R2). At the same time, the prediction results of the HGS-RF model were compared with those of the RF model, Sparrow search algorithm (SSA) optimization RF model, particle swarm optimization RF model (PSO) optimization RF model and quantum particle swarm optimization RF model (QPSO) optimization. The results showed that the MAE of the RF, SSA-RF, PSO-RF, QPSO-RF and HGS-RF model samples were 17.541, 15.7752, 12.5903, 6.8594 and 6.6921, respectively. MAPE was 13.81%, 10.9766%, 9.6802%, 4.5731% and 5.1536%, respectively. RMSE values were 21.5646, 15.2017, 17.0091, 11.9879 and 12.1691, respectively. The R2 values were 0.9043, 0.9315, 0.9266, 0.9668, and 0.9717, respectively. At the same time, the reliability of the HGS-RF model was supplemented by taking the test data of the Zhengjia1204 coal mining face as an example. Finally, the model was applied to the prediction of borehole spontaneous combustion in the Jinniu Coal Mine, Shanxi Province. The prediction results show that the HGS-RF model can predict the spontaneous combustion temperature of different boreholes quickly and accurately. The results show that the HGS-RF model is more universal and stable than other models, indicating that the HGS-RF model is more suitable for the prediction of borehole spontaneous combustion.