Skip to content

Apoo3va/driving-behaviour-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Driving Behaviour Classification Model πŸš—

A supervised machine learning project that classifies driver behavior β€” Safe, Distracted, or Aggressive β€” using telemetry-style driving data such as speed, braking, steering, and reaction time.

πŸ“‹ Overview

This Driving Behaviour Machine Learning Based Model trains and compares multiple classification models on a driving telemetry dataset to predict a driver's behavior category from sensor-like inputs. The project covers the full ML workflow: exploratory data analysis, preprocessing, baseline model comparison, cross-validation, hyperparameter tuning, and feature importance analysis.

πŸ“‚ Dataset

File: Driver_Behavior_Realistic.csv Shape: 29,002 rows Γ— 11 columns

Feature Description
speed_kmph Vehicle speed
accel_x, accel_y Acceleration components
brake_pressure Braking force applied
steering_angle Steering wheel angle
throttle Throttle input
lane_deviation Deviation from lane center
phone_usage Phone usage indicator
headway_distance Distance to vehicle ahead
reaction_time Driver reaction time
behavior_label Target β€” Safe, Distracted, or Aggressive

Class distribution (fairly balanced):

  • Distracted: 10,021
  • Safe: 10,003
  • Aggressive: 8,978

πŸ› οΈ Tech Stack

Category Tools/Tech
Language Python (Google Colab, T4 GPU runtime)
Data handling pandas, NumPy
Visualization matplotlib, seaborn
ML framework scikit-learn
Models tested Decision Tree, Random Forest, Gradient Boosting, SVM, KNN, Logistic Regression, MLP (Neural Network)

🧠 Methodology

  1. EDA β€” inspected class balance, feature distributions, and boxplots comparing key features (speed_kmph, brake_pressure, steering_angle, reaction_time) across behavior classes.
  2. Preprocessing — label-encoded the target (Aggressive→0, Distracted→1, Safe→2) and standardized features with StandardScaler inside an sklearn Pipeline.
  3. Baseline modeling β€” trained 5 baseline classifiers (Decision Tree, Random Forest, Gradient Boosting, SVM, KNN) and compared Accuracy, Precision, Recall, and F1-Score, with confusion matrices for each.
  4. Cross-validation β€” used Stratified 5-Fold CV (scoring='f1_weighted') for a more robust estimate of each model's performance.
  5. Hyperparameter tuning β€” tuned the top model(s) via GridSearchCV / RandomizedSearchCV (5-fold CV, optimizing weighted F1).
  6. Model interpretation β€” extracted feature importances from Random Forest and Gradient Boosting, and inspected Logistic Regression coefficients per class to understand which features drive each behavior label.
  7. Learning rate analysis β€” tested Gradient Boosting across multiple learning rates (0.5 β†’ 0.01) to study the stability/generalization tradeoff.
  8. Final comparison β€” benchmarked baseline vs. tuned models side-by-side.

πŸ† Results

Model Accuracy Precision Recall F1-Score
KNN (Baseline) 0.9509 0.9509 0.9509 0.9509
Gradient Boosting (Tuned) 0.9509 0.9509 0.9509 0.9509
KNN (Tuned) 0.9507 0.9507 0.9507 0.9507
Neural Network (MLP) 0.9493 0.9493 0.9493 0.9493

Best model: KNN (Baseline) β€” ~95.1% accuracy/F1, essentially tied with tuned Gradient Boosting, showing the default KNN already performs near-optimally on this dataset without additional tuning overhead.

πŸš€ Getting Started

Prerequisites

  • Python 3.8+
  • Jupyter Notebook or Google Colab

Installation

git clone https://github.com/Apoo3va/driver-behaviour-ai.git
cd driver-behaviour-ai
pip install pandas numpy matplotlib seaborn scikit-learn

Running the Notebook

  1. Open Driver_Behavior_Fixed.ipynb in Jupyter or Google Colab
  2. Place Driver_Behavior_Realistic.csv in the same directory (or upload to /content/ in Colab)
  3. Run all cells top to bottom

πŸ“ Project Structure

driving-behaviour-classification/
β”œβ”€β”€ Driver_Behavior_Fixed.ipynb     # Full EDA + model training + comparison notebook
β”œβ”€β”€ Driver_Behavior_Realistic.csv    # Telemetry dataset
└── README.md

🀝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

πŸ‘€ Author

Apoorva Yadav

πŸ“„ License

This project is licensed under the MIT License β€” feel free to use, modify, and distribute with attribution.

πŸ“¬ Contact

For questions or feedback, please open an issue on this repository.

About

A machine learning model that detects and classifies driving behavior. Built with Flask and a trained scikit-learn model, it takes driver input/sensor data and predicts behavior patterns (e.g. safe vs. risky driving), served through a lightweight HTML/CSS/JS frontend and deployed on Render.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors