EV Battery Prediction

Machine Learning To Predict EV Battery Charge Times

In this project, we developed a machine learning model to accurately predict electric vehicle (EV) charging duration using battery charging data from Kaggle. The goal was to improve charging time estimation, reduce range anxiety, and support better charging station and grid planning

.

We began with standard linear regression and evolved the model using ridge regularization to address multicollinearity and improve generalization.

Initial Linear Regression

Early iterations using limited features resulted in extremely poor performance (R² ≈ -0.001), demonstrating that SOC, voltage, and current alone were insufficient.

Final Linear Model

After expanding features and engineering Power:

  • R² = 0.98
  • MSE = 11

Ridge Regression (Final Model)

  • Best λ ≈ 4.64
  • Test R² ≈ 0.987
  • Test MSE ≈ 11.7

Python vs C++ Implementation

To explore computational efficiency, we implemented Ridge Regression in both Python and C++

Python:

  • Training time ≈ 936 µs
  • Prediction time ≈ 499 µs
  • Total ≈ 1434 µs

C++:

  • Training time ≈ 1395 µs
  • Prediction time ≈ 0 µs
  • Total ≈ 1396 µs

Key Takeaways:

  • Python is faster for rapid development and iteration.
  • C++ offers stronger runtime performance for repeated large-scale deployment.
  • C++ implementation required over 500 lines of code vs ~250 in Python.
  • For production-level, high-frequency inference systems, C++ may be preferable.

Key Insights

  • Ridge regression effectively stabilized coefficients under multicollinearity.
  • Feature engineering (Power = V × A) was critical for performance gains.
  • Efficiency and battery type were strong predictors.
  • Proper scaling and λ tuning significantly improved generalization.
  • Regularization preserved interpretability while improving robustness.