Advanced machine learning system for accurately predicting energy consumption in electric vehicles
Features | Installation | Quick Start | Documentation | Contributing
The EV Energy Prediction System is a sophisticated machine learning solution that addresses the critical challenge of accurately predicting energy consumption in electric vehicles. By leveraging state-of-the-art ensemble models and comprehensive feature engineering, the system provides highly reliable energy usage forecasts and range estimations based on diverse factors including driving conditions, weather patterns, route characteristics, and vehicle-specific parameters.
Developed for production deployment, this system helps EV users, fleet operators, and vehicle manufacturers overcome range anxiety through precise predictions that optimize route planning, charging strategies, and overall energy management. The architecture follows MLOps best practices with modular components, ensuring scalability, maintainability, and continuous improvement.
🔮 Precise Prediction Engine Accurate energy consumption forecasting leveraging ensemble machine learning models that adapt to diverse driving scenarios |
🌐 Comprehensive Factor Analysis Integration of multiple data dimensions including route topology, weather conditions, vehicle specifications, and driving patterns |
⚙️ Advanced Model Architecture Combination of LSTM networks for temporal patterns and XGBoost for complex feature interactions, optimized for accuracy |
🔌 Production-Ready API Robust RESTful API designed for seamless integration with vehicle systems, navigation apps, and fleet management platforms |
📊 Interactive Visualization Comprehensive dashboards and reporting tools for analyzing energy consumption patterns and optimization opportunities |
🛠️ Extensible Framework Modular architecture enabling easy addition of new features, model improvements, and integration capabilities |
- Data Pipeline: Processes diverse data sources including route information, weather data, and vehicle telemetry
- Feature Engineering: Transforms raw data into meaningful features through domain-specific algorithms
- Model Training: Implements a systematic approach to model development with validation and hyperparameter optimization
- Ensemble Model: Combines multiple algorithms to balance the strengths of different prediction approaches
- Prediction API: Provides a robust interface for real-time predictions with appropriate error handling
- Evaluation & Monitoring: Ensures continuous model quality through automated testing and performance tracking
├── config/ # Configuration management
│ └── model_config.yaml # Model hyperparameters and settings
├── data/ # Data management
│ └── preprocess.py # Data preprocessing utilities
├── images/ # Project images and diagrams
├── models/ # Model implementations
│ ├── ensemble.py # Ensemble model architecture
│ ├── lstm_model.py # LSTM implementation for temporal data
│ ├── train_model.py # Model training orchestration
│ └── xgboost_model.py # XGBoost implementation
├── scripts/ # Utility scripts
│ ├── deploy.sh # Deployment automation
│ └── train.sh # Training execution
├── src/ # Core source code
│ ├── api/ # API implementation
│ │ ├── main.py # API entry point
│ │ ├── prediction.py # Prediction service
│ │ └── schemas.py # API request/response schemas
│ ├── features/ # Feature engineering
│ │ └── build_features.py # Feature generation and transformation
│ └── visualization/ # Visualization components
│ └── visualize.py # Visualization utilities
├── test/ # Comprehensive test suite
│ ├── conftest.py # Test configurations
│ ├── test_api.py # API tests
│ └── test_models.py # Model tests
├── .gitattributes # Git attributes
├── .gitignore # Git ignore rules
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Docker configuration
├── LICENSE # License information
├── README.md # Project documentation
└── requirements.txt # Dependency management
Get up and running with the EV Energy Prediction System in minutes:
# Clone the repository
git clone https://github.com/yourusername/ev-energy-prediction.git
cd ev-energy-prediction
# Set up with Docker (recommended for quick start)
docker-compose up -d
# Access the API documentation
open http://localhost:8000/docs
- Python 3.8+
- Docker and Docker Compose (for containerized deployment)
- NVIDIA GPU (recommended for model training)
# Clone the repository
git clone https://github.com/yourusername/ev-energy-prediction.git
cd ev-energy-prediction
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Verify installation
python -c "from src.api.prediction import predict_energy_consumption; print('Installation successful')"
For containerized deployment with all dependencies preconfigured:
# Build and start services
docker-compose up -d
# Verify services are running
docker-compose ps
The system provides a RESTful API for energy consumption predictions:
import requests
import json
# API endpoint
url = "http://localhost:8000/api/v1/predict"
# Example request data
payload = {
"route": {
"origin": {"lat": 37.7749, "lng": -122.4194},
"destination": {"lat": 37.3352, "lng": -121.8811},
"departure_time": "2023-05-10T08:00:00Z"
},
"vehicle": {
"model": "Model Y",
"year": 2023,
"battery_capacity": 75.0,
"efficiency": 0.16
},
"weather": {
"temperature": 18.5,
"precipitation": 0,
"wind_speed": 10
}
}
# Make prediction request
response = requests.post(url, json=payload)
result = response.json()
print(f"Estimated energy consumption: {result['prediction']['energy_kwh']} kWh")
print(f"Estimated range: {result['prediction']['range_km']} km")
POST /api/v1/predict
Request Schema:
Field | Type | Description |
---|---|---|
route |
Object | Route information including origin, destination, and optional waypoints |
vehicle |
Object | Vehicle specifications including model, battery capacity, and efficiency |
weather |
Object | Weather conditions including temperature, precipitation, and wind |
options |
Object | Optional settings for the prediction request |
Response Schema:
Field | Type | Description |
---|---|---|
prediction |
Object | Prediction results including energy consumption and range |
route_details |
Object | Analyzed route information |
metadata |
Object | Information about the prediction process |
For complete API documentation, visit the Swagger UI at /docs
when the server is running.
The system provides tools for training and optimizing prediction models:
# Run standard training process
./scripts/train.sh
# Run training with custom configuration
python models/train_model.py --config custom_config.yaml --output_dir models/checkpoints
# Install development dependencies
pip install -r requirements-dev.txt
# Set up pre-commit hooks
pre-commit install
# Run code formatter
black .
This project follows strict coding standards:
- PEP 8 guidelines for Python code
- Black for consistent code formatting
- Type hints for improved code quality and IDE support
# Verify code style
flake8 .
# Apply automatic formatting
black .
# Check type hints
mypy src
The project includes comprehensive tests to ensure code quality:
# Run all tests
pytest
# Run tests with coverage report
pytest --cov=src --cov=models
# Run specific test modules
pytest test/test_models.py
The recommended deployment method uses Docker:
# Deploy with Docker Compose
docker-compose -f docker-compose.prod.yml up -d
# Scale the prediction service
docker-compose -f docker-compose.prod.yml up -d --scale prediction=3
For environments without Docker:
# Install production dependencies
pip install -r requirements.txt
# Start the API server
gunicorn -w 4 -k uvicorn.workers.UvicornWorker src.api.main:app
The EV Energy Prediction System delivers reliable performance metrics:
Metric | Value | Description |
---|---|---|
Prediction Accuracy | ~92-95% | Energy consumption prediction accuracy under varied conditions |
API Latency | <100ms | Average response time for prediction requests |
Throughput | 100+ req/s | Requests handled per second per instance |
GPU Training Time | ~2 hours | Complete model training cycle on recommended hardware |
We welcome contributions to the EV Energy Prediction System! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Run tests to ensure everything works (
pytest
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
For detailed contribution guidelines, see CONTRIBUTING.md.
- Enhanced prediction models
- Additional feature engineering approaches
- Improved visualization tools
- Extended API capabilities
- Performance optimizations
- Documentation improvements
This project is licensed under the MIT License - see the LICENSE file for details.
- Open-source libraries that power this project:
If you find E-Forecast helpful, please consider giving it a star ⭐
@Muhkartal - kartal.dev