Anomaly detection method and device, computer device, storage medium and program product

By combining autoencoders, variational autoencoders, and support vector data description networks, and optimizing model parameters, the hypersphere collapse problem of traditional anomaly detection models is solved, achieving higher accuracy in anomaly detection.

CN117150401BActive Publication Date: 2026-07-03TSINGHUA UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TSINGHUA UNIVERSITY
Filing Date
2023-08-01
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Traditional anomaly detection models based on autoencoders and support vector data description networks are prone to hypersphere collapse, resulting in low detection accuracy.

Method used

By combining an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network, a pre-defined anomaly detection model is constructed. The model parameters are optimized using the information entropy ratio and the loss function to avoid hypersphere collapse and improve detection accuracy.

Benefits of technology

This effectively avoids mapping the training data to the same point in the hypersphere, improving the accuracy of anomaly detection and generating more accurate detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117150401B_ABST
    Figure CN117150401B_ABST
Patent Text Reader

Abstract

This application relates to an anomaly detection method, apparatus, computer equipment, storage medium, and program product. The method includes: acquiring vehicle data of a vehicle to be detected; inputting the vehicle data into a preset anomaly detection model for anomaly detection, generating an anomaly detection result for the vehicle; the preset anomaly detection model is generated based on an initial anomaly detection model trained on it; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network; and outputting the anomaly detection result for the vehicle. This method can improve the accuracy of the vehicle anomaly detection process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to an anomaly detection method, apparatus, computer equipment, storage medium, and program product. Background Technology

[0002] With the development of artificial intelligence technology, the application of deep learning models is becoming increasingly widespread. For example, deep learning models can be used to detect anomalies in vehicles, thereby determining whether a vehicle has malfunctioned.

[0003] Traditional techniques rely on auto-encoders (AEs) and support vector data description networks (SVDDs) to build anomaly detection models, thereby enabling anomaly detection of vehicles.

[0004] However, traditional methods for detecting anomalies in vehicles suffer from low accuracy. Summary of the Invention

[0005] Therefore, it is necessary to provide an anomaly detection method, apparatus, computer equipment, storage medium, and program product that can improve the accuracy of anomaly detection in response to the above-mentioned technical problems.

[0006] Firstly, this application provides an anomaly detection method. The method includes:

[0007] Obtain vehicle data for the vehicle to be inspected;

[0008] The vehicle data of the vehicle to be detected is input into a preset anomaly detection model for anomaly detection, and anomaly detection results of the vehicle to be detected are generated. The preset anomaly detection model is generated based on an initial anomaly detection model trained on it. The initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network.

[0009] Output the anomaly detection results of the vehicle to be detected.

[0010] In one embodiment, the method further includes:

[0011] Acquire historical vehicle data for multiple vehicles;

[0012] Based on the historical vehicle data, the initial anomaly detection model, and the initial error calculation model, the first model parameters of the initial anomaly detection model are calculated; the initial error calculation model includes the initial autoencoder and the initial support vector data description network.

[0013] The initial anomaly detection model is updated based on the first model parameters to obtain an intermediate anomaly detection model;

[0014] The intermediate anomaly detection model is trained based on the historical vehicle data to obtain the preset anomaly detection model.

[0015] In one embodiment, calculating the first model parameters of the initial anomaly detection model based on the historical vehicle data, the initial anomaly detection model, and the initial error calculation model includes:

[0016] Based on the historical vehicle data and the initial error calculation model, the first error of the initial support vector data description network is calculated;

[0017] Based on the historical vehicle data and the initial anomaly detection model, the second error of the initial variational autoencoder is calculated;

[0018] Based on the first error and the second error, the ratio of the information entropy between the first error and the second error is calculated, and the ratio of the information entropy is used as the first model parameter.

[0019] In one embodiment, training the intermediate anomaly detection model based on the historical vehicle data to obtain the preset anomaly detection model includes:

[0020] Based on the historical vehicle data and loss function, the intermediate anomaly detection model is trained to obtain the model parameters of the intermediate anomaly detection model;

[0021] The intermediate anomaly detection model is updated based on its model parameters to obtain a new intermediate anomaly detection model.

[0022] The initial error calculation model is updated based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model;

[0023] The new error calculation model is used as the initial error calculation model, and the new intermediate anomaly detection model is used as the initial anomaly detection model for iterative calculation until the value of the loss function reaches its minimum. The new intermediate anomaly detection model corresponding to the minimum loss function is then used as the preset anomaly detection model.

[0024] In one embodiment, training the intermediate anomaly detection model based on the historical vehicle data and the loss function to obtain the model parameters of the intermediate anomaly detection model includes:

[0025] The historical vehicle data is input into the intermediate anomaly detection model for anomaly detection, and a predicted anomaly detection result corresponding to the historical vehicle data is generated.

[0026] The loss function is calculated based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to the historical vehicle data;

[0027] Based on the loss function, the model parameters of the intermediate anomaly detection model are determined.

[0028] In one embodiment, acquiring historical vehicle data for multiple vehicles includes:

[0029] Obtain raw vehicle data for multiple vehicles;

[0030] Delete the abnormal data from the original vehicle data to obtain new original vehicle data;

[0031] The new original vehicle data is augmented to obtain augmented original vehicle data.

[0032] The original vehicle data after data augmentation is filtered based on the Pearson correlation coefficient to obtain the historical vehicle data of the multiple vehicles.

[0033] Secondly, this application also provides an anomaly detection device. The device includes:

[0034] The acquisition module is used to acquire vehicle data of the vehicle to be detected;

[0035] An anomaly detection module is used to input the vehicle data of the vehicle to be detected into a preset anomaly detection model for anomaly detection and generate anomaly detection results for the vehicle to be detected; the preset anomaly detection model is generated based on an initial anomaly detection model trained on it; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder and an initial support vector data description network;

[0036] The output module is used to output the abnormal detection results of the vehicle under test.

[0037] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method in any of the embodiments of the first aspect described above.

[0038] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.

[0039] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.

[0040] The aforementioned anomaly detection method, apparatus, computer equipment, storage medium, and program product acquire vehicle data of a vehicle to be detected; input the vehicle data of the vehicle to be detected into a preset anomaly detection model for anomaly detection, and generate anomaly detection results for the vehicle to be detected; the preset anomaly detection model is generated based on an initial anomaly detection model trained on it; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network; and outputs the anomaly detection results for the vehicle to be detected. In this embodiment, the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network. Since the variational autoencoder can map each data point to a Gaussian distribution corresponding to that data point, and the variational autoencoder introduces random sampling noise during the mapping process, the Gaussian distributions corresponding to each data point are all different. Therefore, after the initial variational autoencoder is combined with the initial autoencoder and the initial support vector data description network, the initial anomaly detection model can map the Gaussian distributions corresponding to each data point to a hypersphere. Since the Gaussian distributions corresponding to each data point do not overlap, the Gaussian distributions corresponding to each data point will not be mapped to the same point in the hypersphere.

[0041] Furthermore, during the process of training the initial anomaly detection model to generate the preset anomaly detection model, the Gaussian distributions corresponding to each training data point will not be mapped to the same point in the hypersphere. Therefore, using the preset anomaly detection model can effectively avoid the hypersphere collapse phenomenon caused by mapping each training data point to the same point in the hypersphere. Based on this, the preset anomaly detection model has high accuracy. Next, the acquired vehicle data of the vehicle to be detected is input into the more accurate preset anomaly detection model for anomaly detection, which can generate more accurate anomaly detection results for the vehicle to be detected. Attached Figure Description

[0042] Figure 1 This is a diagram illustrating the application environment of an anomaly detection method in one embodiment;

[0043] Figure 2 This is a flowchart illustrating an anomaly detection method in one embodiment;

[0044] Figure 3 This is a flowchart illustrating the model training steps in another embodiment;

[0045] Figure 4This is a flowchart illustrating the first model parameter calculation step in one embodiment;

[0046] Figure 5 This is a schematic diagram of the structure of the initial anomaly detection model in one embodiment;

[0047] Figure 6 This is a flowchart illustrating the steps for generating a preset anomaly detection model in one embodiment.

[0048] Figure 7 This is a flowchart illustrating the steps for acquiring historical vehicle data in one embodiment;

[0049] Figure 8 This is a schematic diagram illustrating the distribution of the number of vehicle faults for different models and the types of vehicle faults present in the total number of vehicle models in one embodiment.

[0050] Figure 9 This is a schematic diagram of the original vehicle data before the vehicle status is filled in, as shown in one embodiment.

[0051] Figure 10 This is a schematic diagram of the result after filling in the vehicle status of the original vehicle data in one embodiment;

[0052] Figure 11 This is a schematic diagram of the data before the total voltage of the original vehicle data is filled in in one embodiment;

[0053] Figure 12 This is a schematic diagram showing the result after filling in the total voltage of the original vehicle data in one embodiment;

[0054] Figure 13 This is a flowchart illustrating an anomaly detection method in one optional embodiment;

[0055] Figure 14 This is a schematic diagram of the overall architecture of an anomaly detection method in one embodiment;

[0056] Figure 15 This is a structural block diagram of an anomaly detection device in one embodiment;

[0057] Figure 16 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0059] With the development of artificial intelligence technology, the application of deep learning models is becoming increasingly widespread. For example, deep learning models can be used to detect anomalies in vehicles, thereby determining whether a vehicle has malfunctioned. Furthermore, to protect the environment, the use of new energy vehicles (such as electric vehicles) is becoming increasingly widespread. However, if the internal battery of a new energy vehicle malfunctions, it can lead to an accident. Therefore, as an example, deep learning models can be used to detect anomalies in electric vehicles, thereby determining whether the electric vehicle has malfunctioned.

[0060] Traditional techniques rely on auto-encoders (AEs) and support vector data description networks (SVDDs) to build anomaly detection models, thereby enabling anomaly detection in electric vehicles.

[0061] However, traditional anomaly detection models may suffer from hypersphere collapse, where all training data is mapped to a single point in the hypersphere space. Once hypersphere collapse occurs, traditional anomaly detection models cannot be trained properly. Therefore, traditional methods for vehicle anomaly detection suffer from low accuracy.

[0062] The anomaly detection method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on the cloud or other network servers. Server 104 acquires vehicle data of the vehicle to be detected; server 104 inputs the vehicle data of the vehicle to be detected into a preset anomaly detection model for anomaly detection, generating anomaly detection results for the vehicle to be detected; the preset anomaly detection model is generated based on an initial anomaly detection model trained on it; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network; server 104 outputs the anomaly detection results of the vehicle to be detected to terminal 102. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.

[0063] In one embodiment, such as Figure 2As shown, an anomaly detection method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:

[0064] S220: Obtain vehicle data of the vehicle to be tested.

[0065] The vehicle to be detected refers to the vehicle that needs to be detected for anomalies. The vehicle to be detected can be an electric vehicle, a bus, a truck, etc. The vehicle data of the vehicle to be detected refers to the vehicle data related to anomaly detection from the characteristic data of the vehicle to be detected. For example, vehicle data can include, but is not limited to, vehicle speed, vehicle charging status, and vehicle battery voltage. Optionally, server 104 can directly obtain the vehicle data of the vehicle to be detected from terminal 102 or a database. Alternatively, server 104 can first obtain the initial vehicle data of the vehicle to be detected from terminal 102 or a database, and then perform data preprocessing on the initial vehicle data to obtain the vehicle data of the vehicle to be detected. The data preprocessing methods can include, but are not limited to, at least one of data deletion, data expansion, and data filtering.

[0066] S240, input the vehicle data of the vehicle to be detected into the preset anomaly detection model for anomaly detection, and generate the anomaly detection result of the vehicle to be detected; the preset anomaly detection model is generated based on the initial anomaly detection model; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder and an initial support vector data description network.

[0067] The preset anomaly detection model is an anomaly detection model generated by training an initial anomaly detection model. The initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network (SVDD). In other words, the initial anomaly detection model is an anomaly detection model constructed based on the initial autoencoder, initial variational autoencoder, and initial SVDD. The initial autoencoder is an untrained autoencoder. An autoencoder (AE) is a type of artificial neural network used in semi-supervised and unsupervised learning. Its function is to learn representations of input data by using the input data as the learning target. An autoencoder consists of an encoder and a decoder. The initial SVDD is an untrained support vector data description network. A support vector data description network (SVDD) is a network used for data description. It can provide a hyperspherical description of the target dataset and can be used for outlier detection or classification.

[0068] The initial variational autoencoder (VAE) is an untrained VAE. A VAE is a directed model that uses learned approximate data for inference and can be trained using gradient-based optimization methods. The VAE is a feature learning model to ensure the relevance of the latent representation to the anomaly detection task. For regularization, the VAE does not encode the input data into a single point, but instead maps each data point output by the encoder to a corresponding Gaussian distribution, thus learning the probability distribution of the parameters based on the training data. Since the VAE introduces random sampling noise during the Gaussian distribution mapping process, the Gaussian distributions corresponding to each data point are all different. Therefore, after combining the initial VAE with the initial autoencoder and the initial support vector data description network, the initial anomaly detection model in this embodiment can map the Gaussian distributions corresponding to each data point into a hypersphere space. Since the Gaussian distributions corresponding to each data point are not identical, they will not be mapped to the same point in the hypersphere. This effectively avoids the hypersphere collapse caused by the encoder mapping the data to the same point in the hypersphere.

[0069] Optionally, server 104 can directly input the vehicle data of the vehicle to be detected into a preset anomaly detection model for anomaly detection, generating an anomaly detection result for the vehicle to be detected. Alternatively, server 104 can first input the vehicle data of the vehicle to be detected into the preset anomaly detection model for anomaly detection, generating a score result for the vehicle to be detected; then, based on the score result, determine the anomaly detection result for the vehicle to be detected. The score result for the vehicle to be detected can be a value between 0 and 1, and the score result is used to characterize whether the vehicle to be detected has an anomaly. The anomaly detection result for the vehicle to be detected includes whether the vehicle to be detected has an anomaly or not.

[0070] S260 outputs the anomaly detection results for the vehicle under test.

[0071] Optionally, server 104 can output the anomaly detection results of the vehicle under test to terminal 102 so that users can view the anomaly detection results. In addition, server 104 can also issue an alert for vehicles whose anomaly detection results indicate that the vehicle under test has an anomaly, so as to ensure that passengers in the vehicle can be informed of the anomaly in a timely manner.

[0072] In the above anomaly detection method, vehicle data of the vehicle to be detected is acquired; the vehicle data is input into a preset anomaly detection model for anomaly detection, generating anomaly detection results for the vehicle to be detected; the preset anomaly detection model is generated based on an initial anomaly detection model trained on it; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network; and the anomaly detection results for the vehicle to be detected are output. In this embodiment, the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network. Since the variational autoencoder can map each data point to a Gaussian distribution corresponding to that data point, and the variational autoencoder introduces random sampling noise during the mapping process, the Gaussian distributions corresponding to each data point are all different. Therefore, after the initial variational autoencoder is combined with the initial autoencoder and the initial support vector data description network, the initial anomaly detection model can map the Gaussian distributions corresponding to each data point to a hypersphere. Since the Gaussian distributions corresponding to each data point do not overlap, the Gaussian distributions corresponding to each data point will not be mapped to the same point in the hypersphere.

[0073] Furthermore, during the process of training the initial anomaly detection model to generate the preset anomaly detection model, the Gaussian distributions corresponding to each training data point will not be mapped to the same point in the hypersphere. Therefore, using the preset anomaly detection model can effectively avoid the hypersphere collapse phenomenon caused by mapping each training data point to the same point in the hypersphere. Based on this, the preset anomaly detection model has high accuracy. Next, the acquired vehicle data of the vehicle to be detected is input into the more accurate preset anomaly detection model for anomaly detection, which can generate more accurate anomaly detection results for the vehicle to be detected.

[0074] In the above embodiments, the preset anomaly detection model is generated by training an initial anomaly detection model. The initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network. The specific training method for the preset anomaly detection model is described below. In one embodiment, such as... Figure 3 As shown, the above-mentioned anomaly detection method also includes:

[0075] S320 retrieves historical vehicle data for multiple vehicles.

[0076] Here, "multiple vehicles" refers to vehicles of different types and models, including electric vehicles, buses, and trucks. "Historical vehicle data" refers to historical vehicle data related to anomaly detection from the feature data of multiple vehicles. For example, historical vehicle data may include, but is not limited to, vehicle speed, vehicle charging status, and vehicle battery voltage. Optionally, server 104 can directly obtain historical vehicle data from terminal 102 or a database. Alternatively, server 104 can first obtain raw vehicle data from terminal 102 or a database, and then perform data preprocessing on the raw vehicle data to obtain historical vehicle data. The data preprocessing methods may include, but are not limited to, at least one of data deletion, data augmentation, and data filtering.

[0077] S340, based on historical vehicle data, the initial anomaly detection model, and the initial error calculation model, calculates the first model parameters of the initial anomaly detection model; the initial error calculation model includes the initial autoencoder and the initial support vector data description network.

[0078] The initial error calculation model includes an initial autoencoder and an initial support vector data description network. That is, the initial error calculation model can be constructed based on the initial autoencoder and the initial support vector data description network. The core idea of ​​constructing the initial error calculation model is to project all data into a hypersphere space through the encoder's mapping, thereby constructing a minimum hypersphere that encloses all normal data and excluding outlier data as much as possible from the minimum hypersphere. The first model parameter of the initial anomaly detection model refers to the parameters used for model training and updating in the initial anomaly detection model. The first model parameter is used to balance the error between the initial anomaly detection model and the initial error calculation model.

[0079] Optionally, server 104 can directly calculate the first model parameters of the initial anomaly detection model based on historical vehicle data, the initial anomaly detection model, and the initial error calculation model. Alternatively, server 104 can first calculate based on historical vehicle data and the initial anomaly detection model respectively to obtain a first calculation result; then calculate based on historical vehicle data and the initial error calculation model to obtain a second calculation result; and finally determine the first model parameters of the initial anomaly detection model based on the first and second calculation results. It should be noted that the embodiments of this application do not limit the order of the calculation process based on historical vehicle data and the initial anomaly detection model, nor the calculation process based on historical vehicle data and the initial error calculation model.

[0080] S360 updates the initial anomaly detection model based on the parameters of the first model to obtain the intermediate anomaly detection model.

[0081] Optionally, server 104 can update the initial anomaly detection model based on the first model parameters to obtain an intermediate anomaly detection model. For example, server 104 can obtain the first initial model parameters of the initial anomaly detection model, and then replace the first initial model parameters with the first model parameters to update the initial anomaly detection model and obtain the intermediate anomaly detection model. Here, the first initial model parameters refer to the initial first model parameters in the initial anomaly detection model. The intermediate anomaly detection model refers to the model obtained after updating the first initial model parameters in the initial anomaly detection model.

[0082] S380 trains the intermediate anomaly detection model based on historical vehicle data to obtain the preset anomaly detection model.

[0083] Optionally, server 104 can directly input historical vehicle data from multiple vehicles into an intermediate anomaly detection model for training to obtain a preset anomaly detection model. Alternatively, server 104 can first input historical vehicle data from multiple vehicles into an intermediate anomaly detection model for training to obtain a new intermediate anomaly detection model; then update the parameters of the first model based on the new intermediate anomaly detection model to obtain new first model parameters; and then train the new intermediate anomaly detection model based on the new first model parameters and the historical vehicle data from multiple vehicles to obtain the preset anomaly detection model.

[0084] In this embodiment, since the initial error calculation model includes an initial autoencoder and an initial support vector data description network, the first model parameters of the initial anomaly detection model can be calculated relatively accurately based on the acquired historical vehicle data from multiple vehicles, the initial anomaly detection model, and the initial error calculation model. Because the first model parameters can balance the errors between the initial anomaly detection model and the initial error calculation model, updating the initial anomaly detection model based on the more accurate first model parameters yields a more accurate intermediate anomaly detection model after error balancing. Therefore, training the more accurate intermediate anomaly detection model using historical vehicle data results in a more accurate preset anomaly detection model.

[0085] The above embodiments involve calculating the first model parameters of the initial anomaly detection model based on historical vehicle data, the initial anomaly detection model, and the initial error calculation model. The specific method for this is described below. In one embodiment, such as... Figure 4 As shown, S340 includes:

[0086] S420 calculates the first error of the initial support vector data description network based on historical vehicle data and the initial error calculation model.

[0087] Optionally, server 104 can calculate the first error of the initial support vector data description network based on historical vehicle data and the initial error calculation model. For example, for the input space... and output space Assuming the network corresponding to the encoder have A neural network with n hidden layers, and the set of model parameters is as follows. Among them, W l If the model parameters are for layer l∈{1,…,L}, then This refers to the inclusion of parameters The network φ is given The feature representation. The purpose of the initial error calculation model is to jointly learn the model parameters. Simultaneously minimize the output space The volume of the hypersphere containing the data. Assume the hypersphere is characterized by radius R > 0, and center... And some training data were given. In input space Therefore, the optimization objective L(SVDD) of the initial error calculation model can be defined as Equation (1). The optimization objective L(SVDD) of the initial error calculation model is shown in Equation (1).

[0088]

[0089] Where L(SVDD) is the optimization objective of the initial error calculation model, and R is the radius of the hypersphere. The first term represents the model parameters. The second term on the right-hand side of the equation is the penalty term, which is the penalty imposed when the data exceeds the normal range of the hypersphere. The third term on the right-hand side of the equation represents the model parameters with hyperparameter λ > 0. A weight decay regularizer on the , where ||·|| F This represents the Frobenius norm.

[0090] Since the initial error calculation model in this embodiment is a binary classification problem, the optimization objective L(SVDD) of the initial error calculation model can be simplified to obtain the first error R of the initial support vector data description network. SVDD The calculation formula is as follows. The initial support vector data describes the network's first error R. SVDD The calculation formula is shown in formula (2).

[0091]

[0092] Among them, R SVDD The first error of the network is described by the initial support vector data, x. iLet i be the input training data, and n be the total number of input training data. Here are the model parameters, c is the hypersphere center, φ(x) is the encoding function, λ is the hyperparameter, L is the number of network layers, and ||W l || F Let R be the Frobenius norm of the parameters of the l-th layer model. Therefore, server 104 can input historical vehicle data into the first error R in the initial error calculation model. SVDD The calculation formula is used to calculate the first error of the initial support vector data describing the network. This first error characterizes the error in the data's path to the hypersphere center.

[0093] S440 calculates the second error of the initial variational autoencoder based on historical vehicle data and the initial anomaly detection model.

[0094] Optionally, server 104 can calculate the second error of the initial variational autoencoder based on historical vehicle data and the initial anomaly detection model. For example, such as... Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of the initial anomaly detection model in one embodiment. This application can introduce a variational autoencoder into the initial error calculation model. For regularization, the variational autoencoder does not encode the input data into a single point, but instead maps each data point output by the encoder to a Gaussian distribution corresponding to that data point, thereby learning the probability distribution of the parameters based on the training data. The initial anomaly detection model based on the variational autoencoder and the initial error calculation model follows the structure of an autoencoder, consisting of an encoder and a decoder. During training of the initial anomaly detection model, the encoder maps the training data to the parameters of the probability distribution followed by the latent variables, thereby sampling to obtain the latent variables according to this probability distribution; the decoder then maps the latent variables back to the data variables, i.e., reconstructs the data. The second error of the initial variational autoencoder is shown in formulas (3) and (4).

[0095]

[0096]

[0097] Where, L(θ,φ; x i The second error of the initial variational autoencoder is denoted as . μ is an intermediate parameter. i Let σ be the mean vector of the i-th input data. i Let z be the variance vector of the i-th input data, and J be the dimension of z. and They represent μ i and σ iThe j-th element, θ is the parameter corresponding to the decoder, p θ (x) is the decoder.

[0098] Therefore, server 104 can input historical vehicle data into the calculation formula of the second error in the initial anomaly detection model, thereby calculating the second error of the initial variational autoencoder. The second error characterizes the network's reconstruction error.

[0099] S460, Based on the first error and the second error, calculate the ratio of the information entropy between the first error and the second error, and use the ratio of the information entropy as the first model parameter.

[0100] Optionally, server 104 can describe the network's first error and the initial variational autoencoder's second error based on the initial support vector data, and explore the balance between the first and second errors in representing the model training error. This application proposes an error balancing method based on training error entropy weights. This error balancing method can record and standardize the first and second errors of the training data during a training process, and calculate the information entropy of the first and second errors respectively. Thus, the ratio of the information entropy of the first and second errors is used as the first model parameter for training. The core idea of ​​the error balancing method is to maximize the weight of the side with larger fluctuations (the side that transmits more information) during training, and this weight is the ratio of relative error information entropy.

[0101] For example, server 104 can calculate the information entropy of the first error and the information entropy of the second error respectively for the first error and the second error. The formula for calculating the information entropy is shown in formula (5).

[0102]

[0103] Where X is the first error or the second error, and H(X) is the information entropy of the first error or the second error; x i Let i be the first error i in a training batch, or the second error i in a training batch; p(x i This indicates that the error value is x during a single training batch. i The probability of.

[0104] Then, server 104 can calculate the ratio of the information entropy between the first error and the second error using the information entropy of the first error and the information entropy of the second error, and use the ratio of information entropy as the first model parameter. The formula for calculating the ratio of information entropy is shown in formula (6).

[0105]

[0106] Where γ is the ratio of information entropy, also known as the relative error information entropy ratio. B is the number of data points passed to the model for training in a single batch (batch size), and H(X) R H(X) is the information entropy of the first error. RE ) represents the information entropy of the second error.

[0107] In this embodiment, a first error of the initial variational autoencoder is calculated based on historical vehicle data and the initial anomaly detection model; a second error of the initial support vector data description network is calculated based on historical vehicle data and the initial error calculation model. This allows for the calculation of the ratio of information entropy between the first and second errors, which is then used as a first model parameter in model training. This ensures that the side with greater fluctuations (those conveying more information) has a larger weight during training, and the first model parameter can be used to balance the error between the initial anomaly detection model and the initial error calculation model, thereby ensuring that the trained pre-defined anomaly detection model has high accuracy.

[0108] The above embodiments involve training an intermediate anomaly detection model based on historical vehicle data to obtain a preset anomaly detection model. The specific method is described below. In one embodiment, such as... Figure 6 As shown, S380 includes:

[0109] S620 trains the intermediate anomaly detection model based on historical vehicle data and loss function to obtain the model parameters of the intermediate anomaly detection model.

[0110] Optionally, server 104 can train the intermediate anomaly detection model based on historical vehicle data and a loss function to obtain the model parameters of the intermediate anomaly detection model. In one optional embodiment, S620 includes:

[0111] Historical vehicle data is input into an intermediate anomaly detection model for anomaly detection, generating predicted anomaly detection results corresponding to the historical vehicle data.

[0112] Optionally, server 104 can input historical vehicle data into an intermediate anomaly detection model for anomaly detection, generating a predicted anomaly detection result corresponding to the historical vehicle data. The predicted anomaly detection result can be represented as an anomaly detection score. For example, if the anomaly detection score is a value between 0 and 1, an anomaly detection score below 0.5 can be used to indicate that the historical vehicle data is abnormal, and an anomaly detection score not below 0.5 can be used to indicate that the historical vehicle data is not abnormal. The formula for calculating the initial anomaly detection score corresponding to a single data sample is shown in formula (7).

[0113]

[0114] Where s(x) is the initial anomaly detection score corresponding to a single data sample, and φ(x) is the encoding function. Here are the model parameters during training, and c is the center of the hypersphere.

[0115] This application embodiment can comprehensively consider the encoder's reconstruction error. Therefore, φ(x) can be defined as the encoding function, g(x) as the decoding function, and the model parameters corresponding to φ(x) are... The model parameters corresponding to g(x) are: The formula for calculating the initial anomaly detection score for a single data sample was modified to obtain the formula for calculating the anomaly detection score for a single data sample. The formula for calculating the anomaly detection score for a single data sample is shown in formula (8).

[0116]

[0117] Where S(x) is the anomaly detection score corresponding to a single data sample, γ is the first model parameter, and c is the hypersphere center. The first term on the right side of the above equation is the reconstruction error. By introducing a non-zero reconstruction error during the training process, the hypersphere collapse phenomenon caused by the network mapping each training data to the same point in the hypersphere space can be avoided to some extent.

[0118] Furthermore, this application embodiment also introduces a dynamic optimization mechanism for the hypersphere center, which can update the hypersphere center after each training session based on the training data. The update formula for the hypersphere center is shown in formula (9).

[0119]

[0120] Where c is the center of the hypersphere, B is the batch size (number of data points passed to the model for training in a single pass), and φ(x) is the encoding function. These are the model parameters used by the encoding function during training.

[0121] The loss function is calculated based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to historical vehicle data.

[0122] Based on the loss function, determine the model parameters of the intermediate anomaly detection model.

[0123] Optionally, server 104 can obtain the labeled anomaly detection results corresponding to the historical vehicle data. Therefore, server 104 can calculate a loss function based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to the historical vehicle data. The loss function is used to adjust the model parameters and can include, but is not limited to, the binary cross-entropy loss function, the L2 loss function, and the log-cosine loss function. Thus, server 104 can calculate the model parameters of the intermediate anomaly detection model based on the loss function.

[0124] S640, update the intermediate anomaly detection model based on the model parameters of the intermediate anomaly detection model to obtain a new intermediate anomaly detection model.

[0125] Optionally, server 104 can replace the historical model parameters of the intermediate anomaly detection model with the model parameters of the intermediate anomaly detection model, thereby updating the intermediate anomaly detection model and obtaining a new intermediate anomaly detection model. Here, the model parameters of the intermediate anomaly detection model refer to the model parameters calculated based on the loss function. The new intermediate anomaly detection model refers to the intermediate anomaly detection model with updated model parameters.

[0126] S660 updates the initial error calculation model based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model.

[0127] Optionally, server 104 can update the initial error calculation model based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model. For example, in conjunction with formula (2), server 104 can update the initial error calculation model based on the parameters of the intermediate anomaly detection model. The model parameters are replaced with those of the intermediate anomaly detection model, thereby updating the initial error calculation model and obtaining a new error calculation model. Here, the new error calculation model refers to the error calculation model after the model parameters are updated.

[0128] It should be noted that the order of S640 and S660 is not limited in the embodiments of this application. That is, S640 can be executed first and then S660; or S660 can be executed first and then S640; or S640 and S660 can be executed simultaneously.

[0129] S680 uses the new error calculation model as the initial error calculation model and the new intermediate anomaly detection model as the initial anomaly detection model for iterative calculation until the value of the loss function reaches its minimum. The new intermediate anomaly detection model corresponding to the minimum loss function is then used as the preset anomaly detection model.

[0130] Optionally, server 104 can use the new error calculation model as the initial error calculation model and the new intermediate anomaly detection model as the initial anomaly detection model, and execute the following iteratively: calculate a new first error of the initial support vector data description network based on historical vehicle data and the new initial error calculation model; calculate a new second error of the initial variational autoencoder based on historical vehicle data and the new initial anomaly detection model; calculate a new information entropy ratio between the new first error and the new second error based on the new first error and use the new information entropy ratio as a new first model parameter; update the new initial anomaly detection model based on the new first model parameter to obtain a new intermediate anomaly detection model.

[0131] Next, based on historical vehicle data and the loss function, a new intermediate anomaly detection model is trained to obtain new model parameters. The new intermediate anomaly detection model is then updated based on these new parameters, resulting in a further updated intermediate anomaly detection model. The initial error calculation model is then updated again based on the new intermediate anomaly detection model's parameters, resulting in a further updated error calculation model. This updated error calculation model is used as the initial error calculation model, and the updated intermediate anomaly detection model is used as the initial anomaly detection model for iterative calculation until the loss function reaches its minimum value. The updated intermediate anomaly detection model corresponding to the minimum loss function is then used as the preset anomaly detection model.

[0132] In this embodiment, by training the intermediate anomaly detection model based on historical vehicle data, a loss function can be calculated based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to the historical vehicle data. This loss function then yields more accurate model parameters for the intermediate anomaly detection model. Furthermore, the intermediate anomaly detection model is updated based on these more accurate model parameters to obtain a new, more accurate intermediate anomaly detection model. Finally, the initial error calculation model is updated based on these more accurate intermediate anomaly detection model parameters to obtain a new, more accurate error calculation model.

[0133] Then, the more accurate new error calculation model is used as the initial error calculation model, and the more accurate new intermediate anomaly detection model is used as the initial anomaly detection model for iterative calculation until the value of the loss function reaches its minimum. The new intermediate anomaly detection model corresponding to the minimum loss function is used as the preset anomaly detection model. Based on the loss function, the parameters of the error calculation model and the initial anomaly detection model can be iteratively calculated, thereby training a more accurate preset anomaly detection model.

[0134] The above embodiment involves acquiring historical vehicle data from multiple vehicles; the specific method is described below. In one embodiment, such as... Figure 7 As shown, S320 includes:

[0135] S720 acquires raw vehicle data from multiple vehicles.

[0136] Optionally, server 104 can directly obtain raw vehicle data for multiple vehicles from terminal 102 or a database. Multiple vehicles refer to vehicles of different types and models, such as electric vehicles, buses, and trucks. The raw vehicle data for multiple vehicles refers to multiple characteristic data of these vehicles. For example, the raw vehicle data may include, but is not limited to, vehicle speed, vehicle status, vehicle charging status, vehicle operating mode, vehicle speed, gear, total voltage, total current, cumulative mileage, battery charging status (SOC international), DC-DC converter status, insulation resistance, highest alarm level, lowest temperature probe, lowest temperature value, highest temperature probe, highest temperature value, highest voltage battery, lowest voltage battery, and highest single-cell voltage.

[0137] For example, such as Figure 8 As shown, Figure 8 This diagram illustrates the distribution of fault counts for different vehicle models and the types of faults across all vehicle models (i.e., vehicle types) in one embodiment. Based on this, the original vehicle data exhibits the following problems: 1) Large data volume: Typically, samples of the original vehicle data are collected at fixed time intervals, resulting in a massive amount of data; 2) Fault data is limited: For example, in historical experiments, only 10,343 fault data entries were collected, representing only 0.19% of the total original vehicle data; 3) Uneven fault distribution: In the experimental dataset, vehicle models LB24, LB47, LB57, and LB41 cover 95.91% of the faults, while other vehicle models contain only a small number of fault types; 4) The original vehicle data simultaneously contains both discrete categorical data features and continuous data features.

[0138] S740, delete abnormal data in the original vehicle data to obtain new original vehicle data.

[0139] Optionally, server 104 can delete abnormal data from the original vehicle data to obtain new original vehicle data. For example, server 104 can delete features unrelated to vehicle battery health from the original vehicle data, and can delete timestamp-related original vehicle data based on the characteristic that abnormal vehicle data occurs following a stationary Poisson process. Furthermore, server 104 can fill in null values ​​in the original vehicle data. For example, if the vehicle is charging, missing values ​​for mileage and speed are filled with 0, and the accumulated mileage is filled with the mileage value within the segment. If all mileage values ​​within a segment are missing, the mileage value at the end of the previous segment is used for filling. Figure 9 As shown, Figure 9 This is a schematic diagram of the original vehicle data before the vehicle status is filled in, as shown in one embodiment. Figure 10 As shown, Figure 10 This is a schematic diagram illustrating the result of filling in the vehicle status information of the original vehicle data in one embodiment. For example... Figure 11 As shown, Figure 11 This is a schematic diagram of the data before the total voltage of the original vehicle data is filled in, as shown in one embodiment. Figure 12 As shown, Figure 12 This is a schematic diagram illustrating the result of filling in the total voltage of the original vehicle data in one embodiment. For the highest and lowest cell voltage, highest and lowest temperature, interpolation can be used to fill in the values ​​based on the average values ​​at different times. Missing values ​​for vehicle status can be filled in based on vehicle speed, current, and voltage values. If all data for the total number of cell temperature probes is missing, it is deleted.

[0140] In addition, server 104 can also perform data preprocessing on outliers in the original vehicle data. For example, if zero values, vehicle status, and charging status within the invalid data range are incorrectly labeled, then the incorrectly labeled data are outliers in the original vehicle data. Server 104 can then correct these outliers using the same method as null value imputation. Afterward, server 104 can also perform data segmentation. For example, server 104 can segment the current state of the original vehicle data into three categories—driving, charging, and stationary—based on the information corresponding to vehicle status (vehicle_state) and charging status (charging_status).

[0141] S760 expands the new original vehicle data to obtain expanded original vehicle data.

[0142] Optionally, firstly, since there is an uneven distribution of positive and negative data samples in the new original vehicle data, the server 104 can perform data augmentation on the new original vehicle data to obtain undersampled original vehicle data. Because the original vehicle data itself contains a large amount of data, it is not suitable for data augmentation using interpolation methods such as SMOTE. In this embodiment, the server 104 can use undersampling to augment the new original vehicle data until the number of positive and negative data samples is equal, thus obtaining undersampled original vehicle data.

[0143] Second, the discrete and continuous data characteristics contained in the original vehicle data are shown in Table 1.

[0144] Table 1

[0145]

[0146] Since the original vehicle data contains both discrete categorical features and continuous quantitative features, this embodiment employs a batch general combined feature derivation method to augment the undersampled original vehicle data, thereby obtaining augmented original vehicle data, in order to improve classification performance. The steps of the batch general combined feature derivation method are as follows: Server 104 can combine different values ​​corresponding to discrete data with continuous data to form new features; and under the new features, grouping and summing based on vehicle identification numbers (vid) can expand the data dimensions and provide more data features for subsequent modeling. For example, some undersampled original vehicle data is shown in Table 2. Some augmented original vehicle data obtained using the batch general combined feature derivation method is shown in Table 3.

[0147] Table 2

[0148]

[0149] Table 3

[0150]

[0151] Referring to Tables 2 and 3, for vehicle number 1 and discrete data A, if discrete data A is 1, then the continuous data C related to both vehicle number 1 and discrete data A = 1 includes 4 and 1. Adding 4 and 1 gives 5, thus determining the value corresponding to vehicle number 1 and discrete data A = 1 & C is 5. For vehicle number 2 and discrete data B, if discrete data B is 2, then the continuous data C related to both vehicle number 2 and discrete data B = 2 does not exist. Therefore, the value corresponding to vehicle number 2 and discrete data B = 2 & C is 0.

[0152] S780 uses the Pearson correlation coefficient to filter the original vehicle data after data augmentation, resulting in historical vehicle data for multiple vehicles.

[0153] Optionally, the server 104 can first perform standardization and normalization on the original vehicle data after data augmentation to obtain processed original vehicle data, so as to avoid the difference in magnitude between different vehicle data affecting the model recognition and judgment. The standardization calculation formula is shown in formula (10).

[0154]

[0155] Where, x * For the standardized raw vehicle data, x i The original vehicle data i after augmentation of each data point, Let σ(x) be the mean of the original vehicle data after data augmentation, and let σ(x) be the standard deviation of the original vehicle data after data augmentation.

[0156] The normalization calculation formula is shown in formula (11).

[0157]

[0158] Where x′ represents the processed original vehicle data, x′ i For each standardized original vehicle data i, min(x′) i ) represents the minimum value in the standardized original vehicle data, max(x′) i ) represents the maximum value in the standardized original vehicle data.

[0159] Subsequently, due to feature derivation and data expansion, the vehicle data becomes sparse. Therefore, the original vehicle data after data expansion contains a large amount of redundant zero-value data. Based on this, it is necessary to perform appropriate data feature filtering on the original vehicle data after data expansion. For example, server 104 can calculate the Pearson correlation coefficient of any two processed original vehicle data. The formula for calculating the Pearson correlation coefficient is shown in formula (12).

[0160]

[0161] Where X, Y represent any two processed original vehicle data sets, ρ(X,Y) is the Pearson correlation coefficient of any two processed original vehicle data sets, and μ X σ is the expected value of the processed raw vehicle data. X E[(X-μ)] represents the standard deviation of the processed original vehicle data. X )(Y-μ Y[)] is used to calculate the covariance between any two processed original vehicle data.

[0162] Therefore, server 104 can sort the calculated Pearson correlation coefficients from largest to smallest to obtain a sorting result. From the sorting result, it can select a preset data entry with a higher Pearson correlation coefficient and identify this preset data entry as the historical vehicle data for multiple vehicles. This application does not limit the number of preset data entries; for example, 500 data entries can be selected as the historical vehicle data for multiple vehicles.

[0163] In this embodiment, raw vehicle data for multiple vehicles is acquired; outlier data is removed from the raw vehicle data to obtain new raw vehicle data. This new raw vehicle data is then augmented to obtain augmented raw vehicle data. This augmented data ensures that the number of positive and negative data samples in the historical vehicle data is equal and expands the data dimensionality, providing more data features for subsequent modeling. The augmented raw vehicle data is then filtered based on the Pearson correlation coefficient, enabling dimensionality reduction of the high-dimensional sparse data and thus identifying historical vehicle data for multiple vehicles suitable for model training.

[0164] In an optional embodiment, such as Figure 13 As shown, an anomaly detection method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the following steps are included:

[0165] S1302, Obtain raw vehicle data for multiple vehicles;

[0166] S1304, Delete the abnormal data in the original vehicle data to obtain new original vehicle data;

[0167] S1306, The new original vehicle data is augmented to obtain the augmented original vehicle data;

[0168] S1308: Based on the Pearson correlation coefficient, the original vehicle data after data augmentation was filtered to obtain historical vehicle data for multiple vehicles.

[0169] S1310, Calculate the first error of the initial support vector data description network based on historical vehicle data and the initial error calculation model; the initial error calculation model includes the initial autoencoder and the initial support vector data description network.

[0170] S1312, Calculate the second error of the initial variational autoencoder based on historical vehicle data and the initial anomaly detection model; the initial anomaly detection model includes the initial autoencoder, the initial variational autoencoder, and the initial support vector data description network;

[0171] S1314, Based on the first error and the second error, calculate the ratio of the information entropy between the first error and the second error, and use the ratio of the information entropy as the first model parameter;

[0172] S1316, Update the initial anomaly detection model based on the first model parameters to obtain the intermediate anomaly detection model;

[0173] S1318, Input historical vehicle data into the intermediate anomaly detection model to perform anomaly detection and generate the predicted anomaly detection results corresponding to the historical vehicle data;

[0174] S1320, Calculate the loss function based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to the historical vehicle data;

[0175] S1322, Determine the model parameters of the intermediate anomaly detection model based on the loss function;

[0176] S1324, Update the intermediate anomaly detection model based on the model parameters of the intermediate anomaly detection model to obtain a new intermediate anomaly detection model;

[0177] S1326, Update the initial error calculation model based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model;

[0178] S1328, The new error calculation model is used as the initial error calculation model, and the new intermediate anomaly detection model is used as the initial anomaly detection model for iterative calculation until the value of the loss function reaches the minimum. The new intermediate anomaly detection model corresponding to the minimum loss function is used as the preset anomaly detection model.

[0179] S1330, Obtain vehicle data of the vehicle to be tested;

[0180] S1332, Input the vehicle data of the vehicle to be detected into the preset anomaly detection model for anomaly detection and generate the anomaly detection result of the vehicle to be detected;

[0181] S1334 outputs the anomaly detection results for the vehicle under test.

[0182] Optional, such as Figure 14 As shown, Figure 14This is a schematic diagram of the overall architecture of the anomaly detection method in one embodiment. The overall architecture of the anomaly detection method in this application embodiment includes a data acquisition step, a preset anomaly detection model generation step, and a verification and analysis step. The data acquisition step includes acquiring raw vehicle data from multiple vehicles, preprocessing anomaly data, undersampling data, batch general combined feature derivation, standardization and normalization, and data feature filtering to obtain historical vehicle data for multiple vehicles. The preset anomaly detection model generation step includes constructing an initial error calculation model including an initial autoencoder and an initial support vector data description network, introducing an initial variational autoencoder to construct an initial anomaly detection model, balancing the error entropy weights, and model training to obtain a trained preset anomaly detection model. The specific processes of each step in the data acquisition step and the preset anomaly detection model generation step can be referred to the above embodiment and will not be repeated here.

[0183] The validation analysis steps include single-vehicle anomaly detection, multi-vehicle anomaly detection, performance comparison, and controlled variable experiments. For example, during model training, if the true positive rate (TPR) and false positive rate (FPR) are known, server 104 can plot an ROC (Receiver Operating Characteristic) curve in an FPR-TPR coordinate system (with FPR as the x-axis and TPR as the y-axis). Based on the ROC curve, the AUC (Area Under Curve) value and variance are calculated. The AUC value is used as a validity measure to observe the distribution of the data samples, and the mean (AUC) and standard deviation (Std) of the AUC values ​​are used to determine the effectiveness of the trained model. Each point on the ROC curve corresponds to a threshold. For each classifier, each threshold corresponds to a true positive rate (TPR) and a false positive rate (FPR), and AUC refers to the area enclosed by the ROC curve and the lower coordinate axis. The closer the AUC value is to 1, the better the model classification performance. The formula for calculating the true positive rate (TPR) is shown in formula (13), and the formula for calculating the false positive rate (FPR) is shown in formula (14).

[0184]

[0185]

[0186] Among them, TPR is the true positive rate, TP is the true positive rate, FP is the false positive rate, and FN is the false negative rate.

[0187] During the experiment, the classifier corresponding to the model can be applied to single-vehicle anomaly detection and multi-vehicle anomaly detection, and the performance of the trained model can be verified by performance comparison. To demonstrate the superiority of the anomaly detection method in this embodiment, HBOS, INFOREST, KNN, OCSVM, PCA, SOD and other schemes can also be compared, and the comparison results are shown in Table 4.

[0188] Table 4

[0189]

[0190] To demonstrate the effectiveness of the trained model, controlled variable experiments can be conducted, i.e., controlling variables for multiple vehicle data sets. For example: 1) An anomaly detection model (AE-SVDD) is constructed based on an autoencoder and a support vector data description network, with the error relative weight (i.e., the first model parameter γ) fixed at 1; 2) An anomaly detection model (Deep-SVDD) is constructed based on an autoencoder and a support vector data description network, without considering network reconstruction errors; 3) An anomaly detection model (VAE-SVDD) is constructed based on a variational autoencoder, an autoencoder, and an initial support vector data description network, with the error relative weight (i.e., the first model parameter γ) fixed at 1; 4) An anomaly detection model is constructed based on a one-dimensional convolutional neural network (Conv1d). The experimental results of the controlled variable experiments are shown in Table 5.

[0191] Table 5

[0192]

[0193] In the aforementioned anomaly detection method, the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network. Since the variational autoencoder maps each data point to its corresponding Gaussian distribution, and introduces random sampling noise during this mapping process, the Gaussian distributions for each data point are all different. Therefore, after combining the initial variational autoencoder with the initial autoencoder and the initial support vector data description network, the initial anomaly detection model can map the Gaussian distributions for each data point to a hypersphere. Because the Gaussian distributions for each data point are non-overlapping, they will not map to the same point in the hypersphere.

[0194] Furthermore, during the process of training the initial anomaly detection model to generate the preset anomaly detection model, the Gaussian distributions corresponding to each training data point will not be mapped to the same point in the hypersphere. Therefore, using the preset anomaly detection model can effectively avoid the hypersphere collapse phenomenon caused by mapping each training data point to the same point in the hypersphere. Based on this, the preset anomaly detection model has high accuracy. Next, the acquired vehicle data of the vehicle to be detected is input into the more accurate preset anomaly detection model for anomaly detection, which can generate more accurate anomaly detection results for the vehicle to be detected.

[0195] To improve the reliability and validity of anomaly detection in electric vehicles and significantly enhance the reliability of battery detection, this application combines a deep variational autoencoder (VAE) with an autoencoder and a support vector data description network (Deep-SVDD). The resulting model inherits the unsupervised classification characteristics of Deep-SVDD and the data generation characteristics of VAE, and can comprehensively consider the reconstruction error of the deep network and the SVDD error, thereby avoiding the hypersphere collapse phenomenon that occurs in traditional Deep-SVDD. Furthermore, a relative error balancing method based on training error entropy is proposed, achieving a true representation of the training error.

[0196] The above-mentioned anomaly detection methods can accurately predict various problems that may occur in electric vehicles, such as temperature difference alarms, battery high temperature alarms, overvoltage alarms for on-board energy storage devices, undervoltage alarms for on-board energy storage devices, low SOC alarms, single-cell overvoltage alarms, single-cell undervoltage alarms, excessively high SOC alarms, SOC jump alarms, rechargeable energy storage system mismatch alarms, poor battery cell consistency alarms, insulation alarms, DC-DC temperature alarms, braking system alarms, DC-DC status alarms, drive motor controller temperature alarms, high-voltage interlock status alarms, drive motor temperature alarms, and overcharging of on-board energy storage devices. Potential anomalies in electric vehicles are shown in Table 6.

[0197] Table 6

[0198]

[0199]

[0200] The aforementioned anomaly detection methods have broad application prospects and significant implications. Firstly, they offer a novel approach to the maintenance and inspection of new energy vehicles, reducing manufacturers' operational costs and improving vehicle safety and reliability. Secondly, they can help increase consumer trust and acceptance of new energy vehicles, promoting their market adoption. Finally, the general combined features and other preprocessing methods employed in these methods not only provide high-quality datasets for the electric vehicle sector but also offer valuable insights and application opportunities for anomaly detection and fault diagnosis in other fields. Therefore, these anomaly detection methods also have broad application prospects in intelligent transportation, smart cities, and other areas, making a significant contribution to the development of new energy vehicles and related industries.

[0201] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0202] Based on the same inventive concept, this application also provides an anomaly detection device for implementing the anomaly detection method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more anomaly detection device embodiments provided below can be found in the limitations of the anomaly detection method described above, and will not be repeated here.

[0203] In one embodiment, such as Figure 15 As shown, an anomaly detection device 1500 is provided, including: an acquisition module 1520, an anomaly detection module 1540, and an output module 1560, wherein:

[0204] The acquisition module 1520 is used to acquire vehicle data of the vehicle to be detected.

[0205] The anomaly detection module 1540 is used to input the vehicle data of the vehicle to be detected into the preset anomaly detection model for anomaly detection and generate the anomaly detection result of the vehicle to be detected. The preset anomaly detection model is generated based on the initial anomaly detection model. The initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder and an initial support vector data description network.

[0206] Output module 1560 is used to output the anomaly detection results of the vehicle under test.

[0207] In one embodiment, the anomaly detection device 1500 further includes:

[0208] The historical vehicle data acquisition module is used to acquire historical vehicle data for multiple vehicles.

[0209] The first model parameter calculation module is used to calculate the first model parameters of the initial anomaly detection model based on historical vehicle data, the initial anomaly detection model, and the initial error calculation model; the initial error calculation model includes the initial autoencoder and the initial support vector data description network.

[0210] The intermediate anomaly detection model generation module is used to update the initial anomaly detection model based on the parameters of the first model to obtain the intermediate anomaly detection model.

[0211] The preset anomaly detection model generation module is used to train the intermediate anomaly detection model based on historical vehicle data to obtain the preset anomaly detection model.

[0212] In one embodiment, the first model parameter calculation module includes:

[0213] The first error calculation unit is used to calculate the first error of the initial support vector data description network based on historical vehicle data and the initial error calculation model.

[0214] The second error calculation unit is used to calculate the second error of the initial variational autoencoder based on historical vehicle data and the initial anomaly detection model.

[0215] The first model parameter calculation unit is used to calculate the ratio of the information entropy between the first error and the second error based on the first error and the second error, and use the ratio of the information entropy as the first model parameter.

[0216] In one embodiment, the preset anomaly detection model generation module includes:

[0217] The model parameter determination unit is used to train the intermediate anomaly detection model based on historical vehicle data and loss function to obtain the model parameters of the intermediate anomaly detection model.

[0218] A new intermediate anomaly detection model generation unit is used to update the intermediate anomaly detection model based on the model parameters of the intermediate anomaly detection model to obtain a new intermediate anomaly detection model.

[0219] A new error calculation model generation unit is used to update the initial error calculation model based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model;

[0220] The preset anomaly detection model generation unit is used to iteratively calculate the new error calculation model as the initial error calculation model and the new intermediate anomaly detection model as the initial anomaly detection model until the value of the loss function reaches the minimum. The new intermediate anomaly detection model corresponding to the minimum loss function is then used as the preset anomaly detection model.

[0221] In one embodiment, the model parameter determination unit includes:

[0222] The predictive anomaly detection result generation subunit is used to input historical vehicle data into the intermediate anomaly detection model for anomaly detection and generate the predicted anomaly detection result corresponding to the historical vehicle data.

[0223] The loss function calculation subunit is used to calculate the loss function based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to the historical vehicle data.

[0224] The model parameter determination sub-unit is used to determine the model parameters of the intermediate anomaly detection model based on the loss function.

[0225] In one embodiment, the historical vehicle data acquisition module includes:

[0226] The raw vehicle data acquisition unit is used to acquire raw vehicle data from multiple vehicles.

[0227] A new raw vehicle data generation unit is used to delete abnormal data in the raw vehicle data and obtain new raw vehicle data;

[0228] The data augmentation unit is used to augment new original vehicle data to obtain augmented original vehicle data.

[0229] The data filtering unit is used to filter the original vehicle data after data augmentation based on the Pearson correlation coefficient to obtain historical vehicle data for multiple vehicles.

[0230] Each module in the aforementioned anomaly detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0231] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 16 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores anomaly detection data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements an anomaly detection method.

[0232] Those skilled in the art will understand that Figure 16 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0233] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0234] Obtain vehicle data for the vehicle to be inspected;

[0235] The vehicle data of the vehicle to be detected is input into the preset anomaly detection model for anomaly detection, and anomaly detection results of the vehicle to be detected are generated. The preset anomaly detection model is generated based on the initial anomaly detection model. The initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network.

[0236] Output the anomaly detection results for the vehicle to be tested.

[0237] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0238] Acquire historical vehicle data for multiple vehicles;

[0239] Based on historical vehicle data, the initial anomaly detection model, and the initial error calculation model, the first model parameters of the initial anomaly detection model are calculated; the initial error calculation model includes the initial autoencoder and the initial support vector data description network.

[0240] The initial anomaly detection model is updated based on the parameters of the first model to obtain the intermediate anomaly detection model;

[0241] The intermediate anomaly detection model is trained based on historical vehicle data to obtain the preset anomaly detection model.

[0242] In one embodiment, based on historical vehicle data, an initial anomaly detection model, and an initial error calculation model, the first model parameters of the initial anomaly detection model are calculated. When the processor executes the computer program, it further implements the following steps:

[0243] Based on historical vehicle data and the initial error calculation model, calculate the first error of the initial support vector data description network;

[0244] Based on historical vehicle data and the initial anomaly detection model, the second error of the initial variational autoencoder is calculated;

[0245] Based on the first error and the second error, calculate the ratio of the information entropy between the first error and the second error, and use the ratio of the information entropy as the first model parameter.

[0246] In one embodiment, an intermediate anomaly detection model is trained based on historical vehicle data to obtain a preset anomaly detection model. When the processor executes the computer program, it also performs the following steps:

[0247] Based on historical vehicle data and loss function, the intermediate anomaly detection model is trained to obtain the model parameters of the intermediate anomaly detection model;

[0248] The intermediate anomaly detection model is updated based on the model parameters of the intermediate anomaly detection model to obtain a new intermediate anomaly detection model;

[0249] The initial error calculation model is updated based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model;

[0250] The new error calculation model is used as the initial error calculation model, and the new intermediate anomaly detection model is used as the initial anomaly detection model for iterative calculation until the value of the loss function reaches its minimum. The new intermediate anomaly detection model corresponding to the minimum loss function is then used as the preset anomaly detection model.

[0251] In one embodiment, the intermediate anomaly detection model is trained based on historical vehicle data and a loss function to obtain the model parameters of the intermediate anomaly detection model. When the processor executes the computer program, it also performs the following steps:

[0252] Historical vehicle data is input into an intermediate anomaly detection model for anomaly detection, generating predicted anomaly detection results corresponding to the historical vehicle data.

[0253] Calculate the loss function based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to historical vehicle data;

[0254] Based on the loss function, determine the model parameters of the intermediate anomaly detection model.

[0255] In one embodiment, historical vehicle data of multiple vehicles is acquired, and the processor, while executing the computer program, further performs the following steps:

[0256] Obtain raw vehicle data for multiple vehicles;

[0257] Remove abnormal data from the original vehicle data to obtain new original vehicle data;

[0258] The new original vehicle data is augmented to obtain the augmented original vehicle data.

[0259] The original vehicle data after data augmentation was filtered based on the Pearson correlation coefficient to obtain historical vehicle data for multiple vehicles.

[0260] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0261] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments. It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0262] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0263] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0264] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. An anomaly detection method characterized by, The method includes: Acquire vehicle data of the vehicle to be tested; the vehicle data includes vehicle speed, vehicle charging status and vehicle battery voltage; The vehicle data of the vehicle to be detected is input into a preset anomaly detection model for anomaly detection, and the anomaly detection result of the vehicle to be detected is generated and output. The preset anomaly detection model is generated based on an initial anomaly detection model and an initial error calculation model. The initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder, and an initial support vector data description network. The initial error calculation model includes the initial autoencoder and the initial support vector data description network. The initial variational autoencoder is used to map each data point output by the initial autoencoder to a Gaussian distribution corresponding to each data point to introduce random sampling noise, avoiding hypersphere collapse caused by mapping each data point to the same point in the hypersphere space. The method further includes: acquiring historical vehicle data from multiple vehicles; calculating a first error of the initial support vector data description network based on the historical vehicle data and the initial error calculation model; calculating a second error of the initial variational autoencoder based on the historical vehicle data and the initial anomaly detection model; calculating the ratio of information entropy between the first error and the second error based on the first error and the second error, and using the ratio of information entropy as a first model parameter; updating the initial anomaly detection model based on the first model parameter to obtain an intermediate anomaly detection model; and training the intermediate anomaly detection model based on the historical vehicle data and a loss function to obtain the intermediate anomaly detection model. The model parameters of the intermediate anomaly detection model are determined; the intermediate anomaly detection model is updated based on the model parameters of the intermediate anomaly detection model to obtain a new intermediate anomaly detection model; the initial error calculation model is updated based on the model parameters of the intermediate anomaly detection model to obtain a new error calculation model; the new error calculation model is used as the initial error calculation model, and the new intermediate anomaly detection model is used as the initial anomaly detection model for iterative calculation until the value of the loss function reaches its minimum; the new intermediate anomaly detection model corresponding to the minimum loss function is used as the preset anomaly detection model; the historical vehicle data includes vehicle speed, vehicle charging status, and vehicle battery voltage.

2. The method of claim 1, wherein, The step of training the intermediate anomaly detection model based on the historical vehicle data and the loss function to obtain the model parameters of the intermediate anomaly detection model includes: The historical vehicle data is input into the intermediate anomaly detection model for anomaly detection, and a predicted anomaly detection result corresponding to the historical vehicle data is generated. The loss function is calculated based on the predicted anomaly detection results and the labeled anomaly detection results corresponding to the historical vehicle data; Based on the loss function, the model parameters of the intermediate anomaly detection model are determined.

3. The method of claim 1, wherein, The acquisition of historical vehicle data for multiple vehicles includes: Obtain raw vehicle data for multiple vehicles; Delete the abnormal data from the original vehicle data to obtain new original vehicle data; The new original vehicle data is augmented to obtain augmented original vehicle data. The original vehicle data after data augmentation is filtered based on the Pearson correlation coefficient to obtain the historical vehicle data of the multiple vehicles.

4. An anomaly detection device for implementing the anomaly detection method as described in claim 1, characterized in that, The device includes: The acquisition module is used to acquire vehicle data of the vehicle to be detected; An anomaly detection module is used to input the vehicle data of the vehicle to be detected into a preset anomaly detection model for anomaly detection and generate anomaly detection results for the vehicle to be detected; the preset anomaly detection model is generated based on an initial anomaly detection model trained on it; the initial anomaly detection model includes an initial autoencoder, an initial variational autoencoder and an initial support vector data description network; The output module is used to output the abnormal detection results of the vehicle under test.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.

7. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.