Data-Driven Fault Detection and Diagnosis for Electric Vehicle Batteries

Electric vehicles have become a central pillar in the global transition toward sustainable transportation. In my research, I focus on one of the most critical components of the electric vehicle battery system, namely the traction battery, whose safety and reliability directly determine the overall performance and user acceptance of electric vehicles. Despite the rapid growth of the electric vehicle market, battery-related fires and failures remain a major concern. Many accidents are caused by thermal runaway, internal short circuits, overcharging, and other faults that are difficult to detect in advance. Therefore, developing accurate and early fault detection and diagnosis methods for the electric vehicle battery is of paramount importance.

From a data-driven perspective, I identify two major challenges that hinder the effectiveness of current diagnostic systems. The first challenge lies in the data layer: real-world vehicle data are often highly imbalanced, with fault samples being extremely rare compared to normal operation samples. In addition, the raw alarms are noisy, incomplete, and sometimes contradictory, requiring systematic reconstruction. The second challenge lies in the modeling layer: a single prediction model often exhibits limited accuracy and generalization capability when facing complex, high-dimensional, and nonlinear battery data. To address these challenges, I propose a progressive framework that integrates advanced data preprocessing, data augmentation, and ensemble learning techniques. The key contributions of my work are summarized as follows: first, I apply fault tree analysis to reconstruct the fault severity levels of the electric vehicle battery, ensuring a clean and well-defined dataset; second, I introduce an improved Border-SMOTE algorithm to handle the severe class imbalance; third, I build a Stacking heterogeneous ensemble diagnostic model to improve predictive performance; finally, I adopt a WGAN-GP strategy to further augment the data and achieve near-optimal diagnostic accuracy.

1. Data Source and Preprocessing

The data used in this study were collected from real-world electric vehicles over a period of approximately six months. The data acquisition frequency is 0.1 Hz, meaning that one record is generated every ten seconds. The dataset includes more than 5.51 million records from ten vehicles. The primary fields consist of timestamp, vehicle state, charging state, vehicle speed, running mode, state of charge (SOC), cumulative mileage, insulation resistance, DC-DC status, maximum alarm level, and general alarm flags. A detailed description of the data fields is presented in Table 1.

Table 1: Main fields in the raw electric vehicle battery dataset
Field Description Value range / unit
vid Vehicle identifier String
time Data collection time yyyy-mm-dd hh:mm:ss
vehicle_state Vehicle status 1: starting, 2: off, 3: other
charging_state Charging status 1: parking charge, 2: driving charge, 3: no charge, 4: charge complete
speed Vehicle speed 0–220 km/h
mode Running mode 1: pure electric, 2: hybrid, 3: fuel
soc State of charge 0–100%
mileage Accumulated mileage 0–999999.9 km
insulation_res Insulation resistance 0–60000 KΩ
dcdc_state DC-DC converter state 1: working, 2: disconnected
max_alarm_lvl Maximum alarm level 0–3
alarm_info General alarm flag 32-bit binary flag

The raw data contain many anomalies such as duplicate records, missing values, infinite values, and time discontinuities. I first partition the continuous records into meaningful driving fragments based on vehicle state and charging state. If the two states remain unchanged and the time gap exceeds three minutes, a break is inserted. Fragments shorter than three minutes are discarded because they are statistically insignificant. Then, I remove duplicate rows that share identical values in all fields. For missing values in fields such as maximum cell voltage, minimum cell voltage, maximum temperature, and fault code lists, I apply different strategies. If a field has a large proportion of missing values, I delete it entirely; otherwise, I use forward filling to replace missing values. For infinite values, I directly delete the corresponding rows. Finally, all records are sorted chronologically to ensure temporal consistency.

2. Fault Severity Reconstruction Based on Fault Tree Analysis

After initial cleaning, I discover that the raw alarm flags are not reliable. Some alarms are delayed, some are missing, and some are falsely triggered. Moreover, many alarm flags are unrelated to the battery, such as brake system faults, high-voltage interlock faults, and motor temperature faults. To construct a clean and meaningful fault diagnosis dataset, I apply fault tree analysis (FTA) to decompose the top-level fault event into basic events using logic gates. This top-down approach helps me identify the root causes of battery faults and map them to appropriate severity levels.

According to the national standard and related literature, I redefine the alarm flags and assign each one a severity level from 0 to 3. Level 0 indicates no fault, level 1 indicates a minor fault that does not affect normal driving, level 2 indicates a moderate fault that limits vehicle performance and requires inspection, and level 3 indicates a severe fault that requires immediate stopping and maintenance. Table 2 presents the revised fault alarm definitions and their corresponding severity levels.

Table 2: Revised fault alarm standards and severity levels
Alarm flag Alarm description Alarm standard Severity level
0 Temperature difference Max-min cell temperature > 5 °C 1
1 High battery temperature Max cell temperature > 53 °C 3
2 Storage device overvoltage Total voltage above rated upper limit 3
3 SOC low SOC < 10% 1
4 Cell overvoltage Cell voltage > 4500 mV 3
5 Cell undervoltage Cell voltage < 3540 mV 2
6 SOC high SOC above predefined threshold 2
7 SOC jump SOC change > 2%/min 1
8 Cell inconsistency Voltage standard deviation > 80 mV 2
9 Insulation fault Insulation resistance < 100 Ω/V 3
10 DC-DC temperature DC-DC temperature > 85 °C 1
11 DC-DC state DC-DC disconnected while not off 2

By transforming the original decimal fault codes into binary flags and comparing them with the revised alarm criteria, I eliminate irrelevant alarms and reclassify the actual battery faults. A fixed observation window of 25 minutes (150 data points) is set to capture the trend before a fault occurs. From the normal operation data, I randomly sample the same number of records as the fault data using stratified sampling, ensuring a balanced base dataset. After this process, the final dataset contains a total of 1,339,250 normal records, 69,214 level-1 fault records, 42,838 level-2 fault records, and 44,599 level-3 fault records. The overall fault proportion becomes 10.47%, which is much more reasonable than the original ratio of approximately 1:550.

3. Feature Engineering for Electric Vehicle Battery Diagnosis

Feature engineering is a crucial step that directly influences the performance of machine learning models. In this work, I extract features from three dimensions: battery status, battery consistency, driving behavior, and time context. The battery status features include total voltage, total current, maximum temperature, temperature difference, insulation resistance, and accumulated mileage. The consistency features capture the degree of inconsistency among cells, because cell inconsistency is a major precursor of battery faults. I compute the coefficient of variation (CV) and the maximum deviation rate (DV) for both cell voltage and cell temperature. The formulas for these two indicators are defined as follows.

$$C_v = \frac{1}{\mu} \sqrt{\frac{1}{n} \sum_{m=1}^{n} (K_t^m – \mu)^2} \times 100\%$$

$$D_v = \frac{K_{t}^{\max} – K_{t}^{\min}}{\mu} \times 100\%$$

In the above equations, \(K_t^m\) represents the voltage or temperature of the \(m\)-th cell at time \(t\), \(\mu\) is the mean value, and \(K_{t}^{\max}\) and \(K_{t}^{\min}\) are the maximum and minimum values, respectively. A larger \(C_v\) or \(D_v\) indicates a worse consistency among cells.

The driving behavior features include vehicle speed and its variance, which reflect the acceleration and braking patterns of the driver. The time context features include season, whether the day is a workday, and the time-of-day segment. I also derive the date and time from the timestamp to capture cyclic patterns such as morning and night driving. After extracting an initial set of features, I perform feature selection using both the Pearson correlation coefficient and mutual information.

The Pearson correlation coefficient between two variables \(X\) and \(Y\) is computed as:

$$r_{XY} = \frac{\sum_{i=1}^{n}(X_i – \bar{X})(Y_i – \bar{Y})}{\sqrt{\sum_{i=1}^{n}(X_i – \bar{X})^2} \sqrt{\sum_{i=1}^{n}(Y_i – \bar{Y})^2}}$$

The mutual information between \(X\) and \(Y\) is defined as:

$$MI(X;Y) = \sum_{x \in X} \sum_{y \in Y} p(x,y) \log \frac{p(x,y)}{p(x)p(y)}$$

For continuous variables, I use kernel density estimation to approximate the probability distributions and then compute the mutual information. After ranking all candidate features by their combined scores from Pearson correlation and mutual information, I further use a heatmap analysis to remove highly redundant features. Ultimately, I select 13 key features that are most relevant to the electric vehicle battery fault diagnosis. These features are listed in Table 3.

Table 3: Final selected features for electric vehicle battery fault diagnosis
Dimension Feature Description
Battery status total_volt Total pack voltage
Battery status total_current Total pack current
Battery status max_temp Maximum cell temperature
Battery status max_temp_diff Temperature difference within the pack
Battery status isulate_r Insulation resistance
Battery status mileage Accumulated mileage
Consistency cell_volt_CV Voltage coefficient of variation
Consistency cell_volt_DV Voltage deviation rate
Consistency cell_volt_CV_std Standard deviation of voltage CV
Consistency cell_temp_CV Temperature coefficient of variation
Driving behavior speed Vehicle speed
Time context day_section_0 Whether it is early morning (0:00–5:59)
Time context day_section_1 Whether it is morning (6:00–11:59)

4. Improved SMOTE-Based Fault Diagnosis

The dataset constructed in the previous section still suffers from class imbalance, with fault samples accounting for only about 10.47% of the total. To solve this problem, I adopt a hybrid sampling strategy that combines oversampling and undersampling. For oversampling, I use an improved Border-SMOTE algorithm instead of the classic SMOTE. The key difference is that classic SMOTE generates synthetic samples for all minority instances, which may introduce noise and blur the decision boundary. In contrast, Border-SMOTE focuses on the minority instances that are located near the boundaries between classes, because these boundary samples are the most informative and are more likely to be misclassified.

The Border-SMOTE algorithm works as follows. For each minority sample \(x_i\), I first compute its \(k\) nearest neighbors in the entire training set (including both majority and minority samples). Let \(k’\) be the number of nearest neighbors that belong to the majority class. Then the sample is classified into one of three categories:

  • If \(k’ = k\), the sample is considered noise and is ignored.
  • If \(k/2 \le k’ < k\), the sample is considered a dangerous boundary sample and is selected for oversampling.
  • If \(0 \le k’ < k/2\), the sample is considered a safe interior sample and is not selected.

For each selected boundary sample, I use the Border-SMOTE2 strategy. In this strategy, I find both its \(k\) nearest neighbors in the minority class and its \(k\) nearest neighbors in the majority class. When generating new samples, I interpolate only along the line between the boundary sample and its minority-class neighbors, and also along the line between the boundary sample and its majority-class neighbors but with a restricted interpolation factor \(\lambda \in [0, 0.5]\). The new synthetic sample is generated as:

$$x_{new} = x_i + \alpha (x_{zi} – x_i)$$

where \(\alpha\) is a random number in \([0,1]\) for minority-neighbor interpolation, or in \([0,0.5]\) for majority-neighbor interpolation. This approach strengthens the boundary region without pushing the synthetic samples too far into the majority territory. To further balance the dataset, I apply undersampling to the majority class by randomly removing samples, so that the final training set has a roughly equal number of samples for each class.

To verify the quality of the generated data, I compare the probability density distributions of the original data and the augmented data for all 13 selected features. The distribution curves show that the synthetic samples follow almost the same distribution as the original ones, confirming that the Border-SMOTE strategy generates realistic and reliable samples.

For the diagnostic model, I construct a Stacking heterogeneous ensemble framework. The first layer consists of three base learners: LightGBM, XGBoost, and Random Forest. These three models have complementary strengths. LightGBM is efficient with large-scale data and can capture complex nonlinear relationships. XGBoost is robust to noise and missing values and offers excellent predictive accuracy through regularization and second-order optimization. Random Forest reduces variance by averaging multiple decision trees and helps prevent overfitting. The second layer of the Stacking model uses Logistic Regression as the meta-learner to combine the outputs of the base learners.

The training procedure uses 5-fold cross-validation. The original training set is divided into five folds. For each fold, a base model is trained on the remaining four folds and then predicts the held-out fold. This process is repeated for all folds, generating out-of-fold predictions for the entire training set. The same trained models are also used to predict the test set, and the predicted results are averaged to form the test features for the meta-learner. The meta-learner then trains on these new features to produce the final diagnosis. This stacking mechanism effectively integrates the diverse perspectives of different base learners and improves the overall generalization capability.

I also perform hyperparameter tuning using Bayesian optimization combined with 5-fold cross-validation. This approach efficiently searches the hyperparameter space and ensures that each base model performs at its best before integration. The evaluation metrics include accuracy, precision, recall, and F1-score. The definitions of these metrics are given below.

$$A = \frac{TP+TN}{TP+TN+FP+FN}$$

$$P = \frac{TP}{TP+FP}$$

$$R = \frac{TP}{TP+FN}$$

$$F1 = \frac{2 \cdot P \cdot R}{P + R}$$

Table 4 presents the experimental results on the Border-SMOTE augmented dataset. I compare the performance of the three single models and the Stacking ensemble model.

Table 4: Performance comparison of single models and the Stacking model using Border-SMOTE
Model A (%) P-1 (%) P-2 (%) P-3 (%) P-ave (%) F1-1 (%) F1-2 (%) F1-3 (%) F1-ave (%) R-ave (%) t (s)
LightGBM 94.41 96.61 91.79 93.15 94.09 93.82 93.00 94.42 94.20 94.38 14
XGBoost 94.50 95.79 95.58 97.13 95.06 95.11 94.53 94.54 94.55 94.10 11
Random Forest 91.94 91.30 96.13 97.18 93.21 92.89 94.23 90.15 92.05 91.22 48
Stacking 97.20 98.56 96.21 97.79 97.22 98.43 96.19 97.48 97.17 97.13 85

From Table 4, it is evident that the Stacking model achieves the highest accuracy of 97.20%, which is 2.7 percentage points higher than the best single model XGBoost. The average precision and average F1-score of the Stacking model are 97.22% and 97.17%, respectively, representing relative improvements of 2.1 and 2.6 percentage points over XGBoost. The recall rates for the three fault levels are also significantly improved, especially for level-2 and level-3 faults. The confusion matrix analysis shows that the Stacking model reduces misclassifications across all severity levels, demonstrating its superiority in diagnosing electric vehicle battery faults.

I also compare the traditional SMOTE method with the improved Border-SMOTE method using the same Stacking framework. The results are listed in Table 5. Border-SMOTE consistently outperforms SMOTE by more than 1 percentage point on all metrics, indicating that the boundary-aware oversampling strategy is more effective for this highly imbalanced dataset.

Table 5: Comparison between SMOTE and Border-SMOTE under the Stacking model
Method A (%) P-ave (%) R-ave (%) F1-ave (%) t (s)
SMOTE 96.06 96.20 95.90 96.04 91
Border-SMOTE 97.20 97.22 97.13 97.17 85

5. WGAN-GP-Based Fault Diagnosis

Although Border-SMOTE improves the quality of the augmented data, it still has limitations. The interpolation-based method may generate unrealistic samples in high-dimensional feature spaces, and it can be computationally expensive. To further enhance the data quality, I introduce a more advanced data augmentation technique based on generative adversarial networks. Specifically, I employ the Wasserstein Generative Adversarial Network with Gradient Penalty (WGAN-GP) to generate synthetic fault samples that closely mimic the real distribution of the electric vehicle battery data.

The original GAN suffers from training instability and mode collapse because it uses the Jensen-Shannon divergence as the loss function. The JS divergence becomes constant when the real and generated distributions do not overlap, leading to vanishing gradients. To overcome this issue, WGAN replaces the JS divergence with the Wasserstein distance, also known as the Earth-Mover distance. The Wasserstein distance provides a smooth and meaningful measure of the distance between two distributions even when they have non-overlapping support. However, WGAN enforces the Lipschitz constraint by weight clipping, which can cause gradient explosion or vanishing and limits the capacity of the discriminator.

WGAN-GP solves the weight clipping problem by adding a gradient penalty term to the loss function. The critic network no longer outputs a probability but a real-valued score. The objective function of WGAN-GP is expressed as:

$$L = \mathbb{E}_{\tilde{x} \sim P_g}[D(\tilde{x})] – \mathbb{E}_{x \sim P_r}[D(x)] + \lambda \mathbb{E}_{\hat{x} \sim P_{\hat{x}}}\left[\left(\|\nabla_{\hat{x}} D(\hat{x})\|_2 – 1\right)^2\right]$$

where \(P_r\) is the real data distribution, \(P_g\) is the generated data distribution, \(D\) is the critic network, \(\lambda\) is the gradient penalty coefficient, and \(\hat{x}\) is sampled uniformly along straight lines between pairs of real and generated samples. The penalty term encourages the gradient norm of the critic to be close to 1, which enforces the 1-Lipschitz constraint without the drawbacks of weight clipping.

In my implementation, I train a generator network that maps random noise vectors to synthetic samples in the 13-dimensional feature space. The critic network is trained to distinguish real samples from synthetic samples while being penalized for large gradient norms. I use the Adam optimizer with a learning rate of 0.0001 and a batch size of 256. The gradient penalty coefficient \(\lambda\) is set to 10. The training process is monitored by tracking the loss curves, gradient norms, and the score difference between real and generated samples. The experimental results show that the critic scores for real samples remain consistently higher than those for generated samples, and the gradient norm stabilizes near 1.002, which fully satisfies the theoretical constraint. The generator loss decreases steadily to -2.97, indicating that the Wasserstein distance between the real and generated distributions is extremely small.

To validate the quality of the WGAN-GP generated data, I compare the probability density plots and cumulative distribution functions of the original and synthetic features. The curves overlap almost perfectly for all 13 features, confirming that the synthetic samples are statistically indistinguishable from the real ones. Figure 3 in my study shows these distribution comparisons, but I do not refer to a specific figure number here; the visual inspection clearly demonstrates the high fidelity of the generated data.

After data augmentation with WGAN-GP, I train the same set of base models and the Stacking ensemble model. Table 6 presents the performance comparison on the WGAN-GP augmented dataset.

Table 6: Performance comparison of single models and the Stacking model using WGAN-GP
Model A (%) P-1 (%) P-2 (%) P-3 (%) P-ave (%) F1-1 (%) F1-2 (%) F1-3 (%) F1-ave (%) R-ave (%)
LightGBM 93.08 92.66 95.28 95.26 93.56 93.20 93.66 95.15 93.37 93.23
XGBoost 99.17 99.03 99.41 99.49 99.23 99.06 99.45 99.35 99.22 99.21
Random Forest 98.82 99.11 99.41 99.51 98.97 99.09 99.27 98.55 98.85 98.73
Stacking 99.81 99.90 99.70 99.65 99.79 99.90 99.80 99.63 99.80 99.81

From Table 6, the Stacking model achieves an outstanding accuracy of 99.81%, which is even higher than the result obtained with Border-SMOTE. The XGBoost and Random Forest models also perform remarkably well, with accuracies of 99.17% and 98.82%, respectively. Interestingly, the gap between the Stacking model and the best single model has narrowed to only 0.64 percentage points. This suggests that when the data quality is sufficiently high, even a strong single model can achieve near-perfect diagnosis of electric vehicle battery faults. The reason is that WGAN-GP generates synthetic samples that lie in the same low-dimensional manifold as the real data, making the classification task much easier.

To further investigate this observation, I experiment with three additional base models: Adaptive Boosting (ADA), Gradient Boosting Decision Tree (GBDT), and Multilayer Perceptron (MLP). The results are shown in Table 7.

Table 7: Performance of additional base models and the Stacking model using WGAN-GP
Model A (%) P-1 (%) P-2 (%) P-3 (%) P-ave (%) F1-1 (%) F1-2 (%) F1-3 (%) F1-ave (%) R-ave (%)
ADA 97.73 98.83 98.37 97.03 97.79 97.63 97.79 97.86 97.70 97.64
GBDT 99.71 99.79 99.68 99.54 99.69 99.79 99.71 99.58 99.70 99.71
MLP 99.32 99.57 98.67 99.03 99.22 99.63 98.91 99.14 99.27 99.31
Stacking 99.81 99.90 99.70 99.65 99.79 99.90 99.80 99.63 99.80 99.81

Table 7 shows that GBDT achieves an accuracy of 99.71%, which is only 0.10 percentage points lower than the Stacking model. The MLP model also attains 99.32%, and even the weaker ADA model reaches 97.73%. These results demonstrate that the WGAN-GP data augmentation strategy dramatically improves the separability of the fault classes, allowing a wide range of models to achieve high diagnostic accuracy for the electric vehicle battery.

I also compare the overall best results obtained with the two data augmentation strategies. Table 8 summarizes the comparison between Border-SMOTE and WGAN-GP for the Stacking model.

Table 8: Overall comparison of Border-SMOTE and WGAN-GP under the Stacking model
Data augmentation A (%) P-ave (%) R-ave (%) F1-ave (%)
Border-SMOTE 97.20 97.22 97.13 97.17
WGAN-GP 99.81 99.79 99.81 99.80

The improvements brought by WGAN-GP are substantial. The accuracy increases from 97.20% to 99.81%, a relative improvement of 2.68%. All other metrics also exceed 99.7%. The confusion matrix analysis for the Stacking model with WGAN-GP shows that more than 99.7% of the samples in every class are correctly classified, with only marginal confusion between adjacent fault levels. In particular, the recall for level-3 faults reaches 99.86%, which is critical for preventing catastrophic thermal runaway events.

One important finding of my research is that high-quality data augmentation can partially compensate for the need for complex ensemble models. When the data distribution is clean and well separated, even simple models such as GBDT can achieve near-perfect performance. This does not mean that the Stacking ensemble is unnecessary; rather, the Stacking model consistently provides the best and most stable performance across different data conditions. Therefore, I believe that combining advanced data augmentation with a heterogeneous ensemble is the most reliable approach for diagnosing faults in electric vehicle batteries.

6. Conclusion

In this study, I have presented a comprehensive data-driven framework for fault detection and diagnosis of electric vehicle batteries. The main contributions are summarized as follows:

  1. I constructed a high-quality dataset by applying fault tree analysis to reconstruct fault severity levels, removing irrelevant alarms, and extracting 13 key features through rigorous feature engineering.
  2. I proposed an improved Border-SMOTE strategy to mitigate the severe class imbalance problem. The boundary-focused oversampling significantly improved the diagnostic performance compared to classic SMOTE.
  3. I built a Stacking heterogeneous ensemble model using LightGBM, XGBoost, and Random Forest as base learners and Logistic Regression as the meta-learner. This model achieved 97.20% accuracy on the Border-SMOTE augmented dataset.
  4. I introduced the WGAN-GP strategy to generate more realistic and high-quality synthetic samples. The Stacking model trained on WGAN-GP augmented data achieved 99.81% accuracy, demonstrating the exceptional capability of generative models for data augmentation.

My experimental results reveal an important insight: the quality of data augmentation plays a decisive role in the ultimate diagnostic performance. With the high-fidelity samples generated by WGAN-GP, the performance gap between single models and the ensemble model narrowed to less than 0.5 percentage points, and the overall accuracy exceeded 99.7%. This finding highlights the enormous potential of generative adversarial networks in overcoming the data scarcity and imbalance problems that are common in electric vehicle battery fault diagnosis.

Nevertheless, there are still several directions that deserve further investigation. First, different combinations of base learners and meta-learners could be explored to further optimize the Stacking framework. Second, the fusion of physics-based models with data-driven methods, such as incorporating equivalent circuit models or thermal models, may improve the interpretability and robustness of the diagnosis. Third, the relationship between different battery faults and external factors such as driving behavior, weather, and road conditions should be studied to enable more informed decision-making. Finally, online learning and transfer learning techniques can be adopted to adapt the diagnostic model to new battery types and operating conditions over the full lifecycle of the electric vehicle battery.

In conclusion, my research provides a practical and effective solution for early and accurate detection of electric vehicle battery faults. The combination of fault tree analysis, advanced data augmentation, and ensemble learning offers a robust pathway toward safer and more reliable electric vehicles. I believe that this work will serve as a valuable reference for both academic research and industrial applications in the field of electric vehicle battery health management.

Scroll to Top