China’s sour gas reservoir is very rich in reserves, taking the largest whole offshore natural gas field in China-Puguang gas field as an example, its hydrogen sulfide content reaches 14.1%. The use of renewable energy, such as solar energy through photocatalytic technology, can decompose hydrogen sulfide into hydrogen and monomeric sulfur, thus realizing the conversion and resourceization of hydrogen sulfide gas, which has important research value. In this study, a concentration sample database of a hydrogen sulfide leakage scenario in a chemical park is constructed by Fluent software simulation, and then a leakage concentration prediction model is constructed based on the data samples to predict the hydrogen sulfide leakage diffusion concentration in real-time. Several machine learning algorithms, such as neural networks, support vector machines, and deep confidence networks, are implemented and compared to find the model algorithm with the best prediction performance. The prediction performance of the support vector machine model optimized by the sparrow search algorithm is found to be the best. The prediction model ensures the accuracy of the prediction results while greatly reducing the computational time cost, and the accuracy meets the requirements of practical engineering applications.