Skip to content

【开源实习】在arxiv上发表基于MindSpore的原生论文(28) #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

# Traffic Flow Prediction using MSTIM Model (MindSpore)

This repository implements a **multi-scale temporal information modeling (MSTIM)** based deep learning model for traffic flow prediction, developed using the **MindSpore** framework. The model combines LSTM, CNN, and attention-style temporal aggregation to capture both short-term and long-term patterns in traffic data.

## 📁 Project Structure

```
traffic_prediction_mstim/
├── data/ # Contains the traffic dataset (e.g., Traffic.csv)
├── models/
│ ├── mstim.py # MSTIM module definition
│ └── model.py # TrafficFlowPredictor model
├── utils/
│ ├── preprocess.py # Data preprocessing functions
│ ├── dataset.py # Dataset wrapper for MindSpore
│ └── metrics.py # Evaluation metric computation
├── train.py # Main training and evaluation script
├── config.py # (Optional) Configuration settings
├── requirements.txt # Project dependencies
└── README.md # Project description
```

## 📊 Dataset

We use the [Metro Interstate Traffic Volume Dataset](https://archive.ics.uci.edu/ml/datasets/Metro+Interstate+Traffic+Volume), which contains hourly traffic volume data from a highway in Minnesota, USA. The dataset includes weather, date-time, and traffic volume features.

- Format: CSV
- Time range: 2012 to 2018
- Target: `traffic_volume` (normalized)

## 🚀 How to Run

1. **Install dependencies**
(We recommend using a virtual environment)

```bash
pip install -r requirements.txt
```

2. **Place dataset**
Download and place the CSV data file in the `data/` directory. You can rename it as `Traffic.csv` or modify the path in `train.py`.

3. **Train and Evaluate Model**

```bash
python train.py
```

4. **Model Output**
- Checkpoint saved as `traffic_flow_predictor.ckpt`
- Evaluation metrics: MAE, MSE, RMSE

## 🧠 Model Highlights

- **MSTIM Module**: Combines multiple 1D convolution layers with Bi-LSTM for multi-scale sequence modeling.
- **LSTM Backbone**: Learns temporal dependencies in the input sequence.
- **Custom Preprocessing**: Includes feature standardization and weather condition encoding.

## 📦 Dependencies

See [`requirements.txt`](./requirements.txt) for a complete list of required packages.

## 📄 License

MIT License

---

Created by your AI team using the MindSpore deep learning framework.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# Configuration settings for Traffic Flow Prediction Model

# Data settings
DATA_PATH = "data/Traffic.csv"
WINDOW_SIZE = 24

# Model settings
LSTM_HIDDEN_SIZE = 64
LSTM_LAYERS = 1
MSTIM_OUT_CHANNELS = 32

# Training settings
BATCH_SIZE = 32
NUM_EPOCHS = 10
LEARNING_RATE = 0.001

# MindSpore context settings
DEVICE_TARGET = "CPU" # Change to "GPU" if GPU is available

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

mindspore>=1.10.0
numpy
pandas
scikit-learn
tqdm
Loading