A deep learning project that predicts hourly traffic volume using PyTorch LSTM networks. This project analyzes traffic patterns on an interstate highway in Minnesota, USA, incorporating weather data and temporal features to make accurate predictions.
This project demonstrates how to use deep learning (LSTM networks) for time-series regression tasks. It predicts hourly traffic volume based on historical data, weather, and time features. The workflow includes data preprocessing, model building, training, evaluation, and visualization.
- Clone the repository
- Create and activate a virtual environment
- Install dependencies
- Run the Jupyter notebook
- Overview
- Features
- Dataset
- Installation
- Usage
- Model Architecture
- Visualizations
- Results
- Project Structure
- Customization
- Contributing
- References
- License
- LSTM-based regression for traffic prediction
- Data preprocessing and sequence creation
- Multiple evaluation metrics (MSE, MAE, RMSE, R²)
- Visualizations: actual vs. predicted, residuals
- Well-commented code and markdown explanations
- Source: UCI Machine Learning Repository
- Features: Traffic volume, weather, time, holidays
- Files:
train_scaled.csv,test_scaled.csv
- Python 3.7+
- pip
git clone <your-repo-url>
cd Traffic_Pytorch
python -m venv venv
venv\Scripts\activate # Windows
# or
source venv/bin/activate # Mac/Linux
pip install -r requirements.txt- Open
notebook.ipynbin Jupyter Notebook - Run all cells to:
- Load and preprocess data
- Train the LSTM model
- Evaluate and visualize results
- Input: Sequence of 12 hours, 66 features
- LSTM layers
- Fully connected layers
- Output: Predicted traffic volume
- Actual vs. Predicted: Line plot
- Residuals: Scatter plot
- Training Loss: (if enabled)
Example metrics (run notebook for your results):
- MSE: Mean Squared Error
- MAE: Mean Absolute Error
- RMSE: Root Mean Squared Error
- R²: Coefficient of Determination
Traffic_Pytorch/
├── notebook.ipynb # Main Jupyter notebook
├── requirements.txt # Python dependencies
├── README.md # Project documentation
├── traffic.png # Project header image
├── best_traffic_model.pth # Saved best model
└── Data/
├── train_scaled.csv # Training dataset
├── test_scaled.csv # Testing dataset
└── traffic_enhanced.csv # Enhanced dataset
- Change model parameters in the notebook
- Add new features to CSV files and update input size
- Fork the repository
- Create a feature branch
- Commit and push your changes
- Create a Pull Request
- UCI Machine Learning Repository - Metro Interstate Traffic Volume
- PyTorch documentation
- Matplotlib, Seaborn
MIT License
⭐ If this project helped you learn, please give it a star! ⭐
