Documentation

Installation Guide

Traffic Accident Severity Prediction System using Machine Learning with SHAP Explainability and Flask Web App

Step-by-step Setup Verified Instructions Chat Support
Back to Project
Complete Guide

Installation Guide - Traffic Accident Severity Prediction

Follow these steps in order to set up and run the project on your computer. The whole process takes around 10 to 15 minutes.

Step 1: Prerequisites

Make sure the following are installed before you begin:

  • Python 3.9 or higher
  • pip (comes with Python)
  • A code editor such as VS Code
  • Jupyter Notebook or JupyterLab

Step 2: Extract the Project

Unzip the downloaded file and open the accident_severity_project folder in your code editor.

Step 3: Create a Virtual Environment

This keeps the project dependencies separate from your system. On Windows, run:

python -m venv venv
venv\Scripts\activate

On Mac or Linux, run:

python3 -m venv venv
source venv/bin/activate

Step 4: Install Dependencies

With the virtual environment active, install everything the project needs:

pip install -r requirements.txt
pip install flask

Step 5: Generate the Model Files

Open the notebooks folder and run these four notebooks fully, in this exact order. Each one must finish before you move to the next.

  1. 01_EDA.ipynb - creates the exploratory data analysis figures.
  2. 02_Preprocessing.ipynb - creates scaler.pkl, label_encoders.pkl, feature_names.pkl, and the train-test splits.
  3. 03_Model_Training.ipynb - trains all 8 models and saves best_model.pkl.
  4. 04_SHAP_Explainability.ipynb - creates the SHAP explanation plots.

Note: notebooks 02 and 03 are required for the prediction page. Notebooks 03 and 04 are required for the performance page.

Step 6: Launch the Flask App

From inside the accident_severity_project folder, run:

python app/flask_app.py

Step 7: Open in Your Browser

Visit the address below to use the app:

http://127.0.0.1:5000

You can explore four pages: Home, Predict, EDA dashboard, and Performance. To stop the server, press Ctrl + C in the terminal.

Common Issues

  • Model not found on the predict page: you skipped notebooks 02 and 03. Run them first.
  • Performance page is empty: run notebooks 03 and 04.
  • Module not found error: re-run the pip install command inside the active virtual environment.
  • Port already in use: close other running Flask apps or change the port number in flask_app.py.

Need Help?

Our team is here to assist you with installation and setup.

Chat with Us
Chat with us