Research Project: Research and Modeling of Accident Frequency and Severity on Toll Highways in Russia
This repository contains materials, scripts, and interim results for my thesis titled «Research and Modeling of Accident Frequency and Severity on Toll Highways in Russia» The goal of the study is to explore accident patterns on toll and free roads across Russia, focusing on their frequency and severity.
This project investigates the impact of road type (toll vs free) on the frequency and severity of traffic accidents on rural roads in Russia. The study combines classical econometric methods with modern machine learning approaches to explore key factors influencing road safety and to build predictive models.
(1.1) The average number of accidents per month is lower on toll roads than on free roads.
(1.2) The factors influencing the number of accidents differ between toll and free roads.
(2.1) The probability of a more severe accident outcome is lower on toll roads than on free roads.
(2.2) The factors influencing accident severity differ between toll and free roads.
~1.5 million observations of road traffic accidents from January 2015 to March 2025 collected from stat.gibdd.ru website.
├── gibdd_parser/ # Directory containing XML parsing logic
│ ├── parser.py # Script for extracting XML files from the traffic statistics portal
│ └── settings.py # Configuration file with parameters such as request URLs, headers, and regions
├── severity/ # Directory containing working with accident-level data
│ ├── severity_hypotheses.ipynb # Script to check hypotheses
│ └── severity_model.ipynb # Script to check hypotheses on "hot spots" and train models to predict severity and "hot spots"
├── frequency/ # Directory containing working with panel data
│ ├── frequency_hypotheses.ipynb # Script to check hypotheses on a full sample and on "hot spots"
│ └── frequency_model.ipynb # Script to train the model predict frequency of accidents
├── creating_final_dataset.ipynb # Constructe two datasets with different observations
├── example_data_cards.pdf # Human-readable example of raw accident data
├── example_data_cards.xml # Sample raw XML data for one region and month
├── reading_XML_files.ipynb # Script to transform and aggregate XML data into a single CSV file
├── getting_started_with_the_data.ipynb # Script for initial data cleaning, preprocessing, and feature engineering
├── .gitignore # Git ignored files
├── README.md # Project documentation
├── thesis_concept_overview.pdf # Concept presentation for the project
└── variables_description.md # Description of project features
Collecte accident data from the website using gibdd_parser/. Example data for one month and one region can be found in example_data_cards.pdf (human-readable format) and example_data_cards.xml (raw XML format).
Output: raw XML files stored monthly for each region (e.g., ДТП_<REGION_NUMBER>_YYYY_MM.xml).
Using reading_XML_files.ipynb:
- extract relevant information, such as location, accident type, weather conditions, and participant attributes
- convert participant-level data to accident-level data
- create of new features based on existing accident attributes
- combine and transforme data into a single DataFrame with ~1.5 million observations
Output: raw CSV file (single dataset for all accidents)
Using getting_started_with_the_data.ipynb:
- remove or filling the gaps with ML algorithms
- process caregorical features
- remove unnecessary features and creating the new ones
Output: processed CSV file (single dataset for all accidents)
Using creating_final_dataset.ipynb code constructe:
- accident-level dataset (unit of observation ─ individual accident, for analysis of accident severity)
- panel dataset (unit of observation ─ road section × month, for analysis of accident frequency)
- with negative sampling and feature aggregation
and add a binary variable
is_tollindicating the road type
Output: ACCIDENT_LEVEL_DATA.csv, PANEL_DATA.csv
Work in severity/.
- Check hypotheses (2.1) and (2.2)
- Identify «hot spots» and check hypotheses (2.1) and (2.2) again
- Train a model to predict «hot spots»
- Multinomial Logit (MNL) Model
- undersampling, class weighting
- VIF (Variance Inflation Factor), correlation matrix
- feature importance, PCA, UMAP
- DBSCAN, Random Forest, Gradient Boosting, Neural Network
- GridSearchCV
- evaluation metrics: Accuracy and F1-score
- Hypotheses (2.1) and (2.2) confirmed for both full sample and «hot spots»
- Model predicting «hot spots» achieved 0.85 accuracy and 0.80 F1-score on random obs
Output: ACCIDENTS_HOT_SPOTS.csv (as features for panel dataset, severity_model.ipynb)
Work in frequency/.
- Check hypotheses (1.1) and (1.2)
- Check hypotheses (1.1) and (1.2) for «hot spots»
- Train a model to predict the probability of an accident
- Panel Regression with Fixed Effects
- Negative Binomial Regression (in case of overdispersion)
- undersampling, class weighting
- VIF (Variance Inflation Factor), correlation matrix
- feature importance
- Random Forest, Gradient Boosting
- GridSearchCV
- evaluation metrics: MAE and MSE
- Hypothesis (1.1) rejected, hypothesis (1.2) partially confirmed
- Due to the target being overfilled with zeros, we moved from a regression problem to a binary classification (predicting whether an accident will happen on the road or not, instead of predicting the number of accidents)
- Model for toll roads achieved 0.86 F1-score and 0.82 MCC (Matthews correlation coefficient)
- General model and model for free roads achieved 0.94 accuracy, but only 0.44 F1-score and 0.46 MCC due to the large class imbalance (the minor class makes up 0.069% of the sample) and data specificity (it is recommended to add additional variables that will help increase the separability of the data in the feature space)