Skip to content

Yared-Mengiste/traffic-accident-neural-network-classifier

Repository files navigation

🚦 Traffic Accident Type Classification Using Neural Networks

📌 Overview

This project aims to predict the type of traffic accident using a supervised Neural Network (NN) model. The dataset contains nearly 60,000 accident records with driver, vehicle, road, environmental, temporal, and location-related features.

The primary goal is to build a generalizable classification model by applying proper preprocessing, feature engineering, and validation techniques while avoiding data leakage.


📊 Dataset

  • Size: 59,981 rows × 36 columns

  • Target Variable: Accident Type

  • Feature Types:

    • Categorical (driver behavior, road condition, weather, vehicle type)
    • Numerical (driver age, vehicle service year, number of vehicles)
    • Temporal (hour, day, month)
    • Spatial (location easting & northing)

🔍 Exploratory Data Analysis (EDA)

The following analyses were performed:

  • Histograms and boxplots for numerical feature distributions
  • Count plots for categorical variables
  • Target class distribution analysis
  • Correlation analysis for numerical features

EDA helped identify skewness, outliers, and class imbalance.


🛠 Data Preprocessing & Feature Engineering

✅ Data Leakage Prevention

Outcome-related variables (e.g., number of casualties, injuries, fatalities) were removed to prevent the model from learning information unavailable before an accident occurs.

✅ Feature Transformations

  • Temporal Encoding

    • Hour encoded using sine and cosine to preserve cyclic behavior
    • Additional Time_Bucket feature created (Morning Rush, Midday, Evening Rush, Night)
  • Spatial Encoding

    • Location Easting and Location Northing discretized into bins
  • Vehicle Age Grouping

    • Vehicles categorized as New, Mid, or Old
  • Date Features

    • Date and Year removed to avoid redundancy and leakage

✅ Encoding

  • Target Variable: Label encoded
  • Categorical Features: Encoded appropriately for NN input
  • Numerical Features: Scaled for stable NN training

🧠 Model Architecture

  • Feedforward Neural Network
  • Fully connected dense layers
  • ReLU activation
  • Softmax output layer for multi-class classification

Loss & Optimization

  • Loss Function: Sparse Categorical Crossentropy
  • Optimizer: Adam
  • Regularization: L2, Dropout, and Early Stopping
  • Validation: Used to monitor overfitting and tune hyperparameters

📈 Model Evaluation

  • Training vs validation loss and accuracy monitoring
  • Early stopping to prevent overfitting
  • Performance evaluated on unseen data

🧪 Key Concepts Applied

  • Overfitting prevention
  • Cyclic feature encoding
  • Label encoding vs one-hot encoding
  • Validation-based model tuning
  • Data leakage handling

🧾 Technologies Used

  • Python
  • Pandas, NumPy
  • Matplotlib, Seaborn
  • Scikit-learn
  • TensorFlow / Keras
  • Jupyter Notebook

📌 Future Improvements

  • Handle class imbalance using class weights or focal loss
  • Try alternative models (XGBoost, Random Forest)
  • Add SHAP or feature importance analysis
  • Deploy model using a simple web interface

👤 Author

Yared Mengiste Software Engineering Student Neural Network & Data Analysis Project

About

A neural network model built to classify traffic accident types using cleaned and engineered features from a large real-world dataset, with careful preprocessing and validation to prevent overfitting and data leakage.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors