Research on Pedestrian Avoidance Behavior for School Section Based on Improved BP Neural Network and XGboost Algorithm
Abstract
:1. Introduction
2. Data Collection
3. Methods
3.1. BP Neural Network
Algorithm 1: BP Neural Network Training and Prediction | |
Input: - Dataset in CSV format (features `X’ and target labels `y’) | |
Output: - BP predictions for the test set (`BP_prediction’) - Training loss history (`BP_lossList’) - Message: “BP training completed.” | |
1 | Read data from CSV file: `df = pd.read_csv(‘data_path’) `Split the features (`X`) and target labels (`y`) X ← df.iloc[:, :−1] y ← df.iloc[:, −1] |
2 | x_train, x_test, y_train, y_test ← train_test_split(X, y, test_size = 0.4, random_state = 42) |
3 | BP_net ← BP_network.ini_BP_net(n_feature, n_hidden, n_output) |
4 | x_train ← torch.tensor(x_train, dtype = torch.float32) y_train ← torch.tensor(y_train, dtype = torch.float32).reshape(−1, 1) x_test ← torch.tensor(x_test, dtype = torch.float32) y_test_ ← torch.tensor(y_test, dtype = torch.float32).reshape(−1, 1) |
5 | BP_lossList ← BP_network.train(BP_net, num_epoch, learn_rate, x_train, y_train) |
6 | BP_prediction ← BP_net(x_test).detach().numpy() |
3.2. GA-BP Neural Network
Algorithm 2: GA-BP Neural Network Training | ||
Input: - Dataset in CSV format (features `X` and target labels `y`) | ||
Output: - best_code: The best chromosome encoding obtained by the genetic algorithm - best_fitness_ls: List of the best fitness values of each generation - ave_fitness_ls: List of the average fitness values of each generation | ||
1 | Initialize chrom_len ← n_feature * n_hidden + n_hidden + n_hidden * n_output + n_output | |
2 | Set parameters: size ← 16, p_cross ← 0.4, p_mutate ← 0.5, maxgen ← 150 | |
3 | Initialize population chrom_sum with the size of chromosomes | |
- Calculate fitness using chrom_fitness.calculate_fitness | ||
- Record the best fitness and average fitness for the generation | ||
While account < maxgen: - Select chromosomes based on fitness - Apply crossover and mutation operators - Recalculate fitness for the new population - Record the best fitness and average fitness | ||
If iteration reaches maxgen: - Obtain the chromosome with the best fitness - Extract parameters (weights and biases) | ||
- Convert parameters to tensor format | ||
- Create BP network with GA parameters | ||
- Train the BP network and obtain the training loss | ||
4 | - Make predictions on the test set | |
End Algorithm |
3.3. XGBoost Ensemble Learning Method
Algorithm 3: XGBoost Model Training | |
Input: - CSV file containing feature data and binary labels | |
Output: - Trained XGBoost model, prediction results | |
1 | df ← read_csv(‘data.csv’) |
2 | feature_names ← df.columns[:−1] X ← df.iloc[:, :−1] y ← df.iloc[:, −1] |
3 | X_train, X_test, y_train, y_test ← train_test_split(X, y, test_size ← 0.4, random_state ← 42) |
4 | dtrain ← DMatrix(X_train, label ← y_train, feature_names ← feature_names) dtest ← DMatrix(X_test, label ← y_test, feature_names ← feature_names) |
5 | params ← { ‘max_depth’ ← 7, ‘eta’ ← 0.1, ‘gamma’ ← 0.3, ‘lambda’ ← 0.2, ‘alpha’ ← 0.2, ‘objective’ ← ’binary:logistic’, ‘eval_metric’ ← ’logloss’ } |
6 | num_trees ← 80 bst ← xgb.train(params, dtrain, num_boost_round ← num_trees, evals ← [(dtrain, ‘train’)]) |
7 | y_pred_train ← bst.predict(dtrain) y_pred_train_binary ← (y_pred_train > 0.5) y_pred_test ← bst.predict(dtest) y_pred_test_binary ← (y_pred_test > 0.5) |
8 | xgb.plot_importance(bst, importance_type ← ‘weight’, xlabel ← ‘F-Score’, title ← ‘Feature Importance’, max_num_features ← 12) show_plot() |
9 | End Algorithm |
4. Comparison Analysis of Prediction Models
4.1. Prediction Accuracy Comparison
4.2. Training Convergence and Feature Importance Interpretation Analysis
5. Conclusions and Discussion
5.1. Conclusions
5.2. Discussion
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Appleyard, B. Livable streets for schoolchildren: A human-centred understanding of the cognitive benefits of Safe Routes to School. J. Urban Des. 2022, 27, 692–716. [Google Scholar] [CrossRef]
- Al-Najjar, E.; Sukor, N.S.; Shbeeb, L.I. Addressing safety issues along the way to school: Qualitative findings from Jerash camp, Jordan. J. Transp. Health 2022, 26, 101370. [Google Scholar] [CrossRef]
- Appolloni, L.; Giretti, A.; Corazza, M.V.; D’alessandro, D. Walkable Urban Environments: An Ergonomic Approach of Evaluation. Sustainability 2020, 12, 8347. [Google Scholar] [CrossRef]
- Gregoriades, A.; Dimitriou, L.; Pampaka, M.; Michail, H.; Georgiades, M. Machine Learning Analysis of Pedestrians’ Hazard Anticipation from Eye Tracking Data. In CEUR Workshop Proceeding; RWTH Aachen University: Aachen, Germany, 2022; Available online: https://research.manchester.ac.uk/en/publications/machine-learning-analysis-of-pedestrians-hazard-anticipation-from (accessed on 26 August 2024).
- Alahi, A.; Goel, K.; Ramanathan, V.; Robicquet, A.; Fei-Fei, L.; Savarese, S. Social LSTM: Human Trajectory Prediction in Crowded Spaces. In Proceedings of the 29th IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 26 June–1 July 2016; pp. 961–971. [Google Scholar] [CrossRef]
- Chen, K.; Song, X.; Han, D.; Sun, J.; Cui, Y.; Ren, X. Pedestrian behavior prediction model with a convolutional LSTM encoder–decoder. Phys. A Stat. Mech. Appl. 2020, 560, 125132. [Google Scholar] [CrossRef]
- Wang, B. The Research on Traffic Safety Condition Prediction Method Based on Attention CNN and Deep Forest. Master’s Thesis, Jiangsu University, Zhenjiang, China, 2019. [Google Scholar]
- Liu, K.; Lin, T.; Zhong, T.; Ge, X.; Jiang, F.; Zhang, X. New methods based on a genetic algorithm back propagation (GABP) neural network and general regression neural network (GRNN) for predicting the occurrence of trihalomethanes in tap water. Sci. Total. Environ. 2023, 870, 161976. [Google Scholar] [CrossRef]
- Li, Y.; Fan, W.; Song, L.; Liu, S. Combining emerging hotspots analysis with XGBoost for modeling pedestrian injuries in pedestrian-vehicle crashes: A case study of North Carolina. J. Transp. Saf. Secur. 2023, 15, 1203–1225. [Google Scholar] [CrossRef]
- Ding, S.; Su, C.; Yu, J. An optimizing BP neural network algorithm based on genetic algorithm. Artif. Intell. Rev. 2011, 36, 153–162. [Google Scholar] [CrossRef]
- Du, Y.; Liu, Y. Optimization of BP neural network for predicting air quality using hybrid genetic ant colony algorithm. Comput. Syst. Appl. 2023, 32, 1–8. [Google Scholar] [CrossRef]
- Zhang, L.; Zhang, J.; Ren, P.; Ding, L.; Hao, W.; An, C.; Xu, A. Analysis of energy consumption prediction for office buildings based on GA-BP and BP algorithm. Case Stud. Therm. Eng. 2023, 50, 103445. [Google Scholar] [CrossRef]
- Qu, Y.; Lin, Z.; Li, H.; Zhang, X. Feature Recognition of Urban Road Traffic Accidents Based on GA-XGBoost in the Context of Big Data. IEEE J. Mag. 2019, 7, 170106–170115. [Google Scholar] [CrossRef]
- Chen, R.; Song, J.; Xu, M.; Wang, X.; Yin, Z.; Liu, T.; Luo, N. Prediction of the corrosion depth of oil well cement corroded by carbon dioxide using GA-BP neural network. Constr. Build. Mater. 2023, 394, 132127. [Google Scholar] [CrossRef]
- Wang, L. A hybrid genetic algorithm–neural network strategy for simulation optimization. Appl. Math. Comput. 2005, 170, 1329–1343. [Google Scholar] [CrossRef]
- Li, Y.; Zhou, L.; Gao, P.; Yang, B.; Han, Y.; Lian, C. Short-Term Power Generation Forecasting of a Photovoltaic Plant Based on PSO-BP and GA-BP Neural Networks. Front. Energy Res. 2022, 9, 824691. [Google Scholar] [CrossRef]
- Wang, S.; Zhang, N.; Wu, L.; Wang, Y. Wind speed forecasting based on the hybrid ensemble empirical mode decomposition and GA-BP neural network method. Renew. Energy 2016, 94, 629–636. [Google Scholar] [CrossRef]
- Xu, J.; Zhao, Y. Stability Analysis of Geotechnical Landslide Based on GA-BP Neural Network Model. Comput. Math. Methods Med. 2022, 2022, 3958985. [Google Scholar] [CrossRef] [PubMed]
- Yang, R. Enterprise Network Marketing Prediction Using the Optimized GA-BP Neural Network. Complexity 2020, 2020, 6682296. [Google Scholar] [CrossRef]
- Yu, F.; Xu, X. A short-term load forecasting model of natural gas based on optimized genetic algorithm and improved BP neural network. Appl. Energy 2014, 134, 102–113. [Google Scholar] [CrossRef]
- Ben Jabeur, S.; Stef, N.; Carmona, P. Bankruptcy Prediction using the XGBoost Algorithm and Variable Importance Feature Engineering. Comput. Econ. 2023, 61, 715–741. [Google Scholar] [CrossRef]
- Demir, S.; Sahin, E.K. An investigation of feature selection methods for soil liquefaction prediction based on tree-based ensemble algorithms using AdaBoost, gradient boosting, and XGBoost. Neural Comput. Appl. 2023, 35, 3173–3190. [Google Scholar] [CrossRef]
- Guo, J.; Yang, L.; Bie, R.; Yu, J.; Gao, Y.; Shen, Y.; Kos, A. An XGBoost-based physical fitness evaluation model using advanced feature selection and Bayesian hyper-parameter optimization for wearable running monitoring. Comput. Networks 2019, 151, 166–180. [Google Scholar] [CrossRef]
- Li, H.; Cao, Y.; Li, S.; Zhao, J.; Sun, Y. XGBoost model and its application to personal credit evaluation. IEEE Intell. Syst. 2020, 35, 52–61. [Google Scholar] [CrossRef]
- Shi, X.; Wong, Y.D.; Li, M.Z.-F.; Palanisamy, C.; Chai, C. A feature learning approach based on XGBoost for driving assessment and risk prediction. Accid. Anal. Prev. 2019, 129, 170–179. [Google Scholar] [CrossRef] [PubMed]
- Takefuji, Y. Beyond XGBoost and SHAP: Unveiling true feature importance. J. Hazard. Mater. 2025, 488, 137382. [Google Scholar] [CrossRef]
- Tian, J.; Jiang, Y.; Zhang, J.; Wang, Z.; Rodríguez-Andina, J.J.; Luo, H. High-Performance Fault Classification Based on Feature Importance Ranking-XgBoost Approach with Feature Selection of Redundant Sensor Data. Curr. Chin. Sci. 2022, 2, 243–251. [Google Scholar] [CrossRef]
- Wang, Y.; Ni, X.S. A XGBoost risk model via feature selection and Bayesian hyper-parameter optimization. arXiv 2019. [Google Scholar] [CrossRef]
- Zhang, B.; Zhang, Y.; Jiang, X. Feature selection for global tropospheric ozone prediction based on the BO-XGBoost-RFE algorithm. Sci. Rep. 2022, 12, 9244. [Google Scholar] [CrossRef]
- Zheng, H.; Yuan, J.; Chen, L. Short-term load forecasting using EMD-LSTM neural networks with a Xgboost algorithm for feature importance evaluation. Energies 2017, 10, 1168. [Google Scholar] [CrossRef]
- Ma, J.; Ding, Y.; Cheng, J.C.P.; Tan, Y.; Gan, V.J.L.; Zhang, J. Analyzing the Leading Causes of Traffic Fatalities Using XGBoost and Grid-Based Analysis: A City Management Perspective. IEEE Access 2019, 7, 148059–148072. [Google Scholar] [CrossRef]
- Geng, X.; Wu, S.; Zhang, Y.; Sun, J.; Cheng, H.; Zhang, Z.; Pu, S. Developing hybrid XGBoost model integrated with entropy weight and Bayesian optimization for predicting tunnel squeezing intensity. Nat. Hazards 2023, 119, 751–771. [Google Scholar] [CrossRef]
- Liu, J.; He, X.; Huang, H.; Yang, J.; Dai, J.; Shi, X.; Xue, F.; Rabczuk, T. Predicting gas flow rate in fractured shale reservoirs using discrete fracture model and GA-BP neural network method. Eng. Anal. Bound. Elem. 2024, 159, 315–330. [Google Scholar] [CrossRef]
- Li, J.; Yao, L.; Xu, X.; Cheng, B.; Ren, J. Deep reinforcement learning for pedestrian collision avoidance and human-machine cooperative driving. Inf. Sci. 2020, 532, 110–124. [Google Scholar] [CrossRef]
- Asaithambi, G.; Kuttan, M.O.; Chandra, S. Pedestrian Road Crossing Behavior Under Mixed Traffic Conditions: A Comparative Study of an Intersection Before and After Implementing Control Measures. Transp. Dev. Econ. 2016, 2, 14. [Google Scholar] [CrossRef]
- Botache, D.; Dandan, L.; Bieshaar, M.; Sick, B. Early Pedestrian Movement Detection Using Smart Devices Based on Human Activity Recognition, Gesellschaft für Informatik e.V. 2019. Available online: https://dl.gi.de/handle/20.500.12116/25059 (accessed on 14 June 2024).
- Best, G.; Fitch, R. Bayesian intention inference for trajectory prediction with an unknown goal destination. In Proceedings of the 2015 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), Hamburg, Germany, 28 September–2 October 2015; pp. 5817–5823. [Google Scholar] [CrossRef]
- Rasouli, A.; Kotseruba, I.; Tsotsos, J.K. Understanding Pedestrian Behavior in Complex Traffic Scenes. IEEE Trans. Intell. Veh. 2017, 3, 61–70. [Google Scholar] [CrossRef]
- Wu, M.; Jia, H.; Luo, D.; Luo, H.; Zhao, F.; Li, G. A multi-attention dynamic graph convolution network with cost-sensitive learning approach to road-level and minute-level traffic accident prediction. IET Intell. Transp. Syst. 2022, 17, 270–284. [Google Scholar] [CrossRef]
Site | Width | Length | Observation Time | Duration | School | Sidewalk | Sidewalk Clutter | Total/Avoidance |
---|---|---|---|---|---|---|---|---|
A | 7.5 m | 27.5 m | 23 October 2023, 7:30–8:05 | 35 min | Primary | N | - | 30/11 |
B | 5 m | 31.5 m | 24 October 2023, 17:00–17:30 | 30 min | Primary | N | - | 21/13 |
C | 5 m | 31.8 m | 16 October 2023, 16:30–17:20 | 50 min | Middle | Y | 3 | 32/17 |
D | 4.5 m | 30.7 m | 23 October 2023, 17:00–17:10 | 10 min | Middle | Y | 1 | 37/21 |
E | 4.5 m | 35 m | 14 April 2023, 17:30–17:55 | 25 min | Middle | Y | 1 | 22/19 |
F | 5 m | 15 m | 14 April 2023, 7:50–8:00 | 10 min | Middle | Y | 1 | 25/15 |
Symbol | Explanation | Data Type and Units |
---|---|---|
S | Whether a vehicle traveling in the same direction is encountered (0: no, 1: yes) | Binary |
SS | Whether the encountered same-direction vehicle is a car (0: no, 1: yes) | Binary |
STV | Same-direction traffic volume | Continuous (vehicles per second) |
SM | Whether the encountered same-direction vehicle is an electric bicycle (0: no, 1: yes) | Binary |
O | Whether a vehicle traveling in the opposite direction is encountered (0: no, 1: yes) | Binary |
OS | Whether the encountered opposite-direction vehicle is a car (0: no, 1: yes) | Binary |
OTV | Opposite-direction traffic volume | Continuous (vehicles per second) |
OM | Whether the encountered opposite-direction vehicle is an electric bicycle (0: no, 1: yes) | Binary |
P | Whether pedestrians are walking together (0: no, 1: yes) | Binary |
SV | Same-direction speed (recorded as the maximum speed among vehicles in that direction) | Continuous (m/s) |
OV | Opposite-direction speed (recorded as the maximum speed among vehicles in that direction) | Continuous (m/s) |
W | Road width | Continuous (meters) |
Parameter | Value |
---|---|
Feature | 12 |
Hidden | 15 |
Output | 1 |
Num_epoch | 1000 |
Learn_rate | 0.02 |
Parameter | Value |
---|---|
Size | 16 |
P_cross | 0.4 |
P_mutate | 0.5 |
Maxgen | 150 |
Parameter | Value |
---|---|
Max_depth | 5 |
Tree | 80 |
Eta | 0.1 |
Gamma | 0.3 |
Lambda | 0.2 |
Alpha | 0.2 |
Objective | binary:logistic |
Eval_metri | Logloss |
Model Type | Algorithmic Error | Accuracy | Recall | Precision | F1 | Cost |
---|---|---|---|---|---|---|
BP Neural Network | 10.753 | 0.731 | 0.730 | 0.771 | 0.75 | 54 |
GA-BP Neural Network | 11.038 | 0.791 | 0.757 | 0.848 | 0.8 | 46 |
XGBoost | 0.21 | 0.720 | 0.716 | 0.756 | 0.74 | 55 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Lu, G.; Liu, M. Research on Pedestrian Avoidance Behavior for School Section Based on Improved BP Neural Network and XGboost Algorithm. Appl. Sci. 2025, 15, 4724. https://doi.org/10.3390/app15094724
Lu G, Liu M. Research on Pedestrian Avoidance Behavior for School Section Based on Improved BP Neural Network and XGboost Algorithm. Applied Sciences. 2025; 15(9):4724. https://doi.org/10.3390/app15094724
Chicago/Turabian StyleLu, Guiliang, and Mingwei Liu. 2025. "Research on Pedestrian Avoidance Behavior for School Section Based on Improved BP Neural Network and XGboost Algorithm" Applied Sciences 15, no. 9: 4724. https://doi.org/10.3390/app15094724
APA StyleLu, G., & Liu, M. (2025). Research on Pedestrian Avoidance Behavior for School Section Based on Improved BP Neural Network and XGboost Algorithm. Applied Sciences, 15(9), 4724. https://doi.org/10.3390/app15094724