This repository contains the development of a machine learning system for predicting mortality risk in traffic accidents, based on publicly-available accident data from 2010-2023 across Catalonia. The snapshot used in this project (exported on 2025-12-04) is included in the repository as data/accidents_catalonia_2010_2023.csv.
Our approach, as expected, combines exploratory data analysis, training and assessment of multiple machine learning models, and explainable AI techniques to understand which features matter most when predicting whether an accident will result in fatalities. These insights enable running hypothetical scenarios to assess mortality risk, analyzing past accidents to understand outcomes, and informing present interventions to reduce deadly accidents in the future; all via a user-friendly interactive web application we were tasked to build with Streamlit.
It was developed in a short 2-day sprint timeframe (see commit history) while studying for our final exams and finishing other final projects, and it is designed for use cases in fields like public safety, traffic management, insurance risk assessment and emergency response.
.
├── data/ # Traffic accident dataset from Catalonia (2010-2023)
├── models/ # Trained machine learning models and metadata
├── notebooks/ # Jupyter notebooks for analysis and model development
├── src/ # Streamlit interactive web application
│ ├── app.py
│ ├── components/
│ ├── pages/
│ │ ├── comparative_analysis.py
│ │ ├── hypothetical_scenarios.py
│ │ └── past_accident_analysis.py
│ └── utils/
├── output/ # Generated outputs and processed data
├── .gitignore
├── LICENSE
├── pyproject.toml # Project dependencies
└── README.md
- Python 3.10 or higher
uvpackage manager (install uv)- All Python dependencies are specified in
pyproject.toml
This project uses uv for Python environment management.
- Clone the repository and navigate to the project directory
- Create and activate the virtual environment:
uv sync
source .venv/bin/activateOn Windows:
uv sync
.venv\Scripts\activateTo launch the interactive Streamlit application:
streamlit run src/app.pyTo work with the analysis notebooks:
jupyter notebook notebooks/To add new packages, edit pyproject.toml and run:
uv sync


