Stream data anomaly detection method and system and storage medium

Through sliding window segmentation and density-based clustering algorithm combined with k-nearest neighbor algorithm, parameters are automatically determined, which solves the problem of insufficient performance of existing streaming data anomaly detection in high-dimensional and noisy data processing, and achieves more efficient anomaly detection results. .

CN118764440AInactive Publication Date: 2024-10-11GUANGDONG POLYTECHNIC NORMAL UNIV

Patent Information

Application Number
CN202411045604.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-10-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing streaming data anomaly detection algorithms have limited performance when processing high-dimensional data and noisy data, and parameter settings are cumbersome, making it difficult to achieve ideal results.

Method used

Sliding window segmented streaming data is used, and the density-based clustering algorithm and k-nearest neighbor algorithm are used for clustering, the cluster center distance and the mean cluster center distance are calculated, the neighborhood radius and the minimum number of cluster points are automatically determined, and the impact of noise data is reduced. .

Benefits of technology

It improves the accuracy and generalization of streaming data anomaly detection, is suitable for different data sets, enhances the processing capabilities of high-dimensional data, and reduces computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118764440A_ABST
    Figure CN118764440A_ABST
Patent Text Reader

Abstract

The invention discloses a streaming data anomaly detection method and system and a storage medium, and the method comprises the steps: obtaining streaming data, setting a sliding window, carrying out the window segmentation of the streaming data based on the sliding window, and obtaining segmented window data; clustering the segmented window data by adopting a density-based clustering algorithm to obtain a clustering result; distinguishing a plurality of clusters and discrete points based on the clustering result, calculating a cluster center mean value of the clusters, and calculating a cluster center distance from each discrete point to the cluster center mean value; and calculating a cluster center distance mean value based on the distance from each discrete point to the cluster center mean value, and carrying out abnormal data point detection based on the cluster center distance and the cluster center distance mean value. According to the invention, the anomaly detection precision of the stream data is improved, and the anomaly detection of the stream data can achieve a more ideal effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method, system and storage medium for detecting anomalies in streaming data. Background Art

[0002] In the era of the Internet of Things, a large number of sensor devices collect and generate various sensor data over time, which are applicable to a wide range of fields and applications. Effectively analyzing these streaming data can provide valuable insights for various use cases and applications. Anomaly detection, as an important research topic, also faces new challenges in the context of streaming data.

[0003] There are many types of anomaly detection algorithms, which can be divided into two categories: offline and online according to the way they process data. Offline algorithms such as Isolation Forest are mainly used for the analysis of static data sets, while online algorithms such as xStream can process streaming data. Some offline algorithms can also process streaming data, but they need special adjustments. Common offline algorithms include adaptive anomaly detection algorithm and empirical cumulative distribution function. The adaptive anomaly detection algorithm is a parameter-free algorithm developed specifically for offline data, but it has a quantitative limit on the number of samples in the data set; the empirical cumulative distribution function uses the probability of data extreme values ​​to detect anomalies, but its performance is limited when processing complex structured data. Online algorithms such as stream typicality eccentricity data analysis, but it requires setting an eccentricity comparison threshold. In this regard, an algorithm combining density-based spatial clustering algorithm and support vector machine is currently proposed, but the algorithm requires users to manually set the neighborhood radius and minimum number of points, and the parameters applicable to different data sets are often different. Manually setting parameters is difficult to achieve generalization. At the same time, the existing density-based spatial clustering algorithm has limited processing capabilities for high-dimensional data and is sensitive to noise data, resulting in the failure of anomaly detection of streaming data to achieve the expected effect. Summary of the invention

[0004] The purpose of the present invention is to overcome the deficiencies of the prior art. The present invention provides a method, system and storage medium for detecting anomalies in streaming data, which improve the accuracy of anomaly detection in streaming data and enable anomaly detection in streaming data to achieve a more ideal effect.

[0005] In order to solve the above technical problems, the present invention provides a method for detecting anomalies in streaming data, the method comprising:

[0006] Acquire stream data, set a sliding window, and perform window segmentation on the stream data based on the sliding window to obtain segmented window data;

[0007] Clustering the segmented window data using a density-based clustering algorithm to obtain a clustering result;

[0008] Based on the clustering result, a number of clusters and discrete points are distinguished, the cluster center means of the clusters are calculated, and the cluster center distance from each discrete point to the cluster center mean is calculated;

[0009] The mean of the cluster center distances is calculated based on the cluster center distances from each discrete point to the cluster center mean, and abnormal data point detection is performed based on the cluster center distances and the mean of the cluster center distances.

[0010] Optionally, the acquiring of stream data includes:

[0011] The number of streaming data points in the streaming data source that enter the sliding window is set, and streaming data is obtained from the streaming data source based on the number of streaming data points.

[0012] Optionally, the window segmenting the stream data based on the sliding window to obtain segmented window data includes:

[0013] Setting a window size and a sliding step of the sliding window, and sliding the sliding window on the stream data based on the sliding step;

[0014] When the sliding window is slid on the stream data, the stream data is segmented into windows based on the window size to obtain segmented window data.

[0015] Optionally, clustering the segmented window data using a density-based clustering algorithm to obtain a clustering result includes:

[0016] The neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of points in the cluster is determined based on the number of nearest neighbors;

[0017] Determining the core point of the segmented window data based on the neighborhood radius and the minimum number of points of the cluster;

[0018] Based on the core point, the neighborhood radius and the minimum number of points of the cluster are used to perform data point expansion to obtain a clustering cluster.

[0019] Optionally, the calculating the neighborhood radius based on the k-nearest neighbor algorithm includes:

[0020] Calculating the distance between the data points of the segmented window data, performing neighbor attribution division based on the distance between the data points, and obtaining a number of neighbor attributions;

[0021] Based on the majority voting rule, a number of neighbor affiliations are classified and decided to obtain the target neighbor affiliation;

[0022] A neighborhood radius is determined based on the target neighbor affiliation.

[0023] Optionally, distinguishing a number of clusters and discrete points based on the clustering result includes:

[0024] Determine the cluster center of each cluster based on the clustering result, and calculate the relative distance between each data point and the cluster center;

[0025] The relative distance is compared with a preset distance threshold, and if the relative distance is greater than the preset distance threshold, the corresponding data point is determined to be a discrete point.

[0026] Optionally, distinguishing a number of clusters and discrete points based on the clustering result includes:

[0027] After distinguishing a number of clusters and discrete points, the discrete points are combined with the stream data in the next sliding window to generate new segmented window data, and the new segmented window data is re-clustered.

[0028] Optionally, the abnormal data point detection based on the cluster center distance and the cluster center distance mean includes:

[0029] The cluster center distance is compared with the mean of the cluster center distances. If the cluster center distance is greater than the mean of the cluster center distances, the discrete point corresponding to the cluster center distance is taken as an abnormal data point.

[0030] In addition, the present invention also provides a stream data anomaly detection system, the system comprising:

[0031] Sliding window segmentation module: used to obtain stream data, set a sliding window, and perform window segmentation on the stream data based on the sliding window to obtain segmented window data;

[0032] Clustering module: used to cluster the segmented window data using a density-based clustering algorithm to obtain a clustering result;

[0033] Cluster center parameter calculation module: used to distinguish a number of clusters and discrete points based on the clustering results, calculate the cluster center mean of the cluster, and calculate the cluster center distance from each discrete point to the cluster center mean;

[0034] Anomaly detection module: used to calculate the mean of cluster center distances based on the cluster center distances from each discrete point to the cluster center mean, and perform abnormal data point detection based on the cluster center distances and the mean of cluster center distances.

[0035] In addition, the present invention also provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned method for detecting abnormalities in streaming data.

[0036] In an embodiment of the present invention, the stream data is segmented into windows based on a sliding window so that a certain amount of data can be processed each time to reduce computational complexity. The segmented window data is clustered using a density-based clustering algorithm, the neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of cluster points is determined based on the number of nearest neighbors, thereby avoiding the limitations of manually setting the neighborhood radius and the minimum number of cluster points, being applicable to parameters of different data sets, and improving generalization. At the same time, the neighborhood radius is calculated by the k-nearest neighbor algorithm and the minimum number of cluster points is determined by the number of nearest neighbors, thereby improving the processing capability of high-dimensional data. Abnormal data point detection is performed based on the cluster center distance and the mean of the cluster center distance, thereby reducing the impact of the density-based clustering algorithm on the sensitivity of noise data, improving the accuracy of abnormal detection of stream data, and enabling abnormal detection of stream data to achieve a more ideal effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0038] Figure 1 is a flow chart of a method for detecting abnormalities in streaming data in an embodiment of the present invention;

[0039] Figure 2 Schematic diagram of the structure of the abnormality detection system for streaming data in an embodiment of the present invention. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0041] Embodiment 1

[0042] See also Figure 1 , Figure 1 : is a flow chart of a method for detecting abnormalities in streaming data in an embodiment of the present invention, the method comprising:

[0043] S11: acquiring stream data, setting a sliding window, and performing window segmentation on the stream data based on the sliding window to obtain segmented window data;

[0044] In a specific implementation of the present invention, the acquiring of stream data includes: setting the number of stream data points in the stream data source that enter the sliding window, and acquiring stream data from the stream data source based on the number of stream data points.

[0045] Furthermore, the window segmenting of the stream data based on the sliding window to obtain segmented window data includes: setting a window size and a sliding step of the sliding window, and sliding the sliding window on the stream data based on the sliding step; when sliding the sliding window on the stream data, window segmenting the stream data based on the window size to obtain segmented window data.

[0046] Specifically, the number of stream data points entering the sliding window in the stream data source is set, and the number of stream data points can be set to one hundred. Based on the number of stream data points, stream data is obtained from the stream data source. The stream data source can be a sensor network of the Internet of Things, and the stream data can be sensor data. Each time, a fixed number of stream data enters the sliding window through the message queue. Stream data is a set of sequential, large, fast, and continuous data sequences. Generally, stream data can be regarded as a dynamic data set that grows infinitely over time. Unlike batch data, stream data does not process a fixed set of data at one time, but processes real-time data continuously. It is applied to network monitoring, sensor networks, aerospace, and meteorological measurement and control. The stream data is sorted and sorted according to the corresponding time node sequence to obtain the sorted stream data. The tuple density of the data is calculated based on the sorted stream data, and the corresponding change amplitude is calculated based on the tuple density. The length of the sliding time window is determined based on the tuple density and the corresponding change amplitude, and the sliding window is set based on the length of the sliding time window. The window size and sliding step of the sliding window are set. Each sliding window contains a fixed number of data points. Only the window size amount of data is processed each time. The acquired stream data is sequentially input into the sliding window. The sliding window is slid on the stream data based on the sliding step. When the sliding window is slid on the stream data, the stream data is segmented based on the window size, that is, the sliding window processes the stream data of the window size. The window size can be set to one hundred to obtain segmented window data. It should be noted that, except for the first time when the sliding window processes the newly acquired stream data, the rest of the processing is the combination of the unprocessed discrete points in the cluster and the newly acquired stream data. The stream data is segmented based on the sliding window so that a certain amount of data can be processed each time to reduce the computational complexity.

[0047] S12: clustering the segmented window data using a density-based clustering algorithm to obtain a clustering result;

[0048] In the specific implementation process of the present invention, the density-based clustering algorithm is used to cluster the segmented window data to obtain a clustering result, including: calculating the neighborhood radius based on the k-nearest neighbor algorithm, and determining the minimum number of cluster points based on the number of nearest neighbors; determining the core point of the segmented window data based on the neighborhood radius and the minimum number of cluster points; based on the core point, using the neighborhood radius and the minimum number of cluster points to expand the data points to obtain a cluster cluster.

[0049] Furthermore, the calculation of the neighborhood radius based on the k-nearest neighbor algorithm includes: calculating the distance between the data points of the segmented window data, dividing the neighbor attributions based on the distance between the data points, and obtaining a number of neighbor attributions; making classification decisions on a number of neighbor attributions based on a majority voting rule to obtain a target neighbor attribution; and determining the neighborhood radius based on the target neighbor attribution.

[0050] Specifically, the k-nearest neighbor algorithm uses training data to divide the feature vector space and uses the division result as the final algorithm model. There is a sample data set, also called a training sample set, and each data in the sample set has a label, that is, each data in the sample set has a corresponding relationship with the classification to which it belongs. Calculate the distance between the data points of the segmented window data, and measure its similarity by calculating the distance. When selecting the distance calculation method, the attribute type of the data needs to be considered. Because the stream data is continuous attribute data, the distance between the data points of the segmented window data can be calculated by calculating the Euclidean distance. The neighbor attribution is divided based on the distance between the data points, that is, the neighborhood radius is divided according to the distance between the data points, and several neighbor attributions are obtained. Classification decisions are made on several neighbor attributions based on the majority voting rule, that is, by calculating the number of times the neighborhood radius appears, the distance of the data point with the most occurrences is used as the final target neighbor attribution, and the target neighbor attribution is obtained; the neighborhood radius is determined based on the target neighbor attribution, that is, the data point distance is used as the neighborhood radius. The minimum number of points in a cluster is determined based on the number of nearest neighbors, that is, the k value of the k-nearest neighbor algorithm is used as the minimum number of points in the cluster. The selection of the k value is an important parameter in the k-nearest neighbor algorithm, which is a hyperparameter. Too large a k value may lead to underfitting, and too small a k value may lead to overfitting. The k value is selected by the cross-validation method, starting from selecting a smaller k value, and continuously increasing the k value, and then calculating the variance of the validation set, and finally finding a more suitable k value, that is, selecting the number of nearest neighbors. The K nearest neighbor algorithm is applicable to various types of data, and it is insensitive to outliers and can process noise data. Based on the neighborhood radius and the minimum number of points in the cluster, the core point of the segmented window data is determined, and the distance between each data point and other data points in the segmented window data is calculated. The number of flow data contained in the circle centered on each data point can be obtained according to the neighborhood radius by calculating the Euclidean distance. If the number is greater than or equal to the minimum number of points in the cluster, the data point is used as the core point of the segmented window data. Based on the core point, the data point expansion is performed using the neighborhood radius and the minimum number of cluster points. For each core point, all data objects within a circle centered on it are divided into a cluster, and the radius of the circle is the neighborhood radius. For all data objects that are not core points, if they are within the neighborhood radius of a core point, they are marked as boundary points, otherwise they are marked as noise points and the noise points are removed. For a core point, if there are other core points in its neighborhood radius, the two core points and the flow data points in their neighborhoods are merged into one cluster. By recursively merging, all clustering clusters are obtained and the clustering results are output.The segmented window data is clustered using a density-based clustering algorithm, the neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of cluster points is determined based on the number of nearest neighbors, thereby avoiding the limitations brought about by manually setting the neighborhood radius and the minimum number of cluster points, being applicable to parameters of different data sets, and improving generalization. At the same time, by calculating the neighborhood radius through the k-nearest neighbor algorithm and determining the minimum number of cluster points through the number of nearest neighbors, the processing capability of high-dimensional data can be improved.

[0051] S13: distinguishing a number of clusters and discrete points based on the clustering result, calculating the cluster center mean of the cluster, and calculating the cluster center distance from each discrete point to the cluster center mean;

[0052] In the specific implementation process of the present invention, the method of distinguishing several clusters and discrete points based on the clustering results includes: determining the cluster center of each cluster based on the clustering results, and calculating the relative distance between each data point and the cluster center; comparing the relative distance with a preset distance threshold, and if the relative distance is greater than the preset distance threshold, judging that the corresponding data point is a discrete point.

[0053] Furthermore, the method of distinguishing several clusters and discrete points based on the clustering results includes: after distinguishing several clusters and discrete points, combining the discrete points with the stream data in the next sliding window to generate new segmented window data, and re-clustering the new segmented window data.

[0054] Specifically, the mean of all data points in the cluster cluster in the clustering result is calculated, and the mean is used as the cluster center of the subcluster. The relative distance between each data point and the cluster center is calculated, and the relative distance between each data point and the cluster center is calculated using the Euclidean distance. The relative distance is compared with the preset distance threshold. If the relative distance is greater than the preset distance threshold, the corresponding data point is determined to be a discrete point. The cluster center mean of the cluster is calculated by the cluster center and the number beam of cluster centers, and the cluster center distance from each discrete point to the cluster center mean is calculated. Similarly, the cluster center distance from each discrete point to the cluster center mean can be calculated by the Euclidean distance. After distinguishing several clusters and discrete points, the discrete points are combined with the stream data in the next sliding window to generate new segmented window data, and the new segmented window data is re-clustered until the clustering of all stream data is completed.

[0055] S14: Calculate the mean of cluster center distances based on the cluster center distances from each discrete point to the cluster center mean, and perform abnormal data point detection based on the cluster center distances and the mean of cluster center distances.

[0056] In the specific implementation process of the present invention, the abnormal data point detection based on the cluster center distance and the cluster center distance mean includes: comparing the cluster center distance with the cluster center distance mean, if the cluster center distance is greater than the cluster center distance mean, then taking the discrete point corresponding to the cluster center distance as an abnormal data point.

[0057] Specifically, after completing the clustering of all the stream data, the mean of the cluster center distance is calculated based on the cluster center distance from each discrete point to the cluster center mean, that is, the cluster center distance matrix is ​​calculated based on the cluster center distances of all discrete points and their corresponding quantities, and the cluster center distance is compared with the mean of the cluster center distance. If the cluster center distance is greater than the mean of the cluster center distance, the discrete point corresponding to the cluster center distance is regarded as an abnormal data point. Abnormal data point detection is performed based on the cluster center distance and the mean of the cluster center distance, which reduces the impact of the density-based clustering algorithm on the sensitivity of noise data, improves the accuracy of abnormal detection of stream data, and enables abnormal detection of stream data to achieve a more ideal effect.

[0058] In an embodiment of the present invention, the stream data is segmented into windows based on a sliding window so that a certain amount of data can be processed each time to reduce computational complexity. The segmented window data is clustered using a density-based clustering algorithm, the neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of cluster points is determined based on the number of nearest neighbors, thereby avoiding the limitations of manually setting the neighborhood radius and the minimum number of cluster points, being applicable to parameters of different data sets, and improving generalization. At the same time, the neighborhood radius is calculated by the k-nearest neighbor algorithm and the minimum number of cluster points is determined by the number of nearest neighbors, thereby improving the processing capability of high-dimensional data. Abnormal data point detection is performed based on the cluster center distance and the mean of the cluster center distance, thereby reducing the impact of the density-based clustering algorithm on the sensitivity of noise data, improving the accuracy of abnormal detection of stream data, and enabling abnormal detection of stream data to achieve a more ideal effect.

[0059] Embodiment 2

[0060] See also Figure 2 , Figure 2 : is a schematic diagram of the structure of a stream data anomaly detection system in an embodiment of the present invention, the system includes:

[0061] Sliding window segmentation module 21: used for acquiring stream data, setting a sliding window, and performing window segmentation on the stream data based on the sliding window to obtain segmented window data;

[0062] In a specific implementation of the present invention, the acquiring of stream data includes: setting the number of stream data points in the stream data source that enter the sliding window, and acquiring stream data from the stream data source based on the number of stream data points.

[0063] Furthermore, the window segmenting of the stream data based on the sliding window to obtain segmented window data includes: setting a window size and a sliding step of the sliding window, and sliding the sliding window on the stream data based on the sliding step; when sliding the sliding window on the stream data, window segmenting the stream data based on the window size to obtain segmented window data.

[0064] Specifically, the number of stream data points entering the sliding window in the stream data source is set, and the number of stream data points can be set to one hundred. Based on the number of stream data points, stream data is obtained from the stream data source. The stream data source can be a sensor network of the Internet of Things, and the stream data can be sensor data. Each time, a fixed number of stream data enters the sliding window through the message queue. Stream data is a set of sequential, large, fast, and continuous data sequences. Generally, stream data can be regarded as a dynamic data set that grows infinitely over time. Unlike batch data, stream data does not process a fixed set of data at one time, but processes real-time data continuously. It is applied to network monitoring, sensor networks, aerospace, and meteorological measurement and control. The stream data is sorted and sorted according to the corresponding time node sequence to obtain the sorted stream data. The tuple density of the data is calculated based on the sorted stream data, and the corresponding change amplitude is calculated based on the tuple density. The length of the sliding time window is determined based on the tuple density and the corresponding change amplitude, and the sliding window is set based on the length of the sliding time window. The window size and sliding step of the sliding window are set. Each sliding window contains a fixed number of data points. Only the window size amount of data is processed each time. The acquired stream data is sequentially input into the sliding window. The sliding window is slid on the stream data based on the sliding step. When the sliding window is slid on the stream data, the stream data is segmented based on the window size, that is, the sliding window processes the stream data of the window size. The window size can be set to one hundred to obtain segmented window data. It should be noted that, except for the first time when the sliding window processes the newly acquired stream data, the rest of the processing is the combination of the unprocessed discrete points in the cluster and the newly acquired stream data. The stream data is segmented based on the sliding window so that a certain amount of data can be processed each time to reduce the computational complexity.

[0065] Clustering module 22: used to cluster the segmented window data using a density-based clustering algorithm to obtain a clustering result;

[0066] In the specific implementation process of the present invention, the density-based clustering algorithm is used to cluster the segmented window data to obtain a clustering result, including: calculating the neighborhood radius based on the k-nearest neighbor algorithm, and determining the minimum number of cluster points based on the number of nearest neighbors; determining the core point of the segmented window data based on the neighborhood radius and the minimum number of cluster points; based on the core point, using the neighborhood radius and the minimum number of cluster points to expand the data points to obtain a cluster cluster.

[0067] Furthermore, the calculation of the neighborhood radius based on the k-nearest neighbor algorithm includes: calculating the distance between the data points of the segmented window data, dividing the neighbor attributions based on the distance between the data points, and obtaining a number of neighbor attributions; making classification decisions on a number of neighbor attributions based on a majority voting rule to obtain a target neighbor attribution; and determining the neighborhood radius based on the target neighbor attribution.

[0068] Specifically, the k-nearest neighbor algorithm uses training data to divide the feature vector space and uses the division result as the final algorithm model. There is a sample data set, also called a training sample set, and each data in the sample set has a label, that is, each data in the sample set has a corresponding relationship with the classification to which it belongs. Calculate the distance between the data points of the segmented window data, and measure its similarity by calculating the distance. When selecting the distance calculation method, the attribute type of the data needs to be considered. Because the stream data is continuous attribute data, the distance between the data points of the segmented window data can be calculated by calculating the Euclidean distance. The neighbor attribution is divided based on the distance between the data points, that is, the neighborhood radius is divided according to the distance between the data points, and several neighbor attributions are obtained. Classification decisions are made on several neighbor attributions based on the majority voting rule, that is, by calculating the number of times the neighborhood radius appears, the distance of the data point with the most occurrences is used as the final target neighbor attribution, and the target neighbor attribution is obtained; the neighborhood radius is determined based on the target neighbor attribution, that is, the data point distance is used as the neighborhood radius. The minimum number of points in a cluster is determined based on the number of nearest neighbors, that is, the k value of the k-nearest neighbor algorithm is used as the minimum number of points in the cluster. The selection of the k value is an important parameter in the k-nearest neighbor algorithm, which is a hyperparameter. Too large a k value may lead to underfitting, and too small a k value may lead to overfitting. The k value is selected by the cross-validation method, starting from selecting a smaller k value, and continuously increasing the k value, and then calculating the variance of the validation set, and finally finding a more suitable k value, that is, selecting the number of nearest neighbors. The K nearest neighbor algorithm is applicable to various types of data, and it is insensitive to outliers and can process noise data. Based on the neighborhood radius and the minimum number of points in the cluster, the core point of the segmented window data is determined, and the distance between each data point and other data points in the segmented window data is calculated. The number of flow data contained in the circle centered on each data point can be obtained according to the neighborhood radius by calculating the Euclidean distance. If the number is greater than or equal to the minimum number of points in the cluster, the data point is used as the core point of the segmented window data. Based on the core point, the data point expansion is performed using the neighborhood radius and the minimum number of cluster points. For each core point, all data objects within a circle centered on it are divided into a cluster, and the radius of the circle is the neighborhood radius. For all data objects that are not core points, if they are within the neighborhood radius of a core point, they are marked as boundary points, otherwise they are marked as noise points and the noise points are removed. For a core point, if there are other core points in its neighborhood radius, the two core points and the flow data points in their neighborhoods are merged into one cluster. By recursively merging, all clustering clusters are obtained and the clustering results are output.The segmented window data is clustered using a density-based clustering algorithm, the neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of cluster points is determined based on the number of nearest neighbors, thereby avoiding the limitations brought about by manually setting the neighborhood radius and the minimum number of cluster points, being applicable to parameters of different data sets, and improving generalization. At the same time, by calculating the neighborhood radius through the k-nearest neighbor algorithm and determining the minimum number of cluster points through the number of nearest neighbors, the processing capability of high-dimensional data can be improved.

[0069] Cluster center parameter calculation module 23: used to distinguish a number of clusters and discrete points based on the clustering results, calculate the cluster center mean of the cluster, and calculate the cluster center distance from each discrete point to the cluster center mean;

[0070] In the specific implementation process of the present invention, the method of distinguishing several clusters and discrete points based on the clustering results includes: determining the cluster center of each cluster based on the clustering results, and calculating the relative distance between each data point and the cluster center; comparing the relative distance with a preset distance threshold, and if the relative distance is greater than the preset distance threshold, judging that the corresponding data point is a discrete point.

[0071] Furthermore, the method of distinguishing several clusters and discrete points based on the clustering results includes: after distinguishing several clusters and discrete points, combining the discrete points with the stream data in the next sliding window to generate new segmented window data, and re-clustering the new segmented window data.

[0072] Specifically, the mean of all data points in the cluster cluster in the clustering result is calculated, and the mean is used as the cluster center of the subcluster. The relative distance between each data point and the cluster center is calculated, and the relative distance between each data point and the cluster center is calculated using the Euclidean distance. The relative distance is compared with the preset distance threshold. If the relative distance is greater than the preset distance threshold, the corresponding data point is determined to be a discrete point. The cluster center mean of the cluster is calculated by the cluster center and the number beam of cluster centers, and the cluster center distance from each discrete point to the cluster center mean is calculated. Similarly, the cluster center distance from each discrete point to the cluster center mean can be calculated by the Euclidean distance. After distinguishing several clusters and discrete points, the discrete points are combined with the stream data in the next sliding window to generate new segmented window data, and the new segmented window data is re-clustered until the clustering of all stream data is completed.

[0073] Anomaly detection module 24: used to calculate the mean of cluster center distances based on the cluster center distances from each discrete point to the cluster center mean, and perform abnormal data point detection based on the cluster center distances and the mean of cluster center distances.

[0074] In the specific implementation process of the present invention, the abnormal data point detection based on the cluster center distance and the cluster center distance mean includes: comparing the cluster center distance with the cluster center distance mean, if the cluster center distance is greater than the cluster center distance mean, then taking the discrete point corresponding to the cluster center distance as an abnormal data point.

[0075] Specifically, after completing the clustering of all the stream data, the mean of the cluster center distance is calculated based on the cluster center distance from each discrete point to the cluster center mean, that is, the cluster center distance matrix is ​​calculated based on the cluster center distances of all discrete points and their corresponding quantities, and the cluster center distance is compared with the mean of the cluster center distance. If the cluster center distance is greater than the mean of the cluster center distance, the discrete point corresponding to the cluster center distance is regarded as an abnormal data point. Abnormal data point detection is performed based on the cluster center distance and the mean of the cluster center distance, which reduces the impact of the density-based clustering algorithm on the sensitivity of noise data, improves the accuracy of abnormal detection of stream data, and enables abnormal detection of stream data to achieve a more ideal effect.

[0076] In an embodiment of the present invention, the stream data is segmented into windows based on a sliding window so that a certain amount of data can be processed each time to reduce computational complexity. The segmented window data is clustered using a density-based clustering algorithm, the neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of cluster points is determined based on the number of nearest neighbors, thereby avoiding the limitations of manually setting the neighborhood radius and the minimum number of cluster points, being applicable to parameters of different data sets, and improving generalization. At the same time, the neighborhood radius is calculated by the k-nearest neighbor algorithm and the minimum number of cluster points is determined by the number of nearest neighbors, thereby improving the processing capability of high-dimensional data. Abnormal data point detection is performed based on the cluster center distance and the mean of the cluster center distance, thereby reducing the impact of the density-based clustering algorithm on the sensitivity of noise data, improving the accuracy of abnormal detection of stream data, and enabling abnormal detection of stream data to achieve a more ideal effect.

[0077] A computer-readable storage medium provided in an embodiment of the present invention stores a computer program on the computer-readable storage medium, and when the program is executed by a processor, the abnormality detection method of the stream data of any one of the above embodiments is implemented. Wherein, the computer-readable storage medium includes but is not limited to any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (EraSable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card. That is, the storage device includes any medium that can store or transmit information in a readable form by a device (for example, a computer, a mobile phone), which can be a read-only memory, a disk or an optical disk, etc.

[0078] In addition, the above describes in detail a method, system and storage medium for detecting anomalies in streaming data provided by an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for detecting anomalies in streaming data, characterized in that: The method comprises: Acquire stream data, set a sliding window, and perform window segmentation on the stream data based on the sliding window to obtain segmented window data; Clustering the segmented window data using a density-based clustering algorithm to obtain a clustering result; Based on the clustering result, a number of clusters and discrete points are distinguished, the cluster center means of the clusters are calculated, and the cluster center distance from each discrete point to the cluster center mean is calculated; The mean of the cluster center distances is calculated based on the cluster center distances from each discrete point to the cluster center mean, and abnormal data point detection is performed based on the cluster center distances and the mean of the cluster center distances.

2. The method for detecting anomalies in streaming data according to claim 1, characterized in that: The obtaining of stream data comprises: The number of streaming data points in the streaming data source that enter the sliding window is set, and streaming data is obtained from the streaming data source based on the number of streaming data points.

3. The method for detecting anomalies in streaming data according to claim 1, characterized in that: The window segmenting the stream data based on the sliding window to obtain segmented window data includes: Setting a window size and a sliding step of the sliding window, and sliding the sliding window on the stream data based on the sliding step; When the sliding window is slid on the stream data, the stream data is segmented into windows based on the window size to obtain segmented window data.

4. The method for detecting anomalies in streaming data according to claim 1, characterized in that: The clustering of the segmented window data using a density-based clustering algorithm to obtain a clustering result includes: The neighborhood radius is calculated based on the k-nearest neighbor algorithm, and the minimum number of points in the cluster is determined based on the number of nearest neighbors; Determining the core point of the segmented window data based on the neighborhood radius and the minimum number of points of the cluster; Based on the core point, the neighborhood radius and the minimum number of points of the cluster are used to perform data point expansion to obtain a clustering cluster.

5. The method for detecting anomalies in streaming data according to claim 4, characterized in that: The calculating of the neighborhood radius based on the k-nearest neighbor algorithm includes: Calculating the distance between the data points of the segmented window data, performing neighbor attribution division based on the distance between the data points, and obtaining a number of neighbor attributions; Based on the majority voting rule, a number of neighbor affiliations are classified and decided to obtain the target neighbor affiliation; A neighborhood radius is determined based on the target neighbor affiliation.

6. The method for detecting anomalies in streaming data according to claim 1, characterized in that: The distinguishing a number of clusters and discrete points based on the clustering result includes: Determine the cluster center of each cluster based on the clustering result, and calculate the relative distance between each data point and the cluster center; The relative distance is compared with a preset distance threshold, and if the relative distance is greater than the preset distance threshold, the corresponding data point is determined to be a discrete point.

7. The method for detecting anomalies in streaming data according to claim 1, characterized in that: The distinguishing a number of clusters and discrete points based on the clustering result includes: After distinguishing a number of clusters and discrete points, the discrete points are combined with the stream data in the next sliding window to generate new segmented window data, and the new segmented window data is re-clustered.

8. The method for detecting anomalies in streaming data according to claim 1, characterized in that: The abnormal data point detection based on the cluster center distance and the cluster center distance mean includes: The cluster center distance is compared with the mean of the cluster center distances. If the cluster center distance is greater than the mean of the cluster center distances, the discrete point corresponding to the cluster center distance is taken as an abnormal data point.

9. A streaming data anomaly detection system, characterized in that: The system comprises: Sliding window segmentation module: used to obtain stream data, set a sliding window, and perform window segmentation on the stream data based on the sliding window to obtain segmented window data; Clustering module: used to cluster the segmented window data using a density-based clustering algorithm to obtain a clustering result; Cluster center parameter calculation module: used to distinguish a number of clusters and discrete points based on the clustering results, calculate the cluster center mean of the cluster, and calculate the cluster center distance from each discrete point to the cluster center mean; Anomaly detection module: used to calculate the mean of cluster center distances based on the cluster center distances from each discrete point to the cluster center mean, and perform abnormal data point detection based on the cluster center distances and the mean of cluster center distances.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method for detecting abnormalities in streaming data according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data flow abnormality detection and multiple verification method based on enhancement-type angle abnormality factor

    CN107682319A

  • Abnormal data detection method and device

    CN109766393A

  • Cloud monitoring stream data detection method and device based on clustering analysis and storage medium

    CN115454779A

  • Abnormality detection optimization method and related equipment

    CN116127344A

  • Density-based text clustering method and apparatus, device, and storage medium

    WO2022126971A1

Cited By

  • Sputtering film pressure sensor anomaly detection method and system based on classification model

    CN121211190A