With the development of intelligent transportation, urban traffic flow prediction faces more complex traffic situations and higher accuracy requirements. In this paper, we collected multi-day traffic data from local cities and used a k-means clustering algorithm to analyze the data by clustering. A BP neural network prediction algorithm combined with k-means clustering analysis is designed to construct an “hour-day-week” urban traffic flow prediction model. The model is trained and applied to real-time urban traffic flow prediction to further analyze the performance effect of this model. The training time of this model is the shortest, which is about 67 minutes, and the MAE value is 3.02. The training speed is ahead of the longest training time in model 2, which is about 163 minutes, and the error is reduced by 8.04 compared with that of the highest prediction error in model 1. With different levels of noise added, the R², ACC, and RMSE values of the model in this paper are maintained at about 0.45, 0.63, and 0.8, respectively, indicating that different levels of noise have a significant effect on the performance of this model. This indicates that different degrees of noise have little effect on the performance of the model in this paper. In addition, the prediction effect is better after clustering analysis. The MAPE value of this paper’s model is the lowest, only 2.64%, which is 3.65%-7.52% lower than the other three control models. The experimental results above fully demonstrate the superior performance of this paper’s model, which suggests that this paper’s model is more effective in predicting urban traffic flow.