With the rapid adoption of electric vehicles globally, accurately predicting their charging load has become crucial for grid stability and energy management. In this paper, we propose a novel method that combines clustering algorithms and deep learning techniques to analyze and forecast electric vehicle charging load under multiple scenarios. Our approach leverages the temporal and spatial characteristics of charging data to enhance prediction accuracy, particularly for ultra-short-term horizons. We begin by clustering charging stations based on usage patterns derived from resident travel habits, identifying distinct scenarios such as residential, workplace, and high-traffic areas. Subsequently, we develop a forecasting model using an improved Transformer architecture integrated with Long Short-Term Memory (LSTM) networks, referred to as TransLSTM, to capture complex dependencies in multi-dimensional input features like historical load and meteorological data. Experimental results on real-world datasets from China EV charging stations demonstrate the effectiveness of our method, with significant improvements in metrics such as Mean Squared Error (MSE) and R-squared across different time scales. This work provides a robust framework for supporting grid operations and promoting the integration of renewable energy in the context of electric vehicle expansion.
The proliferation of electric vehicles represents a pivotal shift toward sustainable transportation, driven by global efforts to reduce carbon emissions and combat climate change. In China, the electric vehicle market has experienced exponential growth, necessitating advanced methods to manage the associated charging load. Accurate forecasting of this load is essential for grid operators to balance supply and demand, optimize resource allocation, and prevent overloading. Traditional forecasting methods often struggle with the inherent variability and multi-faceted influences on electric vehicle charging behavior, such as user habits, weather conditions, and temporal patterns. Our research addresses these challenges by introducing a scenario-based analysis that categorizes charging stations into meaningful groups, followed by a deep learning model that excels in capturing both global and temporal dependencies. By focusing on ultra-short-term predictions, we enable real-time responses to fluctuating demands, which is critical for modern smart grids. This paper details our methodology, including data clustering, model architecture, and experimental validation, highlighting the synergy between clustering techniques and advanced neural networks for electric vehicle load forecasting.
In recent years, numerous studies have explored electric vehicle charging load prediction using statistical and machine learning approaches. Probability-based models often incorporate spatial-temporal factors like traffic flow and charging infrastructure layout, but they may lack precision in short-term forecasts. Machine learning methods, particularly those based on recurrent neural networks (RNNs) and Long Short-Term Memory (LSTM), have shown promise in handling time-series data. However, they can be limited in capturing long-range dependencies and interactions among multiple input features. The Transformer model, with its self-attention mechanism, has emerged as a powerful alternative for sequence modeling, but it may not fully leverage temporal relationships in electric vehicle load data. Our work builds on these foundations by integrating LSTM into the Transformer framework, creating a hybrid model that combines the strengths of both. Additionally, we employ clustering to define scenarios that reflect real-world usage patterns, such as those observed in China EV deployments, where charging behavior varies significantly across urban functional zones. This scenario-based approach allows for more tailored and accurate predictions, as each model is optimized for specific charging contexts.
Our methodology consists of two main phases: scenario-based analysis using clustering and the development of the TransLSTM forecasting model. In the first phase, we collect historical charging load data from electric vehicle stations and apply the K-means clustering algorithm to group them based on daily charging patterns. We define three time segments—night (22:00–06:00), midday (11:00–15:00), and other periods—to capture typical usage peaks. The clustering results reveal four distinct scenarios: low-frequency usage, workplace charging, residential charging, and high-traffic area charging. Each scenario corresponds to different user behaviors; for instance, residential charging peaks at night, while workplace charging is dominant during midday. This segmentation enables us to model the charging load more accurately by accounting for spatial and temporal variations specific to electric vehicle operations in China.
In the second phase, we design the TransLSTM model, which enhances the standard Transformer by incorporating LSTM units in the decoder. The encoder part of the Transformer uses self-attention to process multi-dimensional input features, including historical charging load, humidity, wind speed, and wind direction. These features are selected based on correlation analyses, such as Pearson and Spearman tests, which indicate significant relationships with electric vehicle load. The self-attention mechanism computes weighted sums of input sequences, allowing the model to focus on relevant features across different time steps. Mathematically, for an input sequence $X$, we compute queries, keys, and values as follows:
$$Q = W_q \cdot X, \quad K = W_k \cdot X, \quad V = W_v \cdot X$$
where $W_q$, $W_k$, and $W_v$ are learnable weight matrices. The attention output is then given by:
$$\text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right) V$$
where $d_k$ is the dimension of the key vectors. This is extended to multi-head attention to capture diverse aspects of the input. The encoder outputs a sequence of hidden states that encapsulate global context, which are then passed to the LSTM-based decoder. The LSTM component handles temporal dependencies by updating its cell state and hidden state through gating mechanisms. For each time step $t$, the LSTM operations can be expressed as:
$$f_t = \sigma(W_f \cdot [h_{t-1}, x_t] + b_f)$$
$$i_t = \sigma(W_i \cdot [h_{t-1}, x_t] + b_i)$$
$$\tilde{C}_t = \tanh(W_C \cdot [h_{t-1}, x_t] + b_C)$$
$$C_t = f_t \cdot C_{t-1} + i_t \cdot \tilde{C}_t$$
$$o_t = \sigma(W_o \cdot [h_{t-1}, x_t] + b_o)$$
$$h_t = o_t \cdot \tanh(C_t)$$
where $f_t$, $i_t$, and $o_t$ are the forget, input, and output gates, respectively; $C_t$ is the cell state; $h_t$ is the hidden state; and $\sigma$ denotes the sigmoid function. The decoder uses these states to generate predictions, with a linear layer producing the final output. This combination allows the TransLSTM model to effectively model both feature interactions and long-term temporal patterns in electric vehicle charging data.
For our experiments, we utilize a dataset from Shijiazhuang City, China, comprising charging records from 22,488 electric vehicle stations over a period from January 1 to July 12, 2023. The data includes features such as charging load, temperature, humidity, wind speed, wind direction, and rainfall, sampled at 15-minute intervals. We preprocess the data by normalizing the features and splitting it into training, validation, and test sets. The clustering phase identifies the four scenarios, and for each, we train a separate TransLSTM model. We compare our method against baseline models like standard Transformer and LSTM, as well as a scenario-based LSTM variant (Scenario-LSTM). The models are evaluated using step-by-step prediction for ultra-short-term horizons: 15 minutes, 1 hour, and 4 hours. Key hyperparameters for TransLSTM include 6 encoder layers, 4 attention heads, a dropout rate of 0.1, and 2 LSTM layers, optimized via grid search. The Adam optimizer with a learning rate of 0.001 is used for training, with a batch size of 32.

The evaluation metrics include Mean Squared Error (MSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and R-squared (R²). The formulas for these metrics are as follows:
$$MSE = \frac{1}{n} \sum_{t=1}^{n} (A_t – F_t)^2$$
$$MAE = \frac{1}{n} \sum_{t=1}^{n} |A_t – F_t|$$
$$MAPE = \frac{100\%}{n} \sum_{t=1}^{n} \left| \frac{A_t – F_t}{A_t} \right|$$
$$R^2 = 1 – \frac{\sum_{t=1}^{n} (A_t – F_t)^2}{\sum_{t=1}^{n} (A_t – \bar{A})^2}$$
where $A_t$ is the actual value, $F_t$ is the forecasted value, $\bar{A}$ is the mean of actual values, and $n$ is the number of data points. Lower values of MSE, MAE, and MAPE indicate better accuracy, while R² closer to 1 signifies a better fit.
We first examine the impact of input features on prediction performance. Correlation analyses show that charging load has significant relationships with humidity, wind speed, and wind direction, but weak correlations with temperature and rainfall. Therefore, we use a multi-feature input comprising load, humidity, wind speed, and wind direction. Table 1 compares the prediction results for single-feature (load only) and multi-feature inputs over a 1-hour horizon. The multi-feature approach consistently outperforms the single-feature one across all models, with Scenario-TransLSTM achieving the lowest MSE and highest R². For instance, Scenario-TransLSTM with multi-feature input reduces MSE by 52.17% compared to single-feature input, demonstrating the importance of incorporating relevant meteorological factors in electric vehicle load forecasting.
| Input Scheme | Model | MSE (kW) | MAE (kW) | R² |
|---|---|---|---|---|
| Single Power Input | Transformer | 0.00342 | 0.0372 | 0.822 |
| LSTM | 0.00299 | 0.0301 | 0.837 | |
| TransLSTM | 0.00243 | 0.0272 | 0.869 | |
| Scenario-LSTM | 0.00231 | 0.0265 | 0.872 | |
| Scenario-TransLSTM | 0.00189 | 0.0241 | 0.898 | |
| Power + Humidity + Wind Speed + Wind Direction | Transformer | 0.00211 | 0.0569 | 0.836 |
| LSTM | 0.00172 | 0.0388 | 0.897 | |
| TransLSTM | 0.00129 | 0.0320 | 0.908 | |
| Scenario-LSTM | 0.00108 | 0.0289 | 0.931 | |
| Scenario-TransLSTM | 0.000904 | 0.0172 | 0.955 |
Next, we evaluate the forecasting performance across different time scales. Table 2 summarizes the results for 15-minute, 1-hour, and 4-hour predictions. The Scenario-TransLSTM model consistently achieves the best performance in all metrics. For example, in the 1-hour forecast, Scenario-TransLSTM reduces MSE by 38.8% compared to Transformer and 25.0% compared to LSTM. Similarly, MAE improvements are 31.7% and 17.5%, respectively. The scenario-based analysis alone provides significant gains; Scenario-LSTM outperforms LSTM by 18.5% in MSE for 15-minute predictions. These results underscore the value of combining clustering with advanced deep learning for electric vehicle load forecasting, particularly in handling the variability of China EV charging patterns.
| Forecast Horizon | Model | MSE (kW) | MAE (kW) | MAPE (%) | R² |
|---|---|---|---|---|---|
| 15 min | Transformer | 0.00107 | 0.0198 | 8.98 | 0.941 |
| LSTM | 0.000691 | 0.0179 | 8.34 | 0.958 | |
| TransLSTM | 0.000570 | 0.0151 | 7.48 | 0.972 | |
| Scenario-LSTM | 0.000563 | 0.0155 | 6.12 | 0.989 | |
| Scenario-TransLSTM | 0.000526 | 0.0137 | 6.36 | 0.992 | |
| 1 h | Transformer | 0.00211 | 0.0469 | 15.2 | 0.836 |
| LSTM | 0.00172 | 0.0388 | 14.6 | 0.897 | |
| TransLSTM | 0.00129 | 0.0320 | 12.5 | 0.908 | |
| Scenario-LSTM | 0.00108 | 0.0289 | 11.3 | 0.931 | |
| Scenario-TransLSTM | 0.000904 | 0.0172 | 8.34 | 0.955 | |
| 4 h | Transformer | 0.0136 | 0.1127 | 17.21 | 0.614 |
| LSTM | 0.0115 | 0.0991 | 15.97 | 0.679 | |
| TransLSTM | 0.00944 | 0.0914 | 15.44 | 0.701 | |
| Scenario-LSTM | 0.00873 | 0.0860 | 14.23 | 0.733 | |
| Scenario-TransLSTM | 0.00670 | 0.0753 | 13.91 | 0.752 |
The superiority of Scenario-TransLSTM is further illustrated by the prediction curves, which show closer alignment with actual load values compared to other models. For instance, in the 1-hour forecasts, the curve for Scenario-TransLSTM smoothly follows the actual load fluctuations, while baseline models exhibit larger deviations. This accuracy is attributed to the model’s ability to leverage scenario-specific patterns and multi-feature interactions. The self-attention mechanism in Transformer effectively captures relationships among input features, such as how humidity and wind speed influence electric vehicle charging demand, while the LSTM component ensures robust temporal modeling. Moreover, the clustering step allows for customized models that account for regional variations in China EV usage, such as higher nighttime charging in residential areas and midday peaks in commercial zones.
In conclusion, our proposed method demonstrates significant advancements in electric vehicle charging load forecasting by integrating scenario-based clustering with the TransLSTM model. The clustering analysis effectively categorizes charging stations into meaningful scenarios, reflecting real-world user behaviors in China EV contexts. The TransLSTM model combines the global dependency capture of Transformer with the temporal modeling of LSTM, resulting in high-precision predictions across ultra-short-term horizons. Experimental results confirm that our approach outperforms existing methods in terms of MSE, MAE, MAPE, and R², making it a valuable tool for grid management and energy planning. Future work could explore larger datasets and deeper neural architectures to further enhance prediction accuracy and scalability. As the adoption of electric vehicles continues to grow, such forecasting methods will play a vital role in ensuring grid reliability and promoting sustainable energy integration.