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.
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.
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
| 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) |
- EDA β inspected class balance, feature distributions, and boxplots comparing key features (
speed_kmph,brake_pressure,steering_angle,reaction_time) across behavior classes. - Preprocessing β label-encoded the target (
Aggressiveβ0,Distractedβ1,Safeβ2) and standardized features withStandardScalerinside an sklearnPipeline. - 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.
- Cross-validation β used Stratified 5-Fold CV (
scoring='f1_weighted') for a more robust estimate of each model's performance. - Hyperparameter tuning β tuned the top model(s) via
GridSearchCV/RandomizedSearchCV(5-fold CV, optimizing weighted F1). - 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.
- Learning rate analysis β tested Gradient Boosting across multiple learning rates (0.5 β 0.01) to study the stability/generalization tradeoff.
- Final comparison β benchmarked baseline vs. tuned models side-by-side.
| 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.
- Python 3.8+
- Jupyter Notebook or Google Colab
git clone https://github.com/Apoo3va/driver-behaviour-ai.git
cd driver-behaviour-ai
pip install pandas numpy matplotlib seaborn scikit-learn- Open
Driver_Behavior_Fixed.ipynbin Jupyter or Google Colab - Place
Driver_Behavior_Realistic.csvin the same directory (or upload to/content/in Colab) - Run all cells top to bottom
driving-behaviour-classification/
βββ Driver_Behavior_Fixed.ipynb # Full EDA + model training + comparison notebook
βββ Driver_Behavior_Realistic.csv # Telemetry dataset
βββ README.md
Contributions are welcome! Feel free to open an issue or submit a pull request.
Apoorva Yadav
This project is licensed under the MIT License β feel free to use, modify, and distribute with attribution.
For questions or feedback, please open an issue on this repository.