- Project Overview
- Features
- Demo
- Project Structure
- Technologies Used
- Model Performance
- References
- Legal Notice
- License
ONCycle is a platform designed to follow the status of trains delays in real-time. It provides users with the ability to track train delays, view historical data, and predict future delays based on historical patterns.
- Real-time train delay tracking
- Historical delay data visualization
- Predictive analytics for future delays
- User-friendly interface
- Responsive design for mobile and desktop
ONCycle_preview.mp4
Check out the full website here
ONCycle/
βββ app/ # Main application package
β βββ main.py # FastAPI app entry point
β βββ api/routes/ # API endpoint definitions
β β βββ health.py # Health check endpoints
β β βββ prediction.py # ML prediction endpoints
β βββ core/ # Core application components
β β βββ config.py # Configuration management
β β βββ logging.py # Logging setup
β βββ models/ # ML model classes
β β βββ predictors.py # Prediction model implementations
β βββ schemas/ # Pydantic data validation
β β βββ prediction.py # Request/response schemas
β βββ services/ # Business logic layer
β βββ model_service.py # Model loading and inference
βββ models/ # Trained model files (.joblib)
βββ scripts/ # Utility scripts
β βββ train_models.py # Model training script
β βββ test_api.py # API testing script
β βββ run_dev.py # Development server runner
βββ requirements.txt # App dependencies
βββ ui/ # User Interface package
β βββ client/ # React frontend (Vite + TypeScript)
β βββ server/ # NextJS backend for SSR
βββ experiments/ # Model development and research
β βββ notebooks/ # Jupyter notebooks for analysis
| | βββ 00_data_cleaning.ipynb # Initial data cleaning and exploration
| | βββ 01_EDA.ipynb # Exploratory Data Analysis
| | βββ 02_model_selection.ipynb # Model selection and evaluation
| βββscripts/ # Utility scripts for experiments
| βββscreenshots/ # EDA and results screenshots
β βββ data/ # Training data
β βββ models/ # Experimental models
| βββ README.md # Model metrics history
- Interface: React, ViteJS, Tremor, Tremor Blocks
- Backend: FastAPI, NextJS
- Database: PostgreSQL, Supabase
- Modeling: Python, Scikit-learn, XGBoost
- Deployment: DigitalOcean, Vercel
- Data Exploration: Explored and visualized historical train delay data to identify trends and anomalies.
- Feature Engineering: Developed temporal (hour, day, month) and route-specific features to enhance predictive power.
- Model Experimentation: Evaluated multiple algorithms; selected XGBoost for its superior performance (high accuracy, fast training/inference times, and low resource consumption).
- Validation & Testing: Used cross-validation to ensure model robustness and generalizability.
- API Architecture: Designed RESTful APIs using FastAPI for efficient communication between frontend and backend.
- Model Deployment: Implemented scalable model serving with optimized loading and inference pipelines.
- Data Integrity: Leveraged Pydantic for strict request/response validation and type safety.
- Monitoring: Integrated logging and health checks for reliability.
- User Interface: Built a modern, accessible UI with React, Vite, and Tremor components.
- State Management: Implemented efficient state handling and caching for smooth user experience.
- Responsiveness: Ensured seamless usability across devices with a mobile-first design.
- Continuous model training and monitoring: Regularly updated the model with new data to maintain accuracy.
- Documentation: Maintained clear documentation for contributors and users.
Our machine learning model is trained on historical train data and achieves:
| Metric | Value |
|---|---|
| RΒ² Score | 0.852 |
| Mean Absolute Error | 3.62 minutes |
| Features Used | 26 |
| Training Samples | 321,269 |
| Model Version | v1.0 |
Model metrics history: experiments/README.md
The model uses XGBoost with engineered features including:
- Temporal features (hour, day of week, month)
- Route characteristics (distance, duration, route, number of stops, sequence...)
- Historical delay patterns
- Short-term train arrival delay prediction: a data-driven approachΒ [Paper]
- A review of data-driven approaches to predict train delaysΒ [Paper]
- Prediction of rail transit delays with machine learning: How to exploit open data sourcesΒ [Paper]
- RATPstatus.frΒ [Inspiration]
- xgboostingΒ [Code]
This project is not affiliated with or endorsed by ONCF or any other official railway authority. It is an independent project created for educational and proof of concept (POC) purposes.
This project is licensed under the MIT License. See the LICENSE file for details.