As the global focus on clean energy intensifies, electric cars have emerged as a pivotal solution to address environmental and energy challenges. In China, the rapid adoption of China EV has significantly transformed the transportation landscape, leading to a surge in charging demand. Accurate forecasting of electric car charging load is crucial for ensuring grid stability, optimizing resource allocation, and integrating renewable energy sources. However, the inherent variability and spatiotemporal complexity of charging behaviors pose significant challenges for ultra-short-term load prediction. Traditional methods often fail to capture the multidimensional influences and long-term dependencies in time-series data, necessitating advanced approaches that leverage deep learning and data analytics.
In this study, I propose a novel framework that combines clustering-based scenario analysis with an enhanced deep learning model to improve forecasting accuracy. By analyzing historical charging data from electric cars in urban areas like those in China EV deployments, I identify distinct charging patterns and build scenario-specific models. The core of my method integrates the Transformer architecture with Long Short-Term Memory (LSTM) networks, termed TransLSTM, to capture both global feature interactions and temporal dependencies. This approach not only addresses the limitations of existing models but also provides a scalable solution for real-time grid management. Through extensive experiments using real-world datasets, I demonstrate the superiority of my method across multiple time horizons and input configurations.

The proliferation of electric cars worldwide, particularly in regions like China EV markets, has underscored the need for efficient charging infrastructure. Charging load forecasting is essential for grid operators to balance supply and demand, especially with the intermittent nature of renewable energy sources. Ultra-short-term forecasting, which predicts load over intervals such as 15 minutes to 4 hours, enables dynamic responses to fluctuating demand. However, electric car charging behavior is influenced by various factors, including user habits, weather conditions, and temporal patterns. For instance, in China EV scenarios, charging peaks often align with commuting hours, reflecting the urban mobility trends. Traditional forecasting models, such as autoregressive methods or basic machine learning algorithms, struggle to model these complex interactions due to their inability to handle long-range dependencies and multidimensional inputs.
To overcome these limitations, I employ a two-stage methodology: scenario-based analysis using clustering and a customized TransLSTM model for prediction. First, I apply K-means clustering to categorize charging stations into distinct scenarios based on their usage patterns. This allows me to model the unique characteristics of different electric car charging environments, such as residential areas, workplaces, and high-traffic zones. Second, I develop the TransLSTM model, which combines the self-attention mechanism of Transformer with the sequential modeling capabilities of LSTM. This hybrid design enables the model to efficiently process multiple input features—like historical load, humidity, wind speed, and wind direction—while capturing their temporal relationships. The integration of these components results in a robust forecasting framework tailored for the dynamic nature of China EV charging load.
In the following sections, I detail the scenario analysis process, describe the TransLSTM architecture, and present experimental results that validate the method’s effectiveness. I also discuss the implications of my findings for grid operators and future research in electric car load forecasting.
Scenario-Based Analysis Using Clustering
To better understand the spatiotemporal characteristics of electric car charging load, I begin with a scenario-based analysis using clustering techniques. This approach groups charging stations into categories based on their daily usage patterns, which are influenced by factors like urban mobility and user behavior in China EV contexts. By identifying these scenarios, I can build specialized forecasting models that account for the unique demand profiles of each group.
I use the K-means clustering algorithm, which partitions data into K clusters by minimizing the within-cluster variance. The algorithm iteratively assigns data points to the nearest cluster centroid and updates the centroids until convergence. For electric car charging data, I define the input features as the proportion of charging records during three time periods: night (22:00–06:00), midday (11:00–15:00), and other times (06:00–11:00 and 15:00–22:00). This temporal division reflects common commuting patterns observed in China EV studies, where charging demand peaks during rush hours.
The clustering process involves the following steps. First, I determine the optimal number of clusters using the elbow method, which identifies the point where the rate of decrease in the sum of squared distances slows down. Based on this, I set K=4. Next, I apply K-means to the charging record proportions, resulting in four distinct clusters. Each cluster represents a different charging scenario:
- Cluster 1: Low-Frequency Usage Scenario – This group includes charging stations with minimal activity across all periods, often located in remote areas or private residences. These stations exhibit sporadic usage, making them challenging to predict with standard models.
- Cluster 2: Workplace Scenario – Characterized by high midday charging and low night activity, this cluster aligns with electric car charging at office locations. Users typically charge their vehicles during work hours, leading to consistent daytime demand peaks.
- Cluster 3: Residential Scenario – This cluster shows high night charging and low daytime usage, corresponding to home charging habits. In China EV contexts, this pattern is common in residential areas where users charge their electric cars overnight.
- Cluster 4: High-Traffic Scenario – Stations in this cluster have high charging activity throughout the day, often found in commercial centers or transportation hubs. These locations experience continuous demand due to high footfall.
The clustering results provide a foundation for scenario-specific forecasting. By treating each cluster as a separate scenario, I can tailor the prediction models to capture the inherent patterns, thereby improving overall accuracy for electric car load forecasting.
TransLSTM Model Architecture
For forecasting electric car charging load, I propose the TransLSTM model, which integrates the Transformer encoder with an LSTM-based decoder. This design leverages the strengths of both architectures: the self-attention mechanism in Transformer captures global dependencies among input features, while LSTM handles long-term temporal sequences. The model is particularly suited for China EV data, where multiple factors like weather and time-of-day influence charging behavior.
The TransLSTM model consists of two main components: an encoder that processes multidimensional input sequences and a decoder that generates predictions using LSTM units. Below, I describe each part in detail, including the mathematical formulations.
Encoder with Multidimensional Inputs
The encoder takes a sequence of input features, such as historical charging load, humidity, wind speed, and wind direction, which are relevant for electric car forecasting. To incorporate temporal information, I apply positional encoding to the input sequence. The input at time step t is represented as a vector \(\mathbf{X}_t\), which is combined with a positional encoding vector \(\mathbf{P}_t\) to form the enhanced input \(\mathbf{X’}_t = \mathbf{X}_t + \mathbf{P}_t\).
The encoder uses multi-head self-attention to compute weighted sums of the input features. For each attention head, the queries (\(\mathbf{Q}\)), keys (\(\mathbf{K}\)), and values (\(\mathbf{V}\)) are derived through linear transformations:
$$
\mathbf{Q} = \mathbf{X’} \mathbf{W}_q, \quad \mathbf{K} = \mathbf{X’} \mathbf{W}_k, \quad \mathbf{V} = \mathbf{X’} \mathbf{W}_v
$$
where \(\mathbf{W}_q\), \(\mathbf{W}_k\), and \(\mathbf{W}_v\) are learnable weight matrices. The attention output is calculated as:
$$
\text{Attention}(\mathbf{Q}, \mathbf{K}, \mathbf{V}) = \text{softmax}\left(\frac{\mathbf{Q} \mathbf{K}^T}{\sqrt{d_k}}\right) \mathbf{V}
$$
where \(d_k\) is the dimension of the key vectors. The multi-head attention combines outputs from multiple heads, followed by layer normalization and a feed-forward network with ReLU activation. The final encoder output \(\mathbf{h}_{\text{Encoder}}\) is obtained after residual connections and normalization, capturing the global context of the input features for electric car load prediction.
Decoder with LSTM Units
The decoder utilizes LSTM cells to model the temporal dependencies in the sequence. At each time step t, the encoder output \(\mathbf{h}_{\text{Encoder}}\) is combined with the previous hidden state \(\mathbf{h’}_{t-1}\) from the LSTM through a linear layer to form an aggregated state:
$$
\mathbf{h’}_{t-1} = \mathbf{W} [\mathbf{h}_{\text{Encoder}}, \mathbf{h}_{t-1}] + \mathbf{b}
$$
where \(\mathbf{W}\) and \(\mathbf{b}\) are learnable parameters. This aggregated state, along with the current input \(\mathbf{x}_t\) and previous cell state \(\mathbf{C}_{t-1}\), is fed into the LSTM unit. The LSTM operations include:
$$
\begin{aligned}
\mathbf{f}_t &= \sigma(\mathbf{W}_f [\mathbf{h’}_{t-1}, \mathbf{x}_t] + \mathbf{b}_f) \\
\mathbf{i}_t &= \sigma(\mathbf{W}_i [\mathbf{h’}_{t-1}, \mathbf{x}_t] + \mathbf{b}_i) \\
\tilde{\mathbf{C}}_t &= \tanh(\mathbf{W}_C [\mathbf{h’}_{t-1}, \mathbf{x}_t] + \mathbf{b}_C) \\
\mathbf{C}_t &= \mathbf{f}_t \odot \mathbf{C}_{t-1} + \mathbf{i}_t \odot \tilde{\mathbf{C}}_t \\
\mathbf{o}_t &= \sigma(\mathbf{W}_o [\mathbf{h’}_{t-1}, \mathbf{x}_t] + \mathbf{b}_o) \\
\mathbf{h}_t &= \mathbf{o}_t \odot \tanh(\mathbf{C}_t)
\end{aligned}
$$
where \(\mathbf{f}_t\), \(\mathbf{i}_t\), and \(\mathbf{o}_t\) are the forget, input, and output gates, respectively; \(\sigma\) is the sigmoid function; and \(\odot\) denotes element-wise multiplication. The hidden state \(\mathbf{h}_t\) is then passed through a linear layer to produce the prediction output \(\mathbf{O}_t\). This decoder design ensures that the model captures both short-term and long-term patterns in electric car charging data, which is vital for China EV applications where demand fluctuates rapidly.
Experimental Setup and Data Description
To evaluate my method, I use a real-world dataset from Shijiazhuang City, which includes charging records from 22,488 electric car charging stations over a period from January 1 to July 12, 2023. The data comprises multiple features sampled at 15-minute intervals, resulting in 96 time points per day. The features include charging load (in kW), temperature, humidity, wind speed, wind direction, and rainfall. This dataset reflects typical China EV charging behaviors in an urban environment.
I preprocess the data by normalizing the numerical features and encoding categorical variables. For the scenario analysis, I compute the daily charging record proportions for each station and apply K-means clustering with K=4, as described earlier. The clusters are used to define four scenarios: low-frequency, workplace, residential, and high-traffic. For each scenario, I train a separate TransLSTM model.
The model parameters are optimized through grid search. The encoder has 6 layers with 4 attention heads and a dropout rate of 0.1. The decoder uses a 2-layer LSTM with a hidden dimension of 4 and 2 linear layers. I use the Adam optimizer with a learning rate of 0.001 and a batch size of 32. The forecasting task is performed in a step-by-step manner, where the model predicts one time step at a time and uses the prediction as input for subsequent steps. This approach is suitable for ultra-short-term forecasting of electric car load, as it allows real-time updates.
I compare my TransLSTM model against baseline models, including standard Transformer and LSTM, as well as a scenario-enhanced LSTM (Scenario-LSTM). The evaluation metrics include Mean Squared Error (MSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and R-squared (R²), defined as:
$$
\begin{aligned}
\text{MSE} &= \frac{1}{n} \sum_{t=1}^{n} (A_t – F_t)^2 \\
\text{MAE} &= \frac{1}{n} \sum_{t=1}^{n} |A_t – F_t| \\
\text{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}
\end{aligned}
$$
where \(A_t\) is the actual load, \(F_t\) is the forecasted load, \(\bar{A}\) is the mean actual load, and n is the number of data points. Lower MSE, MAE, and MAPE values indicate better accuracy, while R² closer to 1 signifies a better fit.
I also analyze the correlation between input features and charging load using Pearson and Spearman methods. The results show that humidity, wind speed, and wind direction have moderate correlations with load, whereas temperature and rainfall have negligible effects. Therefore, I use load, humidity, wind speed, and wind direction as the input features for the models, ensuring that the TransLSTM model leverages the most relevant factors for electric car forecasting.
Results and Discussion
I conduct experiments for three forecasting horizons: 15 minutes (1 step), 1 hour (4 steps), and 4 hours (16 steps). The results demonstrate the effectiveness of my scenario-based TransLSTM approach compared to other models. Below, I summarize the key findings using tables and analysis.
First, I evaluate the impact of input features on forecasting accuracy. Table 1 compares the performance of models using only historical load versus multiple features (load, humidity, wind speed, wind direction) for 1-hour ahead predictions. The TransLSTM model with multiple features achieves the lowest errors, highlighting the importance of incorporating weather-related factors for electric car load forecasting.
| Input Scheme | Model | MSE (kW) | MAE (kW) | R² |
|---|---|---|---|---|
| Single Feature (Load) | 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 | |
| Multiple Features | 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 |
As shown, the Scenario-TransLSTM model with multiple features reduces MSE by 52.17% and MAE by 28.63% compared to the single-feature case, underscoring the value of multidimensional inputs for China EV applications.
Next, I compare the models across different forecasting horizons. Table 2 presents the evaluation metrics for 15-minute, 1-hour, and 4-hour ahead predictions. The Scenario-TransLSTM model consistently outperforms others, with the highest R² and lowest errors in all cases.
| Forecast Horizon | Model | MSE (kW) | MAE (kW) | MAPE (%) | R² |
|---|---|---|---|---|---|
| 15 Minutes | 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 Hour | 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 Hours | 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 |
For instance, in 1-hour ahead forecasting, Scenario-TransLSTM reduces MSE by 38.8% compared to Transformer and by 25.0% compared to LSTM. Similarly, MAE improvements are 31.7% and 17.5%, respectively. The scenario-based analysis alone enhances performance; Scenario-LSTM shows an 18.5% MSE reduction over LSTM for 15-minute predictions. These results validate that clustering electric car charging data into scenarios and using the TransLSTM model significantly boosts forecasting accuracy, especially for China EV datasets with diverse usage patterns.
Furthermore, the TransLSTM model’s ability to handle multiple features and long sequences makes it suitable for real-time applications. The attention mechanism effectively captures interactions between variables like humidity and wind speed, which influence electric car charging behavior. For example, higher humidity might correlate with increased indoor activities, affecting charging demand in residential scenarios. By modeling these relationships, TransLSTM provides more reliable predictions, aiding grid operators in managing the integration of China EV loads.
Conclusion
In this study, I have developed a comprehensive framework for electric car charging load forecasting that combines scenario-based clustering with an advanced TransLSTM model. The method addresses the spatiotemporal complexities of China EV charging data by identifying distinct usage scenarios and leveraging a hybrid deep learning architecture. My experiments demonstrate that the Scenario-TransLSTM approach achieves superior accuracy across multiple time horizons, outperforming traditional models like Transformer and LSTM.
The key contributions of this work include the integration of clustering for scenario analysis, which allows for tailored modeling of different electric car charging environments, and the novel TransLSTM design, which combines self-attention with LSTM to capture both feature interactions and temporal dependencies. The use of multidimensional inputs, such as weather data, further enhances forecasting precision, providing practical insights for grid management in rapidly growing China EV markets.
For future research, I plan to explore larger datasets and more complex model architectures to handle the scalability of electric car adoption. Additionally, incorporating real-time data streams and adaptive clustering could improve the framework’s responsiveness to dynamic changes in charging behavior. This work lays a foundation for more intelligent and efficient electric car load forecasting, ultimately supporting the sustainable integration of electric vehicles into power systems worldwide.