With the rapid expansion of the electric vehicle industry, reliable charging infrastructure has become a critical component supporting this growth. The accuracy of metering in EV charging stations directly impacts effective charging and energy management for electric vehicles. Traditional calibration methods for EV charging stations often rely on manual on-site operations, which are inefficient and susceptible to environmental interference. These methods struggle to meet the high standards required by the rapidly evolving electric vehicle industry. To address these challenges, we propose an integrated model combining K-Nearest Neighbors (KNN) and Convolutional Neural Networks (CNN) for detecting abnormal metering data in EV charging stations. This approach leverages the rapid neighbor search capability of KNN and the deep feature extraction ability of CNN, resulting in a robust system for remote online supervision platforms.

The increasing demand for electric vehicles has highlighted the importance of efficient and accurate EV charging stations. Current calibration methods for EV charging stations involve comparing the output energy of the charging pile with values from standard calibration devices. However, these methods are time-consuming and prone to errors. In this study, we develop a novel approach that integrates machine learning models to enhance the detection of anomalies in EV charging station data. By combining KNN and CNN, we aim to improve both the speed and accuracy of anomaly detection, making it suitable for large-scale deployment in complex data environments.
Our method begins with the construction of a comprehensive dataset collected from various EV charging stations. Data is acquired from three sources: the vehicle end, the meter end, and the charging pile end. Parameters include voltage, current, power, state of charge (SOC), temperature, and total energy, all timestamped for analysis. The raw data, often in video format, is converted to structured CSV files using optical character recognition (OCR) techniques. Specifically, we employ the Connectionist Text Proposal Network (CTPN) for text localization and the Convolutional Recurrent Neural Network (CRNN) for end-to-end text recognition. This process ensures high accuracy in data extraction, as shown in the following table summarizing data identification results.
| Parameter | Value |
|---|---|
| Total Data Points | 984 |
| Accuracy Rate | 96.44% |
| Incorrect Data Points | 0 |
| Garbled Data Points | 31 |
| Missing Data Points | 4 |
After data extraction, we perform data cleaning to remove incomplete, duplicate, or erroneous entries. This step is crucial for ensuring the quality of the dataset used in model training. The cleaned data is then used to build the integrated KNN-CNN model. The KNN algorithm is a non-parametric classifier that excels in pattern recognition for small to medium-sized datasets. It calculates the distance between data points to identify the nearest neighbors. The Minkowski distance between two n-dimensional points \(x_i\) and \(x_j\) is defined as:
$$d(x_i, x_j) = \left( \sum_{k=1}^{n} |x_{ik} – x_{jk}|^p \right)^{1/p}$$
where \(p=1\) corresponds to the Manhattan distance and \(p=2\) to the Euclidean distance. In our implementation, we use the Euclidean distance for its effectiveness in capturing similarities in EV charging station data.
The CNN component of our model is designed to extract deep features from the temporal and spatial dimensions of the data. It consists of convolutional layers, pooling layers, and fully connected layers. For temporal feature extraction, we use a convolution kernel represented as:
$$W_{temp} \in \mathbb{R}^{5 \times 4 \times 32}$$
For spatial feature extraction, we apply graph convolution to capture relationships between different parameters in the EV charging station data. The spatial convolution is computed as:
$$H^{(l+1)} = \sigma \left( \tilde{D}^{-\frac{1}{2}} \tilde{A} \tilde{D}^{-\frac{1}{2}} H^{(l)} W_{spa}^{(l)} \right)$$
where \(\tilde{A}\) is the adjacency matrix with self-connections, \(\tilde{D}\) is the degree matrix, \(W_{spa}\) is the trainable weight matrix, and \(\sigma\) is the activation function. This allows the model to learn complex patterns in the EV charging station data.
The integrated KNN-CNN model uses a decision-level fusion strategy to combine the outputs of both algorithms. The fusion is based on a weighted average, where weights are dynamically adjusted based on validation performance. Additionally, we implement a dynamic threshold for anomaly detection, which adapts over time to improve robustness. The threshold \(\tau_t\) at time \(t\) is updated as:
$$\tau_t = \alpha \cdot \tau_{t-1} + (1-\alpha) \cdot \frac{1}{N} \sum_{i=1}^{N} S(x_i)$$
where \(\alpha\) is a smoothing factor, \(N\) is the number of samples, and \(S(x_i)\) is the anomaly score at time \(i\). This ensures that the model can distinguish between true anomalies and random noise in EV charging station operations.
To validate our approach, we conducted experiments using data from EV charging stations with different power ratings: 60 kW, 120 kW, and 180 kW. The dataset included normal operation data and data with injected anomalies to simulate common issues such as fixed measurement errors, dynamic variations, and environmental disturbances. We compared the performance of the integrated KNN-CNN model with standalone KNN, CNN, Long Short-Term Memory (LSTM), and Graph Convolutional Network (GCN) models. The following table summarizes the total data collected for the experiments.
| Charging Station Power and Condition | Vehicle End (Groups) | Charging Pile End (Groups) | Meter End (Groups) |
|---|---|---|---|
| 60 kW Full Charge | 5170 | 5170 | 70 |
| 60 kW 5-Minute Charge | 3532 | 3532 | 80 |
| 120 kW Full Charge | 3902 | 3902 | 160 |
| 120 kW 5-Minute Charge | 1664 | 1664 | 180 |
| 180 kW 5-Minute Charge | 2032 | 2032 | 100 |
In the first test scenario, we evaluated the models under normal operating conditions. The KNN model showed high prediction accuracy due to its ability to handle structured data, while the CNN model improved over time with training. The integrated KNN-CNN model consistently outperformed both, achieving higher accuracy across all data volumes. For instance, with 30 minutes of data, the integrated model’s detection accuracy was 6% higher than KNN and 13% higher than CNN. This demonstrates the synergy between the two algorithms in enhancing anomaly detection for EV charging stations.
The second test scenario focused on stable measurement errors, simulating issues like circuit losses or aging components. The KNN model maintained a detection accuracy above 0.98 throughout the charging cycle, while CNN’s accuracy increased from 0.78 at 5 minutes to 0.97 at 30 minutes. The integrated model achieved near-perfect accuracy (0.99) at 30 minutes, highlighting its ability to handle consistent anomalies in EV charging station data.
In the third scenario, we tested dynamic measurement errors, which represent more complex and hidden anomalies. The KNN model’s accuracy remained around 0.8, while CNN showed significant improvement from 0.75 to 0.95 over 30 minutes. The integrated model started lower but rapidly increased to 0.99 after 20 minutes, maintaining stability. This indicates that the fusion model adapts well to varying data conditions in EV charging stations.
To comprehensively assess the models, we combined all test scenarios and included additional algorithms like LSTM and GCN. The results, summarized in the table below, show that the KNN-CNN integrated model achieved the highest detection accuracy across all charging durations, particularly in large data volumes. For example, at 20 minutes, its accuracy was 25% higher than the standalone CNN model. This confirms the effectiveness of our approach in real-world EV charging station environments.
| Charging Duration (minutes) | KNN | LSTM | CNN | GCN | KNN-CNN Integrated |
|---|---|---|---|---|---|
| 5 | 0.85 | 0.70 | 0.65 | 0.68 | 0.90 |
| 10 | 0.87 | 0.75 | 0.72 | 0.74 | 0.93 |
| 15 | 0.88 | 0.80 | 0.78 | 0.79 | 0.95 |
| 20 | 0.89 | 0.83 | 0.82 | 0.81 | 0.97 |
| 25 | 0.90 | 0.85 | 0.85 | 0.84 | 0.98 |
| 30 | 0.91 | 0.86 | 0.87 | 0.85 | 0.99 |
The superior performance of the integrated model can be attributed to its ability to leverage the strengths of both KNN and CNN. KNN provides quick and accurate classification for well-defined patterns, while CNN captures intricate temporal and spatial dependencies. The fusion strategy ensures that the final output is robust against noise and variations in EV charging station data. Moreover, the dynamic threshold mechanism allows the model to adapt to changing conditions, making it suitable for long-term deployment.
In conclusion, our integrated KNN-CNN model offers a significant advancement in anomaly detection for EV charging stations. It addresses the limitations of traditional methods by combining rapid neighbor search with deep feature extraction, resulting in high accuracy and robustness. Experimental results demonstrate its effectiveness across various scenarios, including normal operation, stable errors, and dynamic anomalies. This approach not only enhances the efficiency of metering calibration but also supports the development of intelligent supervision platforms for the electric vehicle industry. Future work will focus on optimizing the data decomposition methods to further improve prediction accuracy for high-frequency components in EV charging station data.
The implementation of this model in remote monitoring systems can revolutionize the way EV charging stations are maintained and calibrated. By providing real-time anomaly detection, it reduces the need for manual inspections and minimizes downtime. This is particularly important as the number of EV charging stations continues to grow worldwide. Our method ensures that these infrastructures operate reliably, supporting the global transition to sustainable transportation.
Additionally, the scalability of the integrated model makes it applicable to large networks of EV charging stations. The use of standardized data formats and automated processing pipelines allows for seamless integration into existing systems. As data volumes increase, the model’s performance improves, making it a future-proof solution for the evolving demands of the electric vehicle ecosystem.
In summary, the KNN-CNN integrated model represents a holistic approach to anomaly detection in EV charging stations. It combines the simplicity of distance-based algorithms with the power of deep learning, resulting in a system that is both accurate and adaptable. We believe that this research will contribute to the development of more efficient and reliable charging infrastructures, ultimately promoting the adoption of electric vehicles and the achievement of environmental goals.
