Skip to content

NitishN31/Real-time-range-in-EVs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real-time EV Range Prediction

Overview

This project aims to predict the range of an Electric Vehicle (EV) based on real-time parameters. By analyzing factors such as speed, battery status, temperature, and driving patterns, we provide a more accurate range estimate than simple percentage-based calculations.

Features used

The models are trained on the following synthetic features:

  • Speed (km/h): The current speed of the vehicle.
  • State of Charge (SOC) %: The current battery level.
  • Ambient Temperature (°C): The outside temperature.
  • Motor RPM: Rotations per minute of the motor.
  • Motor Temperature (°C): Temperature of the motor.
  • Battery Temperature (°C): Temperature of the battery pack (Critical for efficiency).
  • Acceleration (m/s²): Driving aggressiveness.

Project Structure

Real time Range prediction/
├── data/                   # Generated data and plots
├── models/                 # Saved models (XGBoost, MLP, Scaler)
├── src/
│   ├── data_simulator.py   # Generates synthetic data
│   ├── eda.py              # Exploratory Data Analysis
│   ├── train_model.py      # Trains XGBoost model
│   ├── train_advanced_model.py # Trains MLP (Neural Network)
│   └── compare_models.py   # Compares both models
├── requirements.txt        # Dependencies
└── README.md               # Project documentation

Installation

  1. Clone the repository.
  2. Install the required dependencies:
    pip install -r requirements.txt

Usage

1. Generate Data

If you don't have the dataset, generate synthetic data:

python src/data_simulator.py

This creates data/ev_range_data.csv.

2. Exploratory Data Analysis (EDA)

Visualize the data correlations and distributions:

python src/eda.py

Correlation Matrix

Correlation Matrix

Pairplot

Pairplot

3. Train Baseline Model (XGBoost)

Train the XGBoost regressor:

python src/train_model.py

Feature Importance

Feature Importance

Predictions vs Actual (XGBoost)

Predictions vs Actual

4. Train Advanced Model (MLP)

Train the Deep Neural Network:

python src/train_advanced_model.py

Training Loss

Training Loss

5. Compare Models

Compare the performance of XGBoost and MLP:

python src/compare_models.py

Results & Comparison

Model MSE MAE R2 Score
XGBoost 118.58 8.59 0.9828
MLP (Neural Network) 106.03 8.18 0.9846

The MLP model slightly outperforms the XGBoost model, achieving a higher R2 score and lower error rates.

R2 Score Comparison

R2 Comparison

Predicted vs Actual (Comparison)

Comparison Scatter

Conclusion

This project successfully demonstrates that machine learning can accurately predict EV range using real-time vehicle data.

  • Key Findings:
    • Speed and SOC are the most dominant factors.
    • Battery Temperature plays a significant role in efficiency; extreme temperatures reduce range.
    • The Neural Network (MLP) captures complex non-linear relationships slightly better than XGBoost, though both models perform exceptionally well (R2 > 0.98).
  • Future Work:
    • Integrate real-world driving data.
    • Implement a time-series model (LSTM) if sequential data becomes available.
    • Deploy the model as a real-time API.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages