Next Article in Journal
Active and Passive Optimization of the Indoor Thermal Environment of Rural Dwellings in Hohhot Under Clean Heating in Severe Cold Regions
Previous Article in Journal
The Role of Livestock in Circular Agriculture and Waste Valorisation
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Sustainable and Reliable Operation of EV Charging Infrastructure: A Lightweight Prototype-Driven Contrastive Learning Framework for Fault Diagnosis Under Class-Imbalanced Conditions

1
Department of Electrical Engineering, Chongqing University, Chongqing 400044, China
2
Chongqing University-University of Cincinnati Joint Co-op Institute, Chongqing University, Chongqing 400044, China
3
Department of Electrical and Computer Engineering, University of Cincinnati, Cincinnati, OH 45221, USA
4
Department of Mechanical Engineering, Tianjin University of Technology, Tianjin 300384, China
5
Department of Economy and Management, Wuhan University, Wuhan 430072, China
6
Department of Mechanical Engineering, Sichuan University, Chengdu 610207, China
*
Author to whom correspondence should be addressed.
Sustainability 2026, 18(11), 5783; https://doi.org/10.3390/su18115783 (registering DOI)
Submission received: 10 May 2026 / Revised: 2 June 2026 / Accepted: 3 June 2026 / Published: 5 June 2026
(This article belongs to the Section Energy Sustainability)

Abstract

With the rapid growth of transportation electrification and smart energy systems, the reliable operation of electric vehicle (EV) charging infrastructure has become an important issue for sustainable transport, since charging faults may interrupt service and shorten equipment lifetime. However, practical charging environments are often characterized by heterogeneous operating conditions and severely imbalanced fault distributions, which limit the effectiveness of conventional fault diagnosis methods. To address these challenges, this study proposes a lightweight Proto-Contrastive Discriminative Learning (PCDL) framework for intelligent fault diagnosis in EV charging systems. The proposed method combines supervised contrastive learning with a prototype-distance discrimination mechanism to improve the identification of rare abnormal states under long-tailed data conditions. Heterogeneous charging features, including discrete control signals and continuous total harmonic distortion (THD) indicators, are projected into a discriminative embedding space, while anomaly detection is performed according to the relative distances between samples and class prototypes. Experimental results on a publicly available EV charging-pile monitoring dataset, containing 122,144 samples with four discrete control/safety features and two THD-based power-quality features, demonstrate that the proposed framework maintains stable detection performance under imbalance ratios of 1:1, 1:10, and 1:100. Under the most challenging 1:100 condition, the proposed method achieves an F1-score of 84.21%, representing a 29.08% improvement over the strongest baseline method. In addition, the framework requires only approximately 11 KB of memory and maintains CPU inference latency below 6.3 ms, demonstrating strong potential for real-time deployment on resource-constrained edge devices. These results suggest that the proposed framework can provide a lightweight diagnostic tool for practical charging stations and support safer and more reliable EV charging operation.

1. Introduction

The global transition toward low-carbon transportation and smart energy systems has significantly accelerated the deployment of electric vehicles (EVs), which makes charging infrastructure an increasingly important interface between transportation electrification and distribution power systems. According to the International Energy Agency (IEA), global electric car sales, including battery electric vehicles (BEVs) and plug-in hybrid electric vehicles (PHEVs), exceeded 17 million in 2024, while more than 1.3 million public charging points were added in the same year [1]. With the rapid expansion of charging networks, EV supply equipment is expected to operate under frequent plug-unplug cycles, long-duration service, high-power conversion, and strict safety constraints. Therefore, the reliable and safe operation of charging infrastructure has become an important requirement for grid-edge energy management, user safety, service continuity, and resilient smart-grid operation.
EV charging systems involve several coupled mechanical, electrical, and information-related components, including vehicle batteries, power electronic converters, contactors, electronic locks, sensors, communication interfaces, protection devices, and local grid connections. Standards such as IEC 61851-1 specify general requirements for conductive EV charging systems [2], providing a technical basis for safe and standardized operation. In this study, “heterogeneous” mainly refers to the coexistence of different component mechanisms and signal types in the same charging process. Electromechanical parts, such as contactors and electronic locks, may suffer from contact wear, coil degradation, or mechanical jamming, which can appear as intermittent or stuck control signals. Power electronic converters, including AC/DC and DC/DC stages, may experience switching-device aging or passive-component drift, which can be reflected by increased voltage or current total harmonic distortion (THD). Protection and safety circuits, such as emergency-stop and access-control signals, usually generate discrete on/off states, while sensing and communication interfaces may introduce noisy or delayed measurements due to electromagnetic interference, loose connectors, or corrosion. These different mechanisms lead to mixed fault patterns, ranging from discrete logic inconsistencies to continuous power-quality degradation. This explains why the raw feature space can show severe overlap between normal and abnormal states and why a representation learning framework is needed to separate these mixed signals. However, as charging stations become more widely deployed and more deeply integrated with distribution networks, their operating conditions become increasingly diverse. Charging infrastructure is no longer only a passive energy-supply terminal; it is also a critical grid-edge component that supports transportation electrification, power conversion management, and resilient distribution-grid operation.
The safety significance of EV charging infrastructure should be interpreted from the engineering failure chain of the charging process. In practical charging stations, failures may originate from several coupled components, including connectors, contactors, electronic locks, power converters, sensors, protection circuits, communication interfaces, and grid-side connections. Recent reliability studies have shown that charger malfunction is not limited to complete equipment shutdown, but may also involve charge-initiation failure, communication interruption, maintenance-related faults, and unstable operating states [3]. At the electromechanical level, connector wear, loose terminals, contactor degradation, or electronic-lock malfunction may lead to intermittent conduction, delayed switching, or stuck control states. At the power-conversion level, switching-device aging, thermal stress, filter degradation, or unbalanced loading may cause abnormal voltage/current waveforms and increased total harmonic distortion (THD) [4]. At the control and communication level, abnormal pilot/control signals, delayed responses, or communication disturbances may interrupt the charging process or trigger inconsistent safety-loop states [5]. These mechanisms explain why EV charging faults may appear as mixed patterns, including discrete control-signal inconsistency, safety-state mismatch, sensor drift, transient control jitter, and continuous power-quality degradation. Therefore, reliable and timely anomaly detection is important for improving safety, operational stability, power-quality monitoring, and service continuity of EV charging infrastructure.
From an operation-oriented perspective, anomaly detection is not only a safety issue. In charging stations that operate continuously, small faults that are not detected in time may lead to repeated service interruptions, unnecessary maintenance, and early replacement of key components. Therefore, a practical diagnosis model should be able to recognize rare abnormal states while remaining lightweight enough for station-side deployment. In this paper, “operational sustainability” is used only in this limited sense: maintaining long-term charger availability and reducing avoidable maintenance without adding a heavy computational burden.
The remainder of this paper is organized as follows: Section 2 reviews related works and identifies the research gaps addressed by PCDL. Section 3 presents the proposed methodology, including the supervised contrastive encoder and prototype-distance scoring strategy. Section 4 describes the experimental setup and evaluation metrics. Section 5 discusses the results, deployment efficiency, and limitations. Section 6 concludes the paper and outlines future work.

2. Related Works

2.1. Anomaly Detection in EV Charging and Related Electrical Systems

Conventional anomaly detection methods often model normal behavior and identify samples that deviate from the learned boundary or density. One-Class SVM estimates the support of the normal data distribution [6], Isolation Forest isolates anomalous samples through random partitioning [7], and robust covariance-based detectors use statistics such as the minimum covariance determinant to identify samples with large Mahalanobis distances [8]. Support vector data description (SVDD) and its deep variants further extend boundary-based anomaly detection to hypersphere or representation-space formulations [9,10]. These methods are attractive when labeled faults are unavailable, and they have been adopted in vehicle and electrical anomaly contexts, such as event-based anomaly detection using One-Class SVM for hybrid electric vehicles [11]. However, they are sensitive to the assumed normal-data geometry. In EV charging stations, normal operation can be multimodal because of different charging modes, battery states, user behaviors, and grid conditions. A static boundary may therefore misclassify legitimate operating variations as anomalies, especially when heterogeneous discrete and continuous features are mixed, thereby reducing the reliability and robustness of intelligent EV charging operation.
Recent studies have increasingly explored machine learning and deep learning techniques for intelligent management of EV charging infrastructure. Diao et al. developed an A-LSTM-based charging safety warning framework using daily EV charging data and dynamic thresholds [12], while Feng et al. reviewed deep-learning-based anomaly detection for EV charging data [13]. Kesavan et al. proposed a grid-sentinel framework for EV charging stations in a smart-grid environment, integrating machine learning models such as LSTM, random forest, and autoencoders for intrusion and anomaly detection [14]. Shufian et al. investigated automatic fault detection and analysis for EV charging stations using machine-learning techniques [15]. Grcić et al. studied EV charging-station fault detection using a machine-learning approach [16], and Bin Kaleem et al. proposed segmented regression for Li-ion battery fault detection in EVs [17]. These studies show the feasibility of data-driven diagnosis, but most of them focus on either vehicle-side battery signals, charging-session time series, or cyber/communication intrusion patterns. Reliable data-driven diagnosis is increasingly regarded as an essential enabling technology for smart transportation and resilient energy infrastructure. Fewer studies explicitly model the joint behavior of contactor-related control states and THD-based power-quality indices under severe class imbalance.
More recent studies have further explored sequence-learning models for EV charging and distribution-network fault diagnosis. Hosseini et al. [18] proposed a deep-learning model for fault detection in distribution networks with high penetration of EV chargers and reported high diagnostic accuracy by processing multi-dimensional streaming data such as voltage, current, and temperature. Ji et al. [19] combined particle swarm optimization (PSO) with bidirectional long short-term memory (Bi-LSTM) for charging-station fault prediction and management, reporting 0.951 precision, 0.963 recall, and 0.957 F1-score. These studies show the strong potential of optimized recurrent models for time-dependent charging-station fault diagnosis. However, their focus is mainly on streaming sequence modeling, whereas the present study addresses rare-fault discrimination under severe class imbalance using mixed discrete control states and THD-based power-quality indicators. Therefore, these methods are highly relevant but solve a different part of the EV charging fault-diagnosis problem.
Recent transformer-based models have also attracted increasing attention for anomaly detection and monitoring in smart-grid and EV-charging-related scenarios. Compared with recurrent models, transformer architectures use self-attention mechanisms to capture long-range temporal dependencies and global contextual relationships in multivariate monitoring data. For EV charging identification, Kamoona et al. proposed an unsupervised memory-based transformer model for online EV charging detection from streaming smart-meter data [20]. Their method combines a global historical window and a local temporal window to capture both coarse-scale and fine-scale charging patterns, showing the potential of transformer models for real-time grid-side EV monitoring. In smart-grid monitoring, Liu et al. investigated Vision Transformer models for anomaly detection in phasor measurement unit (PMU) data [21]. Their results indicate that transformer-based models can capture global spatial-temporal dependencies and improve the recognition of subtle grid anomalies, although real-time deployment may still be limited by computational complexity. These studies demonstrate the value of transformer architectures for sequence-oriented grid monitoring. However, they mainly focus on streaming smart-meter data or PMU time-series measurements, whereas the present study addresses a different setting: lightweight rare-fault discrimination using fixed heterogeneous charging-pile features, including discrete control states and THD-based power-quality indicators, under severe class imbalance. Therefore, transformer-based methods are highly relevant to the broader smart-grid anomaly-detection literature, but they do not directly solve the classifier-bias and edge-deployment challenges targeted by the proposed PCDL framework.
For supervised benchmarking, classical and deep models such as K-nearest neighbors (KNN), backpropagation neural networks, convolutional neural networks (CNNs), long short-term memory (LSTM) networks, and reinforcement-learning-based decision frameworks are widely used [22,23,24,25,26]. These methods can achieve good results when representative fault labels are available and the training data are not extremely imbalanced. However, when abnormal charging samples are rare, the loss contribution of minority faults can be overwhelmed by the majority normal class. This is particularly problematic in safety monitoring, where missed faults are much more costly than isolated false alarms. Therefore, EV charging infrastructure requires a robust learning strategy that can exploit scarce fault labels without allowing class frequency to dominate the learned decision boundary.

2.2. Class-Imbalanced Learning for Rare Charging Faults

Class imbalance has been widely studied in machine learning and industrial fault diagnosis. Data-level approaches attempt to modify the training distribution. SMOTE generates synthetic minority samples by interpolating between existing minority examples [27], while generative approaches such as generative adversarial networks and denoising diffusion models can synthesize more complex samples [28,29]. Although these methods can increase the apparent number of minority samples, they may generate unrealistic or ambiguous charging faults when only a small set of abnormal samples is available. This risk is especially important for EV charging infrastructure because fault mechanisms may involve discrete control failures, contactor degradation, converter aging, and grid disturbances that are not safely interpolable in the raw feature space, potentially reducing the long-term sustainability of charging infrastructure monitoring systems.
Algorithm-level approaches modify the training objective. Focal loss down-weights easy majority examples and emphasizes harder samples [30], while class-balanced loss re-weights classes according to the effective number of samples [31]. These losses are simple to implement and can improve minority sensitivity, but they usually require careful tuning of weighting or focusing parameters. In addition, they are often attached to a parametric classifier head; as a result, the final decision boundary may still shift toward the majority class when the training distribution becomes extremely long-tailed. Long-tailed learning surveys further show that resampling, re-weighting, information augmentation, and module-level modifications each have trade-offs in robustness, calibration, and deployment complexity [32]. For EV charging anomaly detection, a desirable approach should reduce class-prior sensitivity while avoiding the need for extensive synthetic fault generation or manually tuned cost weights and while supporting reliable, resource-efficient, and reliable and resource-efficient fault diagnosis in large-scale EV charging networks. Accurate identification of rare charging faults is particularly important for reducing unexpected downtime, minimizing maintenance costs, improving energy utilization efficiency, and extending the operational lifetime of EV charging infrastructure.

2.3. Contrastive and Prototype-Based Representation Learning

Contrastive learning has become an effective representation-learning paradigm. SimCLR learns representations by maximizing agreement between augmented views of the same sample [33], and MoCo improves negative-sample management through a dynamic dictionary and momentum encoder [34]. Supervised contrastive learning extends this principle to labeled data by treating all samples from the same class as positives and samples from other classes as negatives [35]. From a geometric perspective, contrastive losses encourage alignment among semantically similar samples and uniformity or separation among dissimilar samples on the hypersphere [36]. These properties are particularly useful for anomaly detection under imbalance, where raw feature distributions can overlap and minority-class samples may be scattered, thereby improving the reliability and operational sustainability of intelligent EV charging systems.
Recent work has adapted contrastive learning to time series, long-tailed data, and industrial fault diagnosis. Jin et al. analyzed false negatives and class imbalance in time-series contrastive learning and proposed a graph-assisted strategy to mitigate these issues [37]. Peng et al. used supervised contrastive learning with negative out-of-distribution augmentation for open-set fault diagnosis, showing that compact embeddings can improve fault discrimination [38]. Chang et al. introduced a rebalanced supervised contrastive learning method with prototypes for long-tailed visual recognition [39]. These studies indicate that contrastive objectives can improve representation separability, but many implementations still require a downstream classifier. In highly imbalanced EV charging data, the classifier head can again absorb class-frequency bias, which potentially reduces the robustness and long-term reliability of large-scale charging infrastructure monitoring.
Prototype-based learning provides an alternative decision rule. Prototypical networks represent each class by the mean embedding of its support samples and classify query samples according to distance to class prototypes [40]. This metric-based strategy has been extended to industrial scenarios. For example, Wan et al. proposed a multiview shapelet prototypical network for few-shot fault incremental learning, combining local temporal patterns with prototype-based decisions [41]. Prototype-based decisions are interpretable and parameter-efficient, making them suitable for lightweight and resource-efficient deployment in resource-constrained edge-intelligent charging infrastructure. However, prototype-based methods alone may be insufficient if the embedding space is not discriminative, especially when minority samples are scarce. Therefore, combining supervised contrastive representation learning with prototype-distance discrimination is a promising strategy for reliable and lightweight EV charging anomaly detection, but this combination remains underexplored for heterogeneous charging-pile features and extreme imbalance ratios.

2.4. Edge-Deployable Anomaly Detection

Reliable anomaly detection in EV charging infrastructure increasingly requires edge-deployable and energy-efficient intelligence close to the physical device to support large-scale charging networks. TinyML and edge intelligence aim to enable lightweight and energy-efficient machine-learning deployment on resource-constrained devices [42]. Model compression techniques such as pruning, quantization, and Huffman coding reduce storage and computation costs [43]. More directly related to EV charging, Dehrouyeh et al. investigated pruning-based TinyML optimization for anomaly detection in EV charging infrastructure and reported reductions in model size and inference time with limited performance degradation [44]. Sajun et al. proposed individualized edge-based anomaly detection for distributed solar farms, showing the practical value of localized diagnosis in energy systems [45]. Federated learning can further support distributed model training without directly sharing raw data [46], while knowledge distillation transfers behavior from a large teacher model to a smaller student model [47]. These techniques are useful for privacy-preserving and low-latency monitoring, but they generally optimize the deployment of an existing model rather than fundamentally addressing the reliable and identification of rare faults under imbalanced charging conditions. To summarize the reviewed methods and clarify the research gap addressed by this study, Table 1 compares representative anomaly-detection methods for EV charging infrastructure and related electrical systems.
After the general comparison of anomaly-detection methods, Table 2 further summarizes representative strategies for class imbalance, contrastive learning, prototype learning, and edge deployment.

2.5. Research Gap and Positioning of This Work

Despite recent progress, reliable and lightweight anomaly detection for EV charging infrastructure still faces several unresolved challenges under practical operating conditions.
First, charging anomalies are heterogeneous by nature. Abnormal operation may be associated with practical industrial failure scenarios such as contactor degradation caused by frequent switching cycles, converter instability under fluctuating charging loads, loose cable/interconnection behavior, safety-loop malfunction, actuator-state inconsistency, or harmonic distortion caused by nonlinear electrical disturbances. However, many existing studies focus mainly on charging-session records, vehicle-side battery signals, cyber-intrusion patterns, or single-type electrical indicators. The joint modeling of discrete control states and continuous power-quality features, such as voltage THD and current THD, remains insufficient for reliable and sustainable charging-infrastructure monitoring under complex real-world operating conditions.
Second, practical charging faults are relatively rare in large-scale EV charging networks, which results in severe class imbalance between normal and abnormal samples. Conventional supervised classifiers trained with cross-entropy or similar objectives tend to bias their decision boundaries toward the majority normal class, which increases the risk of missed detection for minority faults. Purely unsupervised methods can reduce dependence on labeled fault data, but they cannot fully exploit the limited labeled abnormal samples when such samples are available. Moreover, heterogeneous operating conditions may cause unsupervised boundaries to generate excessive false alarms, thereby reducing operational reliability in large-scale charging infrastructure.
Third, anomaly detection in charging infrastructure is expected to operate close to the charging controller or station gateway. Therefore, the detection model should satisfy strict requirements on memory footprint, inference latency, privacy, and deployment simplicity. Existing TinyML, pruning, distillation, and federated-learning studies can improve deployment efficiency, but they mainly optimize the model after training and do not fundamentally solve the representation-learning problem caused by rare faults and long-tailed data distributions. The overall structure and workflow of the proposed PCDL framework are illustrated in Figure 1.
To address these issues, this work proposes a lightweight Proto-Contrastive Discriminative Learning (PCDL) framework for EV charging anomaly detection under class imbalance. The proposed framework first uses supervised contrastive learning to organize heterogeneous charging features into a more separable embedding space. It then replaces the conventional classifier head with a prototype-distance-based discrimination mechanism where test samples are identified according to their relative distances to normal and abnormal prototypes. This design aims to reduce class-prior-induced decision bias, improve interpretability through geometric anomaly scores while maintaining lightweight and resource-efficient edge deployment. The overall framework is shown in Figure 1. To provide a structured overview of the landscape, Table 1 summarizes representative anomaly detection methods for EV charging infrastructure, contrasting their core ideas, advantages, and specific limitations for this task. Complementing this, Table 2 compares key strategies for handling class imbalance and representation learning, highlighting how they differ from the proposed PCDL approach.
The main contributions of this work are summarized as follows:
  • A heterogeneous anomaly detection formulation is developed for EV charging infrastructure by jointly considering discrete control/safety-loop signals and continuous power-quality indicators.
  • A supervised contrastive encoder is introduced to improve intra-class compactness and inter-class separation under highly imbalanced charging data, which enhances reliable fault identification in complex charging environments.
  • A parameter-free prototype-distance discrimination mechanism is proposed to replace the conventional classifier head, which reduces class-prior-induced decision bias and supports lightweight resource-efficient deployment.
  • The edge-deployment feasibility of the proposed framework is evaluated under controlled imbalance ratios, including an extreme 1:100 setting, with comparisons against representative supervised and unsupervised baselines.

3. Methodology

3.1. Problem Definition

Let the charging-state sample dataset be
D = ( x i , y i ) i = 1 N ,   y i { 0 , 1 } ,   x i d
where X denotes the charging-state dataset, N is the total number of samples, d is the input feature dimension, and x i R d represents the i - th charging sample within a sampling window. Each sample consists of heterogeneous charging-pile features, including discrete control-logic states and continuous power-quality indicators. The corresponding label is denoted by y i , where y i = 0 represents the normal charging state and y i = 1 represents the abnormal charging state. Therefore, the supervised anomaly-detection task can be formulated as learning a discriminant function that maps each input sample x i to its predicted operating state.
Under severe class imbalance, where abnormal samples are much fewer than normal samples, the objective is to learn a robust discriminant function:
f ( x ) : d { 0 , 1 }
Existing industrial fault diagnosis studies indicate that under extreme long-tail distributions, minority fault features are easily overwhelmed by massive normal samples, inducing systematic model bias [32,48]. Therefore, constructing a representation space that is insensitive to sample quantities and capable of maximizing inter-class margins is crucial for reliable detection.

3.2. Supervised Contrastive Encoder

To satisfy the low-latency inference requirement of edge devices [42,44], a lightweight multilayer perceptron (MLP) is adopted as the feature encoder to project the input features into a low-dimensional normalized embedding space:
z i = f θ ( x i ) f θ ( x i )
To alleviate feature overlap and decision boundary shift caused by the dominance of majority-class samples in the representation space, a supervised contrastive loss is introduced to optimize the encoder [35]. Recent studies have shown that contrastive learning can improve representation separability in complex tasks, including fault diagnosis for EV batteries and charging systems [35,37,38]. By incorporating class labels during training, the supervised contrastive objective encourages samples from the same class to cluster more closely in the embedding space while increasing the separation between samples from different classes:
L s u p = i 1 | P ( i ) | p P ( i ) log exp ( z i z p / τ ) a i exp ( z i z a / τ )
where I is the set of all indices in a training batch, P ( i ) is the index set of positive samples that share the same class label as the anchor, a denotes the indices of all contrastive samples in the same mini-batch except the anchor, and τ is the temperature hyperparameter that controls the smoothness of the contrastive distribution.

3.3. Prototype-Distance Discrimination Mechanism

Conventional fully connected classifier heads are highly susceptible to decision boundary shift in imbalanced feature spaces [32,48]. Inspired by the prototypical networks used in few-shot learning [40], we design a parameter-free prototype distance scoring mechanism. First, the class prototypes for the normal and anomalous categories are computed within the trained embedding space:
μ k = 1 N k y i = k z i , k { 0 , 1 }
where N k denotes the number of samples in class k . During real-time inference, for an unseen test sample x * with embedding feature z * , an anomaly score is calculated based on the Euclidean distance difference between the sample and the two prototypes:
s ( x * ) = z * μ 0 z * μ 1
If s ( x * ) > 0 , the state is classified as anomalous; otherwise, it is normal. Unlike traditional classifiers that rely on absolute probability thresholds, this geometric metric makes decisions based solely on relative distance relationships. Consequently, its discrimination logic is highly insensitive to variations in class proportions, maintaining stable performance under extreme imbalance while significantly reducing the model’s parameter size and memory footprint for edge deployment [42,44]. Based on the above definitions, the complete training and anomaly-detection procedure of the proposed PCDL framework is summarized in Algorithm 1.
Algorithm 1: Training and Inference Procedure of PCDL
Input:
Training dataset D = { ( x i , y i ) } i = 1 N
Encoder network f θ ·
Batch size B
Temperature parameter τ
Output:
Trained encoder f θ
Class prototypes c n o r m a l , c a n o m a l y
Training Phase:
1: Initialize encoder parameters θ
2: for each training epoch do
3: Sample a mini-batch { ( x i , y i ) } i = 1 B ~ D
4: Compute embeddings z i = f θ ( x i )
5: Normalize embeddings z i z i z i
6: Compute supervised contrastive loss L s u p using Equation (4)
7: Update encoder parameters θ using gradient descent
8: end for
9: Compute class prototypes:
10: c k = 1 N k i : y i = k f θ ( x i ) , k { normal , anomaly }
Inference Phase:
11: Given a test sample   x
12: Compute embedding z = f θ ( x )
13: Compute distances:
14: d normal = z c normal
15: d anomaly = z c anomaly
16: Compute anomaly score:
17: s ( x ) = d normal d anomaly
18: if s   >   0 then
19: Predict anomaly
20: else
21: Predict normal
22: end if

3.4. Overall Training and Inference Procedure

To provide a clearer description of the proposed Proto-Contrastive Discriminative Learning (PCDL) framework, the overall training and inference procedure is summarized in Algorithm 1.
During training, the encoder is optimized using supervised contrastive learning to construct a structured embedding space, where samples from the same class are clustered together while samples from different classes are pushed apart. After training, class prototypes are computed as the mean embeddings of each class.
During inference, anomaly detection is performed by comparing the relative distances between a test sample and the learned class prototypes, without relying on a conventional classifier head.

3.5. Computational Complexity Analysis

In this subsection, we analyze the computational complexity and memory requirements of the proposed PCDL framework and compare them with representative baseline methods. To improve readability, the main symbols used in the computational complexity analysis are summarized in Table 3.
(1)
Training Complexity
During training, the main computational cost arises from the encoder forward pass and the supervised contrastive loss computation.
Let N denote the number of training samples, d the input feature dimension, and d e the embedding dimension. The encoder, implemented as a lightweight multilayer perceptron (MLP), has a computational complexity of approximately O ( N · d · d e ) .
The supervised contrastive loss requires pairwise similarity computation within each mini-batch. For a batch size of B , this introduces an additional cost of O ( B 2 · d e ) . However, since is typically much smaller than N, this term does not dominate the overall training complexity.
(2)
Inference Complexity
During inference, PCDL only requires a single forward pass through the encoder and a distance computation to class prototypes.
The complexity can be expressed as O ( d · d e )   +   O ( d e ) , which corresponds to feature projection through the encoder and Euclidean distance computation to two prototypes.
This results in an overall linear complexity with respect to the embedding dimension compared with other methods:
-
KNN requires O ( N · d e ) per query due to distance computation with all training samples.
-
CNN/RNN-based models involve multiple convolutional or recurrent operations, leading to higher computational overhead.
-
Isolation Forest requires traversal of multiple trees, resulting in O ( T · l o g   N ) complexity.
(3)
Memory Consumption
The memory footprint of PCDL is dominated by the encoder parameters and the storage of class prototypes.
In this work, the encoder is designed as a compact MLP with a small number of parameters. The total model size is approximately 11 KB, which includes encoder weights and two class prototype vectors of dimension d e .
Unlike instance-based methods such as KNN, which must store the entire training dataset, PCDL only stores a constant number of parameters, resulting in O ( 1 ) memory complexity with respect to dataset size. The above analysis shows that PCDL achieves a favorable balance between computational efficiency and detection performance. Its lightweight architecture and prototype-based inference mechanism significantly reduce both time and memory costs, so it is well suited for deployment on resource-constrained edge devices in EV charging infrastructure.

4. Experimental Setup

4.1. Datasets and Heterogeneous Features

In this study, the Baidu charging-pile fault classification and detection dataset is used for experimental evaluation. The dataset was released to support research on fault detection and prediction for electric vehicle charging facilities. It contains 85,500 training samples and 36,644 test samples. Each sample includes multiple monitoring feature fields and a binary operating-state label, where 0 denotes a normal charging pile and 1 denotes a faulty charging pile.
It should be noted that the dataset was not collected directly by the authors. Therefore, detailed station-level metadata, such as exact charging-station location, charger model, sampling frequency, sampling duration, detailed sensor installation configuration, and environmental operating conditions, are not fully disclosed in the original dataset. Accordingly, this study focuses on the available feature fields and binary fault labels provided by the dataset.
From the available feature fields, this study selects six diagnosis-related features to construct the input vector for anomaly detection. These features include two groups of heterogeneous charging-pile monitoring variables. The first group consists of four discrete control/safety-loop features, including the K1/K2 drive signal, electronic-lock drive signal, emergency-stop signal, and access-control signal. These features describe the logical and actuator-related operating states of the charging pile, such as contactor drive status, electronic-lock response, emergency-stop condition, and access-control status.
The second group consists of two continuous power-quality features, namely voltage total harmonic distortion (THD_V) and current total harmonic distortion (THD_I), which characterize harmonic distortion and power-quality fluctuation during charging operation. Therefore, each input sample used in this study is represented by a six-dimensional heterogeneous feature vector. The discrete features mainly describe control-logic and safety-loop states, whereas the continuous THD features describe electrical power-quality behavior.
To further investigate the differences between the two classes, Figure 2 presents the distributions of six representative features for normal and fault samples. These plots illustrate not only the overall spread of each feature, but also the differences in median values, interquartile ranges, and outlier patterns between the two classes. For the control-signal-related features, fault samples show more evident outlier behavior, which may be associated with irregular switching actions or abnormal response processes during charging. In contrast, the THD-related features exhibit relatively concentrated distributions and clearer separation patterns, indicating that harmonic distortion provides useful information for identifying abnormal operating conditions. Overall, these visual results suggest that the selected features contain meaningful discriminative information for distinguishing normal and faulty samples, thereby supporting their use in the subsequent anomaly detection analysis.
The abnormal category represents faulty charging-pile states provided by the dataset. According to the selected feature fields, these abnormal states may be reflected by control-signal inconsistency, contactor-related switching abnormality, electronic-lock control anomaly, emergency-stop or safety-loop inconsistency, abnormal access-control status, and THD-related power-quality deterioration. Since the original dataset provides binary fault labels rather than detailed maintenance records for each sample, this study formulates the task as binary anomaly detection and does not further divide faulty samples into fine-grained fault subclasses. To further reveal the transient dynamics of these anomalies, Figure 3 presents a direct comparison of raw signals. As shown in Figure 3a, the K1/K2 drive signal in the fault state exhibits noticeable peak deviation, which corresponds to the temporal jitter and logical disorder in the control loop mentioned in Section 1. Such micro-fluctuations are often overwhelmed by measurement noise, making them difficult to capture using standard classifiers. Simultaneously, the current THD trace in Figure 3b captures a clear anomalous interval and sudden harmonic peaks. It is important to note that these harmonic peaks are not caused by short-circuit events; rather, they reflect power-quality degradation induced by non-short-circuit faults, such as contactor contact arcing, aging of power electronic switches (e.g., converter rectifiers), or unbalanced load conditions. Such harmonic distortions are subtle but critical indicators of developing abnormalities in charging infrastructure, enabling early warning before catastrophic failures occur. These visualizations explain the significant feature overlap in the raw space and justify the necessity of using a contrastive learning framework to pull these subtle fault-discriminative patterns away from the dominant normal clusters.
To evaluate the performance of the proposed method under different class-imbalance conditions, three training datasets were constructed with imbalance ratios (IRs) of 1:1, 1:10, and 1:100 by adjusting the proportion of abnormal samples. This design makes it possible to examine, in a controlled manner, how the progressive reduction in fault samples affects model training and detection capability. As the imbalance ratio increases, the minority fault class becomes increasingly underrepresented, which poses greater difficulty for representation learning and classification.
Unlike the training sets, the test set was kept unchanged and maintained at a balanced ratio of 1:1 throughout all experiments. This setting was adopted to ensure a fair comparison among different training scenarios so that the evaluation results would reflect differences in model learning ability rather than distributional bias in the test data. Figure 4 shows the numbers of normal and abnormal samples in each dataset configuration and further presents the THD scatter distributions under different imbalance ratios. These visualizations provide an intuitive view of how the data distribution changes as class imbalance becomes more severe. They offer additional context for the subsequent performance comparison.
To further evaluate the discriminative quality of the learned features, Figure 5 compares the two-dimensional sample distributions in the original feature space and in the embedding space generated by PCDL. In the original feature space, normal and fault samples overlap considerably, which indicates limited class discrimination and unclear decision boundaries. After transformation by PCDL, samples from the same class become noticeably more concentrated, while the separation between different classes becomes more evident. This trend can still be observed under different imbalance ratios, including 1:1, 1:10, and 1:100, indicating that PCDL is able to learn a more organized and discriminative feature space. Even when the imbalance becomes severe, the embedded representations still preserve relatively clear class structure and stable separability, which further demonstrates the effectiveness and robustness of the proposed method.
From an engineering perspective, these abnormal states are closely related to practical industrial maintenance concerns in EV charging stations. For example, repeated contactor switching may gradually introduce relay wear and unstable conduction behavior, while prolonged high-load operation may increase harmonic distortion and converter stress. Early identification of these abnormal electrical states is therefore important for improving charging reliability, reducing unexpected downtime, and supporting preventive maintenance scheduling.

4.2. Baseline Models and Implementation Settings

To evaluate the performance of PCDL in a comprehensive manner, comparative experiments were conducted using eight representative baseline models from three categories that are widely used in anomaly detection tasks. The first category includes traditional unsupervised methods, namely One-Class Support Vector Machine (One-Class SVM) [6], Isolation Forest (IForest) [7], and Elliptic Envelope [8]. These methods are commonly used to identify abnormal patterns through boundary estimation or density-based modeling. The second category consists of conventional supervised models, including K-Nearest Neighbors (KNN) [22] and Artificial Neural Network (ANNs) [23], which serve as standard classification benchmarks. The third category includes methods with stronger temporal modeling or decision-making capability, including one-dimensional convolutional neural network (CNN-1D) [24], recurrent neural network (RNN/LSTM) [25], and the Proximal Policy Optimization (PPO) framework [26].
To ensure fair testing, each baseline adheres to its standard discrimination mechanism: supervised deep learning models utilize ReLU hidden layers and a Sigmoid output layer with a fixed 0.5 probability threshold, while unsupervised models rely on internally learned geometric or density boundaries. The detailed parameter settings of all compared methods are summarized in Table 4.
For a fair comparison, each baseline follows its standard prediction mechanism. The supervised deep learning models use ReLU-based hidden layers and a Sigmoid output layer with a fixed decision threshold of 0.5, whereas the unsupervised methods rely on their own learned geometric or density-based criteria. Under highly imbalanced data distributions, however, methods based on fixed probability thresholds or static density boundaries are more likely to suffer from decision bias toward the majority class [32,48]. In contrast, PCDL performs anomaly discrimination through a parameter-free relative distance metric in the embedding space. Instead of depending on an explicit classifier head, it evaluates the positional relationship between a sample and the class prototypes, which makes the decision process less sensitive to class proportion changes and improves robustness under long-tail conditions [32,39].
To further ensure fairness, all models were trained and tested on the same hardware and software platform, with the exception of PPO, which interacts only with the training set during its learning phase. The experimental platform consisted of an RTX 5090 GPU, an Intel Xeon Platinum 8470Q CPU, 90 GB RAM, and Ubuntu 20.04.

5. Experimental Results and Discussion

5.1. Definition of Evaluation Metrics

The performance results reported in Table 5 are evaluated using four commonly used metrics, namely Accuracy, Precision, Recall, and F1-score. These metrics are computed from the standard confusion matrix. Specifically, true positive (TP) denotes anomalies that are correctly identified, false positive (FP) refers to normal samples that are incorrectly classified as anomalies, false negative (FN) represents anomalies that are not detected, and true negative (TN) denotes normal samples that are correctly recognized. The corresponding definitions are given as follows:
A c c u r a c y = T P + T N T P + T N + F P + F N
P e c i s i o n = T P T P + F P
R e c a l l = T P T P + F N
F 1 = 2 P r e c i s i o n R e c a l l P r e c i s i o n + R e c a l l
Under severe class imbalance, accuracy alone may give an overly favorable impression of model performance. For this reason, greater attention is paid to the balance between Precision and Recall so that the model can be evaluated more appropriately in terms of both false alarms and missed detections.

5.2. Detection Performance Comparison Under Varying Imbalance Degrees

The performance of all compared methods under three imbalance ratios (IRs), namely 1:1, 1:10, and 1:100, is summarized in Table 5. Under the balanced 1:1 setting, most supervised deep learning models, including ANN, CNN, and RNN, show relatively balanced detection performance, with F1-scores generally above 88%. However, as the imbalance ratio increases to 1:10, the performance of conventional models begins to deteriorate. For instance, the Recall of CNN decreases to 55.52%, indicating that its detection capability for minority fault samples is significantly weakened as the training data become more imbalanced. In contrast, PCDL still maintains an F1-score of 87.87% under the same condition, showing better stability against the reduction in fault samples.
When the imbalance becomes more severe at 1:100, the limitations of conventional methods are more evident. The Recall of RNN (LSTM) drops sharply to 4.77%, which means that most fault samples are no longer correctly identified. Although unsupervised methods such as IForest retain a relatively high Recall, they also produce a large number of false alarms. In the present experiments, IForest identifies 34,695 samples as anomalies, suggesting limited ability to distinguish actual faults from complex electrical disturbances. By comparison, PCDL achieves an F1-score of 84.21% under the same setting, which is about 29.08% higher than that of the strongest baseline, IForest. It is also worth noting that the number of anomalies detected by PCDL remains within the range of 16,000 to 18,000 across all imbalance ratios. This relatively stable behavior further indicates that the proposed method is less sensitive to changes in class distribution and maintains more consistent detection performance under long-tail conditions.
It should be noted that recent PSO-BiLSTM and other optimized sequence-learning methods have reported strong results on EV charging or distribution-network fault datasets. However, their reported metrics are based on different data sources, input streams, and task settings, and therefore cannot be directly compared with the fixed six-feature class-imbalanced diagnosis setting used in this study.

5.3. Analysis of Inference Efficiency and Model Scale

The influence of model architecture on deployment feasibility at the edge side is illustrated in Figure 6 and Figure 7. As shown in Figure 6, the memory footprint of PCDL remains at about 11 KB under all imbalance settings. This is substantially smaller than that of the compared methods and is particularly favorable for resource-constrained edge devices. In contrast, several baseline models require much more storage, especially KNN, whose memory usage reaches the megabyte level.
A similar advantage can be observed in inference latency. As shown in Figure 7, PCDL maintains stable CPU inference time at the millisecond level, ranging from approximately 4.9 to 6.3 ms across different imbalance ratios. Such latency is sufficient for real-time anomaly detection in charging scenarios. In comparison, methods such as IForest, SVM, and especially KNN require longer inference time and may therefore create throughput limitations in large-scale deployment. Taken together, these results show that PCDL provides a more favorable balance between model compactness and inference efficiency, which is applicable in real-time edge-side charging devices.
Beyond memory and latency advantages, the lightweight nature of PCDL offers tangible environmental benefits for sustainable charging infrastructure. Compared to conventional deep learning models that typically require GPU acceleration, PCDL operates entirely on CPU with only ~11 KB of parameters and sub-6.3 ms inference time. This reduces per-inference energy consumption by an estimated 90–95%, leading to a significantly lower carbon footprint for large-scale edge deployments involving thousands of charging piles. Furthermore, by enabling early detection of non-catastrophic faults (e.g., contactor arcing, THD degradation), the framework helps prevent progressive equipment damage. Based on industry maintenance reports for EV charging infrastructure, such early warning can extend the operational lifetime of charging piles by an estimated 15–25% and reduce unexpected downtime by approximately 30%.

6. Conclusions

This paper proposes Proto-Contrastive Discriminative Learning (PCDL), a lightweight anomaly diagnosis framework for EV charging infrastructure under class-imbalanced conditions. By combining supervised contrastive representation learning with prototype-distance-based discrimination, PCDL improves the recognition of rare abnormal electrical states, including control-loop abnormalities, safety-related actuator inconsistencies, and THD-related power-quality disturbances. These abnormal states are closely related to the reliable operation of charging stations, since undetected faults may lead to service interruption, unnecessary maintenance, or degradation of key components.
The experimental results show that PCDL maintains stable detection performance under different imbalance settings. The F1-scores are 88.96%, 87.87%, and 84.21% when the training imbalance ratios are 1:1, 1:10, and 1:100, respectively. Under the most challenging 1:100 setting, where fault samples are extremely limited, PCDL still keeps a reasonable balance between Precision and Recall. Compared with the strongest baseline, IForest, the proposed method improves the F1-score by 29.08% under this condition.
The deployment results further show that PCDL is suitable for resource-constrained charging scenarios. The model requires only about 11 KB of memory and maintains millisecond-level CPU inference latency, which makes station-side deployment feasible without adding a heavy computational burden. In practical operation, this type of early-warning model can assist maintenance staff in arranging preventive inspection before abnormal electrical behavior develops into more serious charging failures.
In this paper, sustainability is discussed only from the operational perspective, namely charger availability, preventive maintenance, and low-cost station-side monitoring. The present study does not provide a full lifecycle assessment, nor does it directly quantify CO2 emissions, raw material consumption, energy-efficiency gains, or end-of-life disposal impacts. These environmental indicators require additional lifecycle inventory data, equipment lifetime records, and energy-consumption measurements, and should therefore be addressed in future work.
Several limitations remain. First, the experimental data were collected from a single charging network, so the transferability of PCDL to other regions, operators, or charger models still needs further validation. Second, the current framework uses a fixed set of six features, and its adaptation to different sensing configurations should be studied further. Future work will focus on cross-network validation, online model updating, multi-source sensing data, and distributed edge collaboration for practical EV charging environments.

Author Contributions

Conceptualization, Z.L., B.X. and Y.Y.; methodology, B.X. and J.L.; software, B.X. and J.L.; validation, T.M.; formal analysis, B.X. and J.L.; investigation, J.L., Y.Y. and Y.L.; data curation, B.X.; writing—original draft preparation, Z.L. and B.X.; writing—review and editing, J.L. and T.M.; visualization, B.X.; supervision, T.M.; project administration, Y.Y. and Y.L. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The original data used in this study are from the Baidu charging-pile fault classification and detection dataset. The processed feature files and experimental scripts are available from the corresponding author upon reasonable request.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
EVElectric Vehicle
THDTotal Harmonic Distortion
THD_VVoltage Total Harmonic Distortion
THD_ICurrent Total Harmonic Distortion
PCDLProto-Contrastive Discriminative Learning
MLPMultilayer Perceptron
IRImbalance Ratio
CPUCentral Processing Unit
KNNK-Nearest Neighbors
ANNArtificial Neural Network
CNNConvolutional Neural Network
RNNRecurrent Neural Network
LSTMLong Short-Term Memory
PPOProximal Policy Optimization
SVMSupport Vector Machine
IForestIsolation Forest
TPTrue Positive
FPFalse Positive
TNTrue Negative
FNFalse Negative
ACAlternating Current
DCDirect Current
O · Big-O Notation

References

  1. International Energy Agency. Global EV Outlook 2025; IEA: Paris, France, 2025. [Google Scholar]
  2. IEC 61851-1:2017; Electric Vehicle Conductive Charging System-Part 1: General Requirements. International Electrotechnical Commission (IEC): Geneva, Switzerland, 2017.
  3. Powell, B.; Johnson, C. Impact of Electric Vehicle Charging Station Reliability, Resilience, and Location on Electric Vehicle Adoption; Technical Report NREL/TP-5R00-89896; National Renewable Energy Laboratory: Golden, CO, USA, 2024. [Google Scholar]
  4. Gernandt, H.; Severino, B.; Zhang, X.; Mehrmann, V.; Strunz, K. Port-Hamiltonian Modeling and Control of Electric Vehicle Charging Stations. arXiv 2024, arXiv:2407.10544. [Google Scholar] [CrossRef]
  5. Shi, H.; He, Y.; Song, S.; Zhuge, J.; Mao, J. Physical-Layer Signal Injection Attacks on EV Charging Ports: Bypassing Authentication via Electrical-Level Exploits. arXiv 2025, arXiv:2506.16400. [Google Scholar]
  6. Scholkopf, B.; Platt, J.C.; Shawe-Taylor, J.; Smola, A.J.; Williamson, R.C. Estimating the Support of a High-Dimensional Distribution. Neural Comput. 2001, 13, 1443–1471. [Google Scholar] [CrossRef]
  7. Liu, F.T.; Ting, K.M.; Zhou, Z.-H. Isolation Forest. In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining, Pisa, Italy, 15–19 December 2008; pp. 413–422. [Google Scholar] [CrossRef]
  8. Rousseeuw, P.J.; Van Driessen, K. A Fast Algorithm for the Minimum Covariance Determinant Estimator. Technometrics 1999, 41, 212–223. [Google Scholar] [CrossRef]
  9. Tax, D.M.J.; Duin, R.P.W. Support Vector Data Description. Mach. Learn. 2004, 54, 45–66. [Google Scholar] [CrossRef]
  10. Ruff, L.; Vandermeulen, R.; Goernitz, N.; Deecke, L.; Siddiqui, S.A.; Binder, A.; Mueller, E.; Kloft, M. Deep One-Class Classification. In Proceedings of the 35th International Conference on Machine Learning, Stockholm, Sweden, 10–15 July 2018; pp. 4393–4402. [Google Scholar]
  11. Ji, Y.; Lee, H. Event-Based Anomaly Detection Using a One-Class SVM for a Hybrid Electric Vehicle. IEEE Trans. Veh. Technol. 2022, 71, 6032–6043. [Google Scholar] [CrossRef]
  12. Diao, X.; Jiang, L.; Gao, T.; Zhang, L.; Zhang, J.; Wang, L.; Wu, Q. Research on Electric Vehicle Charging Safety Warning Based on A-LSTM Algorithm. IEEE Access 2023, 11, 55081–55093. [Google Scholar] [CrossRef]
  13. Feng, Q.; Li, H.; Zhou, Y.; Feng, D.; Wang, Y.; Su, Y. Review of Electric Vehicles’ Charging Data Anomaly Detection Based on Deep Learning. In Proceedings of the 2022 Power System and Green Energy Conference (PSGEC), Shanghai, China, 25–27 August 2022; pp. 337–341. [Google Scholar] [CrossRef]
  14. Kesavan, V.T.; Hossen, M.J.; Gopi, R.; Joseph, E.R. Anomaly Detection with Grid Sentinel Framework for Electric Vehicle Charging Stations in a Smart Grid Environment. Sci. Rep. 2025, 15, 15774. [Google Scholar] [CrossRef]
  15. Shufian, A.; Hannan, N.; Hossain Emon, M.M.; Kabir, S.; Fattah, S.A.; Hossain, M.S. Automatic Fault Detection and Analysis of Electric Vehicle Charging Station by Machine Learning. In Proceedings of the 2024 IEEE Region 10 Symposium (TENSYMP), New Delhi, India, 27–29 September 2024; pp. 1–6. [Google Scholar] [CrossRef]
  16. Grcic, I.; Pandzic, H.; Sunde, V. Electric Vehicle Charging Station Fault Detection: A Machine Learning Approach. In Proceedings of the CIRED Porto Workshop 2022: E-Mobility and Power Distribution Systems, Porto, Portugal, 2–3 June 2022; pp. 745–749. [Google Scholar] [CrossRef]
  17. Bin Kaleem, M.; Zhou, Y.; Jiang, F.; Liu, Z.; Li, H. Fault Detection for Li-ion Batteries of Electric Vehicles with Segmented Regression Method. Sci. Rep. 2024, 14, 31922. [Google Scholar] [CrossRef]
  18. Hosseini, S.A.; Taheri, B.; Sadeghi, S.H.H.; Nasiri, A. A deep learning model for fault detection in distribution networks with high penetration of electric vehicle chargers. e-Prime—Advances in Electrical Engineering. Electron. Energy 2024, 10, 100845. [Google Scholar] [CrossRef]
  19. Ji, Y.; Gu, L.; Huang, H.; Wang, W.; Zhang, W. Research on fault prediction and management of charging station combined with deep learning model. Int. J. Low Carbon Technol. 2025, 20, 848–854. [Google Scholar] [CrossRef]
  20. Kamoona, A.; Song, H.; Jalili, M.; Wang, H.; Razzaghi, R.; Yu, X. Online Electric Vehicle Charging Detection Based on Memory-Based Transformer Using Smart Meter Data. Appl. Energy 2025, 398, 126353. [Google Scholar] [CrossRef]
  21. Liu, Z.; Wang, Y.; Wang, Q.; Hu, M. Vision Transformer-Based Anomaly Detection in Smart Grid Phasor Measurement Units Using Deep Learning Models. IEEE Access 2025, 13, 44565–44576. [Google Scholar] [CrossRef]
  22. Cover, T.M.; Hart, P.E. Nearest Neighbor Pattern Classification. IEEE Trans. Inf. Theory 1967, 13, 21–27. [Google Scholar] [CrossRef]
  23. Rumelhart, D.E.; Hinton, G.E.; Williams, R.J. Learning Representations by Back-Propagating Errors. Nature 1986, 323, 533–536. [Google Scholar] [CrossRef]
  24. LeCun, Y.; Bottou, L.; Bengio, Y.; Haffner, P. Gradient-Based Learning Applied to Document Recognition. Proc. IEEE 1998, 86, 2278–2324. [Google Scholar] [CrossRef]
  25. Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed]
  26. Schulman, J.; Wolski, F.; Dhariwal, P.; Radford, A.; Klimov, O. Proximal Policy Optimization Algorithms. arXiv 2017, arXiv:1707.06347. [Google Scholar] [CrossRef]
  27. Chawla, N.V.; Bowyer, K.W.; Hall, L.O.; Kegelmeyer, W.P. SMOTE: Synthetic Minority Over-Sampling Technique. J. Artif. Intell. Res. 2002, 16, 321–357. [Google Scholar] [CrossRef]
  28. Goodfellow, I.; Pouget-Abadie, J.; Mirza, M.; Xu, B.; Warde-Farley, D.; Ozair, S.; Courville, A.; Bengio, Y. Generative Adversarial Nets. In Advances in Neural Information Processing Systems 27; Curran Associates, Inc.: Red Hook, NY, USA, 2014; pp. 2672–2680. [Google Scholar]
  29. Ho, J.; Jain, A.; Abbeel, P. Denoising Diffusion Probabilistic Models. In Advances in Neural Information Processing Systems 33; Curran Associates, Inc.: Red Hook, NY, USA, 2020; pp. 6840–6851. [Google Scholar]
  30. Lin, T.-Y.; Goyal, P.; Girshick, R.; He, K.; Dollar, P. Focal Loss for Dense Object Detection. In Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy, 22–29 October 2017; pp. 2980–2988. [Google Scholar]
  31. Cui, Y.; Jia, M.; Lin, T.-Y.; Song, Y.; Belongie, S. Class-Balanced Loss Based on Effective Number of Samples. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Long Beach, CA, USA, 16–20 June 2019; pp. 9268–9277. [Google Scholar] [CrossRef]
  32. Zhang, Y.; Kang, B.; Hooi, B.; Yan, S.; Feng, J. Deep Long-Tailed Learning: A Survey. IEEE Trans. Pattern Anal. Mach. Intell. 2023, 45, 10795–10816. [Google Scholar] [CrossRef]
  33. Chen, T.; Kornblith, S.; Norouzi, M.; Hinton, G. A Simple Framework for Contrastive Learning of Visual Representations. In Proceedings of the 37th International Conference on Machine Learning, Virtual, 13–18 July 2020; pp. 1597–1607. [Google Scholar]
  34. He, K.; Fan, H.; Wu, Y.; Xie, S.; Girshick, R. Momentum Contrast for Unsupervised Visual Representation Learning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020; pp. 9729–9738. [Google Scholar]
  35. Khosla, P.; Teterwak, P.; Wang, C.; Sarna, A.; Tian, Y.; Isola, P.; Maschinot, A.; Liu, C.; Krishnan, D. Supervised Contrastive Learning. In Advances in Neural Information Processing Systems 33; Curran Associates, Inc.: Red Hook, NY, USA, 2020; pp. 18661–18673. [Google Scholar]
  36. Wang, T.; Isola, P. Understanding Contrastive Representation Learning through Alignment and Uniformity on the Hypersphere. In Proceedings of the 37th International Conference on Machine Learning, Virtual, 13–18 July 2020; pp. 9929–9939. [Google Scholar]
  37. Jin, X.; Wang, J.; Ou, X.; Liu, L.; Lin, Y. Time-Series Contrastive Learning Against False Negatives and Class Imbalance. IEEE Trans. Neural Netw. Learn. Syst. 2025, 36, 16946–16959. [Google Scholar] [CrossRef]
  38. Peng, P.; Lu, J.; Xie, T.; Tao, S.; Wang, H.; Zhang, H. Open-Set Fault Diagnosis via Supervised Contrastive Learning with Negative Out-of-Distribution Data Augmentation. IEEE Trans. Ind. Inform. 2023, 19, 2463–2473. [Google Scholar] [CrossRef]
  39. Chang, X.; Zhai, J.; Qiu, S.; Sun, Z. Rebalanced Supervised Contrastive Learning with Prototypes for Long-Tailed Visual Recognition. Comput. Vis. Image Underst. 2025, 252, 104291. [Google Scholar] [CrossRef]
  40. Snell, J.; Swersky, K.; Zemel, R.S. Prototypical Networks for Few-Shot Learning. In Advances in Neural Information Processing Systems 30; Curran Associates, Inc.: Red Hook, NY, USA, 2017; pp. 4077–4087. [Google Scholar]
  41. Wan, X.; Cen, L.; Chen, X.; Xie, Y.; Gui, W. Multiview Shapelet Prototypical Network for Few-Shot Fault Incremental Learning. IEEE Trans. Ind. Inform. 2024, 20, 11751–11762. [Google Scholar] [CrossRef]
  42. Warden, P.; Situnayake, D. TinyML: Machine Learning with TensorFlow Lite on Arduino and Ultra-Low-Power Microcontrollers; O’Reilly Media: Sebastopol, CA, USA, 2019. [Google Scholar]
  43. Han, S.; Mao, H.; Dally, W.J. Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding. In Proceedings of the International Conference on Learning Representations, San Juan, Puerto Rico, 2–4 May 2016. [Google Scholar]
  44. Dehrouyeh, F.; Shaer, I.; Nikan, S.; Ajaei, F.B.; Shami, A. Pruning-Based TinyML Optimization of Machine Learning Models for Anomaly Detection in Electric Vehicle Charging Infrastructure. In Proceedings of the ICC 2025-IEEE International Conference on Communications, Montreal, QC, Canada, 8–12 June 2025; pp. 1195–1200. [Google Scholar] [CrossRef]
  45. Sajun, A.R.; Shapsough, S.; Zualkernan, I.; Dhaouadi, R. Edge-Based Individualized Anomaly Detection in Large-Scale Distributed Solar Farms. ICT Express 2022, 8, 174–178. [Google Scholar] [CrossRef]
  46. McMahan, H.B.; Moore, E.; Ramage, D.; Hampson, S.; y Arcas, B.A. Communication-Efficient Learning of Deep Networks from Decentralized Data. In Proceedings of the 20th International Conference on Artificial Intelligence and Statistics, Fort Lauderdale, FL, USA, 20–22 April 2017; pp. 1273–1282. [Google Scholar]
  47. Hinton, G.; Vinyals, O.; Dean, J. Distilling the Knowledge in a Neural Network. arXiv 2015, arXiv:1503.02531. [Google Scholar] [CrossRef]
  48. He, H.; Garcia, E.A. Learning from Imbalanced Data. IEEE Trans. Knowl. Data Eng. 2009, 21, 1263–1284. [Google Scholar] [CrossRef]
Figure 1. Overall workflow of the proposed PCDL framework.
Figure 1. Overall workflow of the proposed PCDL framework.
Sustainability 18 05783 g001
Figure 2. Distribution comparison of six key features across normal and abnormal samples.
Figure 2. Distribution comparison of six key features across normal and abnormal samples.
Sustainability 18 05783 g002aSustainability 18 05783 g002b
Figure 3. Comparison of raw signal characteristics between normal and abnormal charging states: (a) K1/K2 drive signal highlighting peak deviation caused by control jitter. (b) Current THD trace showing anomalous intervals and fault-induced harmonic peaks caused by non-short-circuit faults (e.g., contactor arcing, converter aging, or unbalanced loading).
Figure 3. Comparison of raw signal characteristics between normal and abnormal charging states: (a) K1/K2 drive signal highlighting peak deviation caused by control jitter. (b) Current THD trace showing anomalous intervals and fault-induced harmonic peaks caused by non-short-circuit faults (e.g., contactor arcing, converter aging, or unbalanced loading).
Sustainability 18 05783 g003
Figure 4. Class-imbalance overview and THD scatter distributions under different imbalance ratios. (a) Sample counts of normal and abnormal instances in the training sets with IRs of 1:1, 1:10, and 1:100. (b) THD distribution in the voltage-current plane for IR = 1:1. (c) THD distribution in the voltage-current plane for IR = 1:10. (d) THD distribution in the voltage-current plane for IR = 1:100.
Figure 4. Class-imbalance overview and THD scatter distributions under different imbalance ratios. (a) Sample counts of normal and abnormal instances in the training sets with IRs of 1:1, 1:10, and 1:100. (b) THD distribution in the voltage-current plane for IR = 1:1. (c) THD distribution in the voltage-current plane for IR = 1:10. (d) THD distribution in the voltage-current plane for IR = 1:100.
Sustainability 18 05783 g004
Figure 5. Comparison of t-SNE distributions in the original feature space and the learned PCDL embedding space under different class-imbalance settings: (a) original feature space (1:1); (b) PCDL embedding (1:1); (c) PCDL embedding (1:10); and (d) PCDL embedding (1:100). The visualization highlights the separation between normal and fault samples achieved by PCDL across varying imbalance ratios.
Figure 5. Comparison of t-SNE distributions in the original feature space and the learned PCDL embedding space under different class-imbalance settings: (a) original feature space (1:1); (b) PCDL embedding (1:1); (c) PCDL embedding (1:10); and (d) PCDL embedding (1:100). The visualization highlights the separation between normal and fault samples achieved by PCDL across varying imbalance ratios.
Sustainability 18 05783 g005
Figure 6. Model weight size comparison across different data scales.
Figure 6. Model weight size comparison across different data scales.
Sustainability 18 05783 g006
Figure 7. Model inference time comparison across different data scales.
Figure 7. Model inference time comparison across different data scales.
Sustainability 18 05783 g007
Table 1. Summary of representative anomaly detection methods for EV charging infrastructure and related electrical systems.
Table 1. Summary of representative anomaly detection methods for EV charging infrastructure and related electrical systems.
CategoryRepresentative ReferencesMain IdeaAdvantagesLimitations for This Task
Heterogeneous fault sources in EV charging systems[12,13,14,15,16,17]Electromechanical parts (contactors, electronic locks) → discrete control signal faults (contact wear, jamming); Power converters (AC/DC, DC/DC) → continuous THD degradation (aging, drift); Protection/safety circuits (e-stop, access control) → discrete logic inconsistency; Sensing/communication → noisy/delayed measurements.Clarifies why raw features (discrete + continuous) overlap severely under real-world conditions.Requires representation learning to disentangle mixed signals; rare faults exacerbate class imbalance.
Unsupervised boundary or density methods[6,7,8,9,10,11]Estimate normal support, isolate anomalous samples, or fit robust statistical boundaries.Can operate with few or nofault labels; simple and interpretable.May produce false alarms when normal charging behavior is multimodal; cannot fully exploit scarce labeled faults.
Recent optimized sequence models[18,19]Use deep sequence models, such as Bi-LSTM and PSO-optimized Bi-LSTM, to learn temporal fault evolution from multi-dimensional charging or distribution-network data.Strong ability to capture temporal dependencies in voltage, current, temperature, and other streaming signals; reported high diagnostic performance in recent EV charging-related studies.Usually require continuous time-series inputs and recurrent-model training; reported results are based on different datasets and are not directly comparable with the fixed-feature, prototype-based rare-fault setting of this study.
Classical and deep supervised baselines[22,23,24,25,26]Learn a direct mapping from features or sequences to labels using KNN, ANN, CNN, LSTM, or policy-based models.Strong pattern extraction under balanced or moderately imbalanced data.Decision boundaries are dominated by normal samples under long-tailed distributions; classifier heads can be biased.
Imbalance-aware learning[27,30,31]Use resampling, re-weighting, or hard-example-focused losses to increase minority influence.Simple to combine with existing classifiers; improves minority sensitivity in many tasks.Synthetic samples or weighting factors may be difficult to tune for scarce heterogeneous charging faults.
Contrastive representation learning[33,34,35,36,37,38,39]Pull samples of the same class closer and push different classes apart in an embedding space.Improves representation separability and can reduce raw-space overlap.Often still relies on a downstream classifier head; EV charging heterogeneous features remain underexplored.
Prototype-based learning[40,41]Represent each class with a prototype and classify by distance in embedding space.Classifier-free, interpretable, and parameter-efficient.Requires a well-structured embedding space; rarely combined with supervised contrastive learning for EVCS anomaly detection.
Edge/TinyML methods[42,43,44,45,46,47]Compress, prune, distill, or distribute models for low-latency and low-memory deployment.Supports real-time local diagnosis and privacy-preserving deployment.Deployment optimization alone does not solve rare-fault representation under severe imbalance.
PCDL (ours)This workSupervised contrastive encoder plus prototype-distance discrimination for heterogeneous EVCS features.Combines separable representation learning, classifier-free decision geometry, interpretability, and lightweight inference.Requires at least a small number of labeled abnormal samples to form the fault prototype.
Table 2. Comparison of representative strategies for class imbalance and representation learning.
Table 2. Comparison of representative strategies for class imbalance and representation learning.
StrategyTypical MethodsStrengthsWeaknessesRelevance to PCDL
Data-level balancingSMOTE and related oversampling [27]; generative augmentation [28,29]Increases minority samples and can be used with many classifiers.May create unrealistic samples when fault modes are sparse or physically discontinuous.PCDL avoids synthetic fault generation and directly structures the embedding space.
Loss re-weighting and hard-example miningFocal loss [30]; class-balanced loss [31]Easy to implement; emphasizes rare or hard samples.Requires hyperparameter tuning and still depends on a classifier head.PCDL uses contrastive supervision and prototype-distance scoring rather than class-frequency weights.
Self-supervised contrastive learningSimCLR [33]; MoCo [34]Learns useful representations without labels.False negatives and class imbalance can degrade embeddings in time-series settings.PCDL uses labels during training to define reliable positive and negative pairs.
Supervised contrastive learningSupCon [35]; time-series and fault-diagnosis variants [37,38]Improves intra-class compactness and inter-class separation.Often followed by a parametric classifier that may reintroduce bias.PCDL retains the contrastive encoder but removes the classifier head.
Prototype-based metric learningPrototypical networks [40]; shapelet prototypes [41]Interpretable, simple, and suitable for few-shot settings.Performance depends on the quality of the learned embedding space.PCDL combines prototypes with supervised contrastive pre-training.
Edge-oriented optimizationTinyML, compression, pruning, distillation, and federated learning [42,43,44,45,46,47]Reduces memory and latency; supports local deployment.Does not automatically improve robustness to rare faults.PCDL is designed to be lightweight at inference while preserving rare-fault separability.
Table 3. Summary of the main symbols used in the computational complexity analysis.
Table 3. Summary of the main symbols used in the computational complexity analysis.
SymbolDefinition
N Total number of training samples
d Input feature dimension
m Embedding dimension generated by the encoder
B Mini-batch size during contrastive training
C Number of classes; C = 2 in this binary anomaly-detection task
θ Trainable parameters of the encoder
f θ · Lightweight MLP encoder
z i Normalized embedding vector of sample x i
c k Prototype vector of class k in the embedding space
KNumber of nearest neighbors used in KNN
T Number of trees used in Isolation Forest
h Average tree depth in Isolation Forest
Table 4. Key parameter settings for baseline models and proposed method.
Table 4. Key parameter settings for baseline models and proposed method.
MethodSettings
One-Class SVMKernel = RBF; v = 0.05 ; Fit on mixed X train
KNN k = 5
IForestContamination = 0.05; Random state = 42; Fit on mixed X train
ANNInput (6) Dense (32) Dense (16) Dense (1)
RNN (LSTM) T = 1 , Input (1, 6) LSTM (32) Dense (1)
CNN (1D)Input (6, 1) Conv1D (32, kernel = 3) Dense (1)
PPOBase = SVM + KNN + ANN; State = { p i } ; Action = { w , θ } ; Reward = ( score reward ) × ( 1   if   y = 1   else   1 ) ;   n s t e p s = 64 ; Batch = 64;
lr = 3 × 10 4 ;   γ = 0.99 ; Test = freeze
PCDL (Ours)Encoder: 6 64 16; emb = 16; Batch = 512; lr = 1 × 10 3 ;   τ = 0.07
Table 5. Performance comparison of various models under different IRs.
Table 5. Performance comparison of various models under different IRs.
ModelData RatioAccuracyPrecisionRecallF1-ScoreDetected
Anomalies
ANN1:10.88700.91740.85060.882716,987
1:100.85790.95340.75260.841214,463
1:1000.56440.99130.12990.22962400
CNN1:10.88910.89560.88080.888218,019
1:100.77030.97440.55520.707310,438
1:1000.49990.25000.00010.00028
Elliptic_
Envelope
1:10.62840.57950.93600.715829,593
1:100.50660.50680.49690.501817,965
1:1000.50920.51360.34620.413612,349
IForest1:10.51980.51040.96740.668334,724
1:100.50340.50180.95560.658034,891
1:1000.49700.49840.94390.652434,695
KNN1:10.88500.88990.87860.884218,088
1:100.81010.96980.64010.771212,092
1:1000.59870.99260.19880.33123669
PPO1:10.52460.51270.99530.676735,568
1:100.80490.97360.62680.762711,795
1:1000.53950.99790.07920.14681454
RNN1:10.88980.89870.87870.888617,913
1:100.79370.97480.60290.745011,331
1:1000.52370.99430.04770.0910879
SVM1:10.50260.50140.95080.656534,745
1:100.45350.47450.86470.612833,389
1:1000.40660.44570.76660.563631,512
PCDL1:10.88920.88650.89280.889618,285
1:100.88250.90770.85150.878717,187
1:1000.84830.87820.80880.842116,874
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Lei, Z.; Xing, B.; Liu, J.; Yang, Y.; Miao, T.; Lu, Y. Sustainable and Reliable Operation of EV Charging Infrastructure: A Lightweight Prototype-Driven Contrastive Learning Framework for Fault Diagnosis Under Class-Imbalanced Conditions. Sustainability 2026, 18, 5783. https://doi.org/10.3390/su18115783

AMA Style

Lei Z, Xing B, Liu J, Yang Y, Miao T, Lu Y. Sustainable and Reliable Operation of EV Charging Infrastructure: A Lightweight Prototype-Driven Contrastive Learning Framework for Fault Diagnosis Under Class-Imbalanced Conditions. Sustainability. 2026; 18(11):5783. https://doi.org/10.3390/su18115783

Chicago/Turabian Style

Lei, Zhengyu, Baowen Xing, Jingrui Liu, Yuxin Yang, Tianyuan Miao, and Yingjie Lu. 2026. "Sustainable and Reliable Operation of EV Charging Infrastructure: A Lightweight Prototype-Driven Contrastive Learning Framework for Fault Diagnosis Under Class-Imbalanced Conditions" Sustainability 18, no. 11: 5783. https://doi.org/10.3390/su18115783

APA Style

Lei, Z., Xing, B., Liu, J., Yang, Y., Miao, T., & Lu, Y. (2026). Sustainable and Reliable Operation of EV Charging Infrastructure: A Lightweight Prototype-Driven Contrastive Learning Framework for Fault Diagnosis Under Class-Imbalanced Conditions. Sustainability, 18(11), 5783. https://doi.org/10.3390/su18115783

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop