Skip to content

About

the project is been made to predict traffic using machine learning. it is still in building phase and i am actively working on this project

Resources

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metro Interstate Traffic Prediction

Machine Learning project for traffic volume forecasting and congestion classification using weather, temporal, and historical traffic data.

Project Overview

This project analyzes the Metro Interstate Traffic Volume Dataset and builds machine learning models to:

  • Predict future traffic volume (Regression)
  • Classify traffic congestion levels (Classification)
  • Identify the most influential factors affecting traffic flow
  • Compare multiple machine learning approaches

The project follows a complete machine learning pipeline including data cleaning, exploratory data analysis (EDA), feature engineering, model training, evaluation, and interpretation.

Dataset

Dataset: Metro Interstate Traffic Volume Dataset

  • 48,204 traffic observations
  • Weather conditions
  • Temperature, rain, snow, cloud coverage
  • Date and time information
  • Traffic volume measurements

Exploratory Data Analysis

Several insights were discovered during EDA:

  • Traffic volume strongly depends on hour of the day
  • Weekdays experience significantly more traffic than weekends
  • Peak traffic occurs during commuting hours
  • Friday shows the highest average traffic volume
  • Temperature has a weak positive relationship with traffic volume
  • Weather conditions have limited influence compared to temporal features

Feature Engineering

To improve predictive performance, several engineered features were created:

  • Hour of day
  • Day of week
  • Month and year
  • Weekend indicator
  • 1-hour traffic lag
  • 6-hour traffic lag
  • 24-hour traffic lag
  • 24-hour rolling mean
  • 24-hour rolling standard deviation
  • Cyclical hour encoding (sin/cos)
  • Weather one-hot encoding

Regression Models

Objective: Predict exact traffic volume.

Model MAE RMSE R² Score
Mean Predictor 1723 1968 0.00
Linear Regression 434 608 0.905
Random Forest Regressor 150.6 235.1 0.9857
XGBoost Regressor 151.1 232.3 0.9861

Best Regression Model: XGBoost Regressor


Traffic Congestion Classification

Traffic volume was converted into four congestion categories using quartile-based segmentation:

  • Low
  • Medium
  • High
  • Critical

Random Forest Classifier achieved:

  • Accuracy: 93%
  • Macro F1 Score: 0.93
  • Weighted F1 Score: 0.93

The confusion matrix revealed that most errors occurred between adjacent congestion levels, while severe misclassifications were extremely rare.


Key Findings

  • Historical traffic volume is the strongest predictor of future traffic.
  • 1-hour lag traffic contributed nearly 73% of total feature importance.
  • Time-related features outperform weather-related features.
  • Feature engineering contributed more to performance gains than model complexity.
  • Traffic forecasting can be performed with high accuracy using engineered temporal features.

Tech Stack

About

the project is been made to predict traffic using machine learning. it is still in building phase and i am actively working on this project

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages