Traffic Congestion Level Prediction: AComparative Study Based on Random Forest and XGBoost Models

Authors

  • Jincheng Yaochen

DOI:

https://doi.org/10.61173/adaqya36

Keywords:

Random Forest, XGBoost, Traffic Conges-tion, Hyperparameter Tuning, Machine Learning

Abstract

With the acceleration of global urbanization, the problem of traffic congestion has become increasingly severe, exerting a significant impact on economic development, environmental governance, and the management of residents. To alleviate the problem of traffic congestion, this study focuses on the performance of the random forest and XGBoost models in predicting traffic congestion levels. In the data preprocessing stage, this study cleaned and encoded key features such as traffic speed and energy consumption, and constructed interaction variables through feature engineering to enhance the model’s ability to capture traffic patterns. During the training phase of the model, this study combined multiple hyperparameter optimization methods, including GridSearchCV, RandomizedSearchCV, Optuna, and BayesSearchCV, for tuning and conducted a comparative analysis. The experimental results show that the optimized models have significant improvements compared to the Baseline. The combined accuracy of random forest + BayesSearchCV has increased from 79.92% to 97.52%, F1-macro has reached 0.9664, and F1-weighted has reached 0.9753. The combined accuracy rate of XGBoost + Optuna increased from 78.56% to 97.6%. The F1-macro score reached 0.9719, and the F1-weighted score reached 0.9761. This study further demonstrates the application potential of machine learning methods in the field of traffic prediction and clarifies a feasible direction for the construction of smart city transportation systems.

References

[1] United Nations Department of Economic and Social Affairs Population Division. World Urbanization Prospects 2018: Highlights. New York: United Nations, 2019.

[2] INRIX Research. 2023 Global Traffic Scorecard. INRIX, 2023. [Online]. Available: https://inrix.com/scorecard

[3] De Vlieger I, De Keukeleere D, Kretzschmar J. Environmental effects of driving behaviour and congestion. Atmospheric Environment, vol. 35, no. 27, pp. 4573–4586, 2000.

[4] Zafar N and Ul Haq I. Traffic congestion prediction based on Estimated Time of Arrival. PLOS ONE, vol. 15, no. 12, e0238200, 2020.

[5] Parsa A B, Movahedi A, Taghipour H, Derrible S, Mohammadian A K. Toward safer highways: application of XGBoost and SHAP for real-time accident detection. Accident Analysis & Prevention, vol. 136, Article 105405, 2020.

[6] Mahmoud N, Abdel-Aty M, Cai Q, Yuan J. Predicting cycle-level traffic movements at signalized intersections using XGBoost, LSTM, and GRU models. Transportation Research Part C: Emerging Technologies, vol. 128, Article 103162, 2021.

[7] Lu X, Chen C, Gao R, Xing Z. Prediction of high-speed traffic flow around city based on BO-XGBoost. Symmetry, vol. 15, no. 7, Article 1453, 2023.

[8] Boukerche A and Coutinho R W L. Machine learning-based traffic prediction models for intelligent transportation systems. Computer Networks, vol. 181, Article 107530, 2020.

[9] Pang J, Wang J, Yu J, Zhang H. Gasoline prices, traffic congestion, and carbon emissions. Transportation Research Part D: Transport and Environment, vol. 116, Article 103634, 2023.

[10] Vlahogianni E I, Karlaftis M G, Golias J C. Short-term traffic forecasting: Where we are and where we’re going. Transportation Research Part C: Emerging Technologies, vol. 43, pp. 3–19, 2014.

[11] Ahmed U, Tu R, Xu J, Amirjamshidi G, Hatzopoulou M, Roorda M J. GPS-based traffic conditions classification using floating car data. Transportation Research Record, vol. 2677, no. 2, pp. 1445–1454, 2023.

Downloads

Published

2025-12-19