This project provides a simple Flask API for predicting public transport route times based on historical data. It analyzes patterns in route schedules and predicts the most likely times for future route occurrences.
- List all available routes
- Predict next day's most likely times for specific routes
- Confidence scoring for predictions
- Simple REST API interface
- Python 3.8 or higher
- pip (Python package installer)
- Git
- Basic knowledge of REST APIs
- Your route data in CSV format
- Clone the repository:
git clone https://github.com/holasoymalva/data_jam.git
cd data_jam
- Create a virtual environment and activate it:
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
- Install required packages:
pip install -r requirements.txt
- Place your data file:
- Copy your route data CSV file to the
data/
directory - Name it
data_example.csv
- Copy your route data CSV file to the
flask_route_predictor/
│
├── data/
│ └── data_example.csv
│
├── app/
│ ├── __init__.py
│ ├── routes.py
│ └── predictor.py
│
├── requirements.txt
└── run.py
- Make sure your virtual environment is activated
- Run the Flask application:
python run.py
The API will start running on http://localhost:5000
GET /routes
Returns a list of all available routes.
Example response:
{
"status": "success",
"data": [
{
"route_id": 908,
"route_name": "82 García Gíneres"
},
...
]
}
GET /predict/<route_id>
Returns predictions for a specific route.
Example response:
{
"status": "success",
"route_id": 908,
"predictions": [
{
"hour": 8,
"predicted_time": "2024-10-27 08:00:00",
"confidence": 85.5
},
...
]
}
The CSV file should have the following columns:
- event_date
- route_id
- route_name
- (other columns will be ignored)
Example:
event_date,route_id,route_name
2024-09-22 13:44:00.000,908,82 García Gíneres
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by holasoymalva
- Thanks to all contributors
- Inspired by public transport optimization needs
- Built with Flask framework
If you have any questions or need help, please:
- Check the existing issues
- Create a new issue if needed
- Contact me through GitHub
Remember to ⭐️ this repository if you found it helpful!