EV Charging Demand Prediction: A Session-Based Analysis Using Machine Learning

The widespread adoption of battery-powered electric vehicles (battery EV cars) is pivotal for the transition to sustainable transportation. However, their integration into the existing power grid presents significant challenges for utility management, infrastructure planning, and grid stability. Unlike traditional loads, the charging demand of a battery EV car is highly stochastic, influenced by complex user behavior, vehicle battery characteristics, and the availability of charging infrastructure. Accurate forecasting of this demand, particularly at the granularity of an individual charging session, is therefore crucial for efficient grid operation, optimal charging station deployment, and providing reliable service to users.

While aggregate daily or hourly demand forecasts are valuable for long-term planning, real-time grid dispatch and stability management require predictions at the session level. Once a battery EV car connects to a charger, the grid operator must anticipate the energy that will be drawn over the coming hours. This study focuses on predicting this very quantity: the energy demand of a single plug-in electric vehicle charging session immediately after it commences. We leverage a rich dataset from public charging stations and apply advanced machine learning regression techniques to model and forecast this demand based on user history and session characteristics.

The core challenge lies in the inherent variability of user behavior. Different users of battery EV cars have diverse driving patterns, battery states of charge upon arrival, and time constraints. Our hypothesis is that a user’s past charging behavior is the most significant indicator of their future demand. By constructing a feature set that captures historical patterns, temporal context, and station attributes, we aim to build a predictive model that can reliably estimate the session energy (Es) for a battery EV car. The general predictive function can be formulated as:

$$E_s = f(L_c, T_s, T_d, S_s, D_w, F_s, P_n, E_{smean}, E_{smax}, E_{smin}, U_{sc}, D_{uc})$$

Where the input variables encompass location category (Lc), temporal features (sequential time Ts, time of day Td, season Ss, day of week Dw), fee policy (Fs), port ID (Pn), and user historical statistics (mean Esmean, max Esmax, min Esmin historical energy, user session count Usc, and days since last session Duc).

Data Description and Exploratory Analysis

The analysis is based on a comprehensive dataset collected from public Level 2 charging stations in a major metropolitan area over seven years, from January 2017 to December 2023. The dataset comprises over 27,000 individual charging sessions, each record containing detailed information such as session start/end timestamps, connection duration, energy delivered (kWh), a unique anonymized user ID, and station/port identifiers.

The evolution of station usage, summarized in the table below, clearly shows the rapid growth in the adoption of battery EV cars. The number of unique users, total charging sessions, and overall energy demand have increased by orders of magnitude.

Year Cumulative Ports Unique Users Charging Sessions Total Energy (MWh)
2017 10 20 552 3.4
2018 18 45 947 4.9
2019 32 97 1822 14.2
2020 70 211 2825 23.9
2021 78 431 4692 34.8
2022 90 787 7389 61.2
2023 97 1118 9254 106.1

A critical step in preparing data for predicting battery EV car charging demand was cleaning and filtering. Sessions with extremely low energy delivery (below the 8.5th percentile) were removed as they likely represented brief connection tests or errors. Furthermore, to ensure meaningful historical features, we retained only users with more than 10 recorded charging sessions. This process resulted in a refined dataset of 22,231 sessions for model development. The distribution of energy per session in this final dataset is highly right-skewed, with a majority of sessions demanding less than 20 kWh, but a long tail extending beyond 50 kWh, indicative of the varying battery sizes and depletion levels among different battery EV car models.

Predictive Modeling Framework and Methodology

The objective is to approximate the function f that maps the 12 input variables to the session energy output. We frame this as a supervised regression problem. The overall framework involves data segmentation, model training with hyperparameter tuning on a validation set, and final evaluation on a held-out test set. To ensure a realistic evaluation of a model’s ability to generalize to future behavior of both existing and new users of battery EV cars, the dataset was split sequentially by time into training (13,115 sessions), validation (4,405 sessions), and test (4,483 sessions) sets. The statistical characteristics of the energy demand in these sets are shown below:

Dataset Min (kWh) 1st Qu. (kWh) Median (kWh) Mean (kWh) 3rd Qu. (kWh) Max (kWh)
Training Set 0.001 4.287 6.822 9.245 12.072 100.530
Validation Set 0.001 4.476 7.346 10.076 13.176 103.118
Test Set 0.001 4.984 8.765 10.950 14.736 100.388

We implemented and compared three robust machine learning algorithms known for their effectiveness in regression tasks, along with a baseline linear regression model. For battery EV car charging prediction, the models were:

  1. Linear Regression (LR): A baseline model assuming a linear relationship between all features and the target.
  2. eXtreme Gradient Boosting (XGBoost): An efficient and scalable implementation of gradient boosting that often delivers state-of-the-art results.
  3. Random Forest (RF): An ensemble method that builds multiple decision trees and merges their predictions.
  4. Support Vector Machine (SVM) with Linear Kernel: A method that finds the optimal hyperplane for regression in a high-dimensional space.

The hyperparameters for each model were carefully tuned using the validation set to optimize performance. The final chosen parameters are listed below:

Model Key Tuned Parameters
XGBoost learning rate (eta)=0.1, max depth=2, n rounds=104, gamma=0, colsample_bytree=0.5, min_child_weight=1
Random Forest mtry=2, ntree=1000, node size=20
SVM (Linear) Cost (C)=1

Model performance was rigorously evaluated using standard regression metrics on the unseen test set. The metrics used were:

  • Coefficient of Determination (R²): Measures the proportion of variance in the target variable that is predictable from the features.
    $$R^2 = 1 – \frac{RSS}{TSS} = 1 – \frac{\sum_{i=1}^{n} (y_i – \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i – \bar{y})^2}$$
  • Root Mean Square Error (RMSE): The square root of the average squared differences between prediction and observation. It is sensitive to large errors.
    $$RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (\hat{y}_i – y_i)^2}$$
  • Mean Absolute Error (MAE): The average of the absolute differences. It provides a more robust measure of typical error magnitude.
    $$MAE = \frac{1}{n} \sum_{i=1}^{n} |y_i – \hat{y}_i|$$

In these equations, $y_i$ is the observed energy demand for a battery EV car session, $\hat{y}_i$ is the predicted demand, $\bar{y}$ is the mean observed demand, and $n$ is the number of sessions in the test set.

Results and Comparative Analysis

The predictive performance of all four models on the test set is summarized in the following table. The results clearly indicate that the XGBoost algorithm achieved the best overall performance for forecasting the energy demand of a battery EV car charging session.

Model R² MAE (kWh) RMSE (kWh)
Linear Regression 0.484 4.65 6.92
XGBoost 0.519 4.57 6.68
Random Forest 0.476 4.87 6.97
SVM (Linear) 0.444 4.64 7.18

With an R² value of 0.519, the XGBoost model explains approximately 52% of the variance in session energy demand. The MAE of 4.57 kWh and RMSE of 6.68 kWh must be interpreted relative to the test set’s mean demand of 10.95 kWh. The MAE indicates that the average prediction error is about 42% of the mean session energy. The fact that the RMSE is notably higher than the MAE suggests the presence of some sessions with large prediction errors, which is expected given the diverse behavior of battery EV car users.

A crucial analysis involves understanding which features drive the predictions. The variable importance analysis, consistent across all models, reveals a dominant pattern: the user’s historical average charging energy ($E_{smean}$) is by far the most significant predictor. This finding strongly supports the core hypothesis that an individual’s past behavior is the primary indicator of their future demand when they plug in their battery EV car. The user’s historical maximum energy ($E_{smax}$) is typically the second most important feature. The relative importance of other features, such as the time since the last session ($D_{uc}$) or the time of day ($T_d$), is considerably lower and varies between models. This suggests that while habitual patterns are key, temporal context provides secondary, modulating information.

The analysis of prediction residuals (error = predicted – observed) organized by user and time reveals another critical insight. While the XGBoost model performs well for the majority of battery EV car users, a small subset (approximately 7% of sessions) exhibits significantly larger errors. These users likely have more volatile charging patterns or insufficient historical data for the model to establish a reliable pattern. If this group is excluded post-hoc, the prediction accuracy for the remaining 93% of sessions improves markedly (R² ≈ 0.610, MAE ≈ 4.19 kWh), highlighting that the overall model performance is dragged down by a minority of hard-to-predict users. In practice, identifying these users a priori is challenging, as their behavior cannot be easily distinguished from their available features at the start of a session.

Discussion and Implications for Grid Management

The study demonstrates that it is feasible to predict the energy demand of a battery EV car at the start of a charging session with reasonable accuracy using machine learning models trained on historical user data. The achieved R² of around 0.52 signifies that about half of the variance in session demand can be explained by the constructed feature set. The remaining unexplained variance is attributable to the intrinsic randomness in user behavior, factors not captured in the data (e.g., the specific state-of-charge of the battery EV car upon arrival, the driver’s immediate travel plans), and potential measurement noise.

The supremacy of user historical average demand as a predictor has profound implications. It underscores that charging behavior is highly personalized. Therefore, models that aggregate demand purely by time or location, without user identity, will miss this critical source of predictive information. For grid operators, this means that leveraging anonymized user history data from charging networks can significantly enhance short-term load forecasting accuracy compared to traditional methods.

From a grid stability and dispatch perspective, accurate session-level prediction is more valuable than aggregate daily forecasts. Knowing that a specific battery EV car will draw 15 kWh over the next 3 hours, rather than just knowing that a station will serve 200 kWh today, allows for much finer real-time control. This enables:

  • Improved Congestion Management: Anticipating high-demand sessions at specific transformers or feeders allows operators to proactively manage load via scheduling or gentle incentives.
  • Enhanced Renewable Integration: Session forecasts can be used to align battery EV car charging with periods of high renewable generation (e.g., sunny or windy periods), turning a potential grid stressor into a flexible demand-side resource.
  • Infrastructure Planning: Identifying users or locations with consistently high or growing energy demand per session helps prioritize infrastructure upgrades for stations serving newer generations of battery EV cars with larger batteries.

The limitations of this work point to valuable directions for future research. The model’s performance is constrained by data availability. Incorporating additional features could improve accuracy. For example, integrating data on the specific model of the battery EV car (and thus its battery capacity) would be highly informative. Furthermore, contextual urban data, such as points-of-interest around the charging station, local traffic flow, or even weather conditions, might help explain some of the residual variance. Exploring more complex model architectures, such as deep neural networks or models that explicitly handle sequential user data (e.g., LSTMs), could also yield improvements, albeit at the cost of increased computational complexity and reduced model interpretability.

Conclusion

In this research, I developed and evaluated a data-driven framework for predicting the charging energy demand of individual plug-in electric vehicle sessions. Utilizing a seven-year dataset from public charging infrastructure, I demonstrated that machine learning models, particularly XGBoost, can effectively forecast session-level demand based on user historical behavior and session context. The key finding is that the past charging average of a user is the most powerful predictor for their future demand when they connect their battery EV car. This emphasizes the personalized nature of electric vehicle charging behavior.

While significant unexplained variance remains due to behavioral randomness, the achieved level of accuracy provides a substantial information advantage for grid operators over traditional aggregate forecasting methods. The ability to predict the load of a newly started charging session in real-time is a critical tool for managing the low-voltage distribution network, optimizing energy dispatch, and facilitating the integration of intermittent renewable resources. As the penetration of battery EV cars continues to grow, session-level demand prediction will become an indispensable component of smart grid management, helping to ensure that the electrification of transportation proceeds reliably and efficiently.

Scroll to Top