With the advent of the digital age in recent years, the application of artificial intelligence in urban Internet of Things (IoT) systems has become increasingly important. The concept of smart cities has gradually formed, and smart firefighting under the smart city system has also become important. The method of machine learning is now applied in various fields, but seldom to the data prediction of smart firefighting. Various types of applications including data applications of machine learning algorithms in smart firefighting have yet to be explored. In this article, we propose using machine learning algorithms to predict building fire-resistance data, aiming to provide more theoretical and technical support for IoT smart cities. This article adopts the fire-resistance data of building beam components in a real fire environment, using three integrated machine learning algorithms, Extreme random Tree (ET), AdaBoost, and Gradient Boosting Machine (GBM), and the grey wolf optimization algorithm to optimize. We improve the grey wolf algorithm and combine the grey wolf algorithm with the machine learning model. The algorithm constitutes three machine learning hybrid models: GWO-ET, GWO-AdaBoost, and GWO-GBM. Compared with traditional grid tuning, particle swarm optimization (PSO), and genetic algorithm (GA) optimization, the robustness and accuracy of the three optimization algorithms and the machine learning hybrid algorithm on the data set are compared and analyzed. Performance is measured through various performance comparisons and experimental result comparisons. For various building beam component data sets under real fires, the optimization and comparison show that the mean square error (MSE) of the proposed algorithm is extremely small. The results indicate that the GWO machine learning hybrid model is superior to other models and has a smaller prediction error.