A clustering method and device for time series data
By optimizing the clustering method through prediction models and objective functions, the problem of imbalanced clustering partitions in time series data was solved, resulting in more accurate and balanced clustering results and enhancing the discriminative power between time series data.
Patent Information
- Application Number
- CN202211231770.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2042-09-30
AI Technical Summary
Existing time-series data clustering methods lack specificity, resulting in poor cluster partition balance, an excessive or insufficient number of feature vectors, and large errors in the clustering results.
A predictive model is used to train cluster partitions. The first objective function ensures that the difference in the number of samples in each cluster partition is less than a threshold. The discriminator and encoder are used to optimize the clustering process. Multiple objective functions are used to tune parameters to improve the balance and accuracy of clustering.
It improves the accuracy and balance of time series data clustering, enhances the distinguishability of different categories of time series data, and ensures that the clustering results are reasonable and balanced.
Smart Images

Figure CN115495631B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, apparatus, computing device and computer-readable storage medium for clustering time-series data. Background Technology
[0002] With the development of computer technology, more and more technologies are being applied in the financial field. The traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, higher demands are being placed on technology.
[0003] Time series data refers to data generated over a period of time, and it originates from all aspects of social production and life. For example, time series data can be formed based on changes in a user's transaction volume over a period of time; it can be formed based on changes in a server's performance metric over a period of time; it can be formed based on changes in the network traffic consumed by an application over a period of time, and so on.
[0004] Clustering time-series data is of great significance in the analysis and mining of time-series data. Current methods for clustering time-series data involve extracting features from each data point to obtain a feature vector. These feature vectors are then clustered using conventional clustering methods to create multiple cluster partitions, each with a corresponding cluster center. Common clustering methods include K-means clustering and the maximum-minimum distance clustering algorithm. For the time-series data to be clustered, the distance between the extracted feature vector and the previously obtained cluster centers is calculated. The magnitude of this distance determines which cluster partition the data point should belong to.
[0005] The clustering methods mentioned above lack specificity, have low distinguishability between time series data, and are prone to poor balance among multiple cluster partitions, or too many or too few feature vectors in a certain cluster partition, resulting in a large error in the final clustering result. Summary of the Invention
[0006] This invention provides a clustering method for time-series data to improve the balance and accuracy of clustering.
[0007] In a first aspect, embodiments of the present invention provide a clustering method for time-series data, comprising:
[0008] Obtain any time series data to be clustered;
[0009] The time series data to be clustered is input into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions respectively; the k clustering partitions are obtained by training the prediction model with at least a first objective function as the objective and using sample time series data; the first objective function is used to ensure that the difference in the number of sample time series data in any two clustering partitions is less than a first preset threshold.
[0010] The clustering partition corresponding to the probability value that meets the preset conditions among the k probability values is determined as the clustering partition to which the time series data to be clustered belongs.
[0011] The prediction model is trained based on a first objective function. This first objective function ensures that the difference in the number of sample time-series data in any two cluster partitions is less than a first preset threshold. This trained prediction model can more accurately distinguish between different categories of time-series data, avoiding situations where the number of feature vectors in a particular cluster partition is too high or too low, thus ensuring the balance and rationality of the clustering results and improving clustering accuracy. Subsequently, the time-series data to be clustered is input into the prediction model trained with at least the first objective function as the objective. This allows for more reasonable and balanced clustering, reflecting the differences between different time-series data, improving the discriminability between time-series data, and enhancing clustering accuracy.
[0012] In some embodiments, the prediction model includes at least a discriminator;
[0013] The prediction model is trained in the following manner:
[0014] Clustering is performed on multiple first-sample time-series data to obtain k initial cluster partitions;
[0015] For any second sample time series data, the second sample time series data is input into the initial discriminator to obtain k discrimination probabilities that the second sample time series data belongs to the k initial clustering partitions; with at least the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities to obtain an updated discriminator, and the initial discriminator is updated to the updated discriminator;
[0016] The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities;
[0017] The initial clustering partition to which the second sample time series data belongs is updated based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs; the initial clustering partition is updated to the updated clustering partition, and the step of inputting the second sample time series data into the discriminator for any second sample time series data is returned until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function.
[0018] First, k initial clustering partitions are obtained. Then, the initial clustering partitions are optimized and corrected using second sample time-series data to obtain updated clustering partitions. Specifically, the initial discriminator predicts k discrimination probabilities of the second sample time-series data belonging to the k initial clustering partitions. Based on these k discrimination probabilities, the initial discriminator is tuned to obtain an updated discriminator. This ensures that the difference in the number of sample time-series data in any two clustering partitions is less than a first preset threshold, guaranteeing the balance and rationality of the clustering results and improving the distinguishability of different time-series data. Through continuous optimization and correction, all k initial clustering partitions are eventually updated to updated clustering partitions. Compared to the initial clustering partitions, the updated clustering partitions better guarantee the balance and rationality of clustering and improve the accuracy of clustering.
[0019] In some embodiments, after obtaining k initial clustering partitions, the method further includes:
[0020] Calculate the k distances between the second sample time series data and the initial cluster centers of the k initial cluster partitions, and determine the k calculated probabilities that the second sample time series data belongs to the k initial cluster partitions based on the k distances;
[0021] At least with the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities, including:
[0022] With the first objective function and the second objective function as the objectives, the initial discriminator is tuned according to the k discrimination probabilities; the second objective function is used to ensure that the difference between the calculated probability and the discrimination probability of the second sample time series data for the same initial cluster partition is less than a second preset threshold.
[0023] Determining the initial clustering partition to which the second sample time series data belongs based on the k discriminant probabilities includes:
[0024] The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities and the k calculated probabilities.
[0025] By adjusting the discriminator parameters using a second objective function, the difference between the calculated probability and the discriminant probability of the second sample time-series data for any initial cluster partition is made less than a second preset threshold. This ensures the discriminant probability is as close as possible to the calculated probability, further optimizing the discriminator. The resulting discriminant probability is both close to the calculated probability and takes into account the balance of time-series data across cluster partitions, thus improving clustering accuracy.
[0026] In some embodiments, before inputting the second sample time series data into the discriminator for any second sample time series data, the method further includes:
[0027] Multiple sub-sample time series data are extracted from the third sample time series data, and the sub-sample time series data are the second sample time series data;
[0028] The initial clustering partition to which the second sample time series data belongs is updated based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs, including:
[0029] The initial clustering partition to which the third sample time series data belongs is determined based on the initial clustering partitions to which multiple second sample time series data belong;
[0030] The initial clustering partition to which the third sample time series data belongs is updated based on the third sample time series data to obtain the updated clustering partition to which the third sample time series data belongs.
[0031] By truncating the third sample time series data, multiple second sample time series data are obtained. Thus, the discriminator calculates the discrimination probability for each second sample time series data. Training the discriminator using the second objective function also ensures that the discrimination probabilities of each second sample time series data within the third sample time series data are relatively similar, guaranteeing that the discrimination probabilities of different subsequences within the same sequence tend to be consistent. This improves the accuracy of determining the initial cluster partition to which the third sample time series data belongs.
[0032] In some embodiments, the prediction model further includes an encoder;
[0033] For any second sample time series data, the second sample time series data is input into the initial discriminator, including:
[0034] For any second sample time series data, the second sample time series data is input into the encoder for encoding to obtain the encoded second sample time series data;
[0035] The encoded second sample time series data is input into the initial discriminator;
[0036] The method further includes:
[0037] The encoded second sample time-series data is input into the decoder to obtain the decoding result;
[0038] Using the first objective function, the second objective function, and the third objective function as objectives, the encoder is tuned according to the k discrimination probabilities; the third objective function is used to ensure that the distance between the decoding result and the second sample time-series data is less than a fourth preset threshold.
[0039] At least with the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities, including:
[0040] Using the first objective function, the second objective function, and the third objective function as objectives, the initial discriminator is tuned according to the k discrimination probabilities.
[0041] The prediction model also includes an encoder and a decoder. The parameters of the encoder and decoder are trained based on a first objective function, a second objective function, and a third objective function. The third objective function aims to ensure that the distance between the decoded result and the unencoded sample time-series data is less than a fourth preset threshold. In other words, the third objective function ensures that the encoding result does not lose as much information as possible from the original time-series data, extracting richer features and improving the accuracy of the clustering results. Furthermore, since the parameters of the discriminator are trained based on the first, second, and third objective functions, the discriminator parameters are further optimized. The resulting discriminator, encoder, and decoder can extract richer features while retaining more information, with the discriminator's discrimination probability and computational probability being as close as possible, resulting in a more balanced and reasonable clustering result.
[0042] In some embodiments, the first objective function is determined in the following manner:
[0043] For any second sample time series data, after determining the initial clustering partition to which the second sample time series data belongs, the k data frequencies corresponding to the k initial clustering partitions are updated according to the attenuation coefficient; the data frequency is used to characterize the number of second sample time series data in any clustering partition; the attenuation coefficient is used to characterize the magnitude of the change in the data frequency;
[0044] For the next second sample time series data of the second sample time series data, obtain the k data frequencies, and determine the first objective function based on the k data frequencies and the k discrimination probabilities corresponding to the next second sample time series data.
[0045] In some embodiments, the second objective function is determined in the following manner:
[0046] For any initial clustering partition, calculate the discrimination probability and the variance of the calculated probability corresponding to multiple second sample time series data, and use the variance as the second objective function.
[0047] Secondly, embodiments of the present invention also provide a clustering apparatus for time-series data, comprising:
[0048] The acquisition unit is used to acquire any time series data to be clustered.
[0049] Processing unit, used for:
[0050] The time series data to be clustered is input into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions respectively; the k clustering partitions are obtained by training the prediction model with at least a first objective function as the objective and using sample time series data; the first objective function is used to ensure that the difference in the number of sample time series data in any two clustering partitions is less than a first preset threshold.
[0051] The clustering partition corresponding to the probability value that meets the preset conditions among the k probability values is determined as the clustering partition to which the time series data to be clustered belongs.
[0052] In some embodiments, the prediction model includes at least a discriminator;
[0053] The processing unit is specifically used for:
[0054] Clustering is performed on multiple first-sample time-series data to obtain k initial cluster partitions;
[0055] For any second sample time series data, the second sample time series data is input into the initial discriminator to obtain k discrimination probabilities that the second sample time series data belongs to the k initial clustering partitions; with at least the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities to obtain an updated discriminator, and the initial discriminator is updated to the updated discriminator;
[0056] The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities;
[0057] The initial clustering partition to which the second sample time series data belongs is updated based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs; the initial clustering partition is updated to the updated clustering partition, and the step of inputting the second sample time series data into the discriminator for any second sample time series data is returned until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function.
[0058] In some embodiments, the processing unit is further configured to:
[0059] Calculate the k distances between the second sample time series data and the initial cluster centers of the k initial cluster partitions, and determine the k calculated probabilities that the second sample time series data belongs to the k initial cluster partitions based on the k distances;
[0060] The processing unit is specifically used for:
[0061] With the first objective function and the second objective function as the objectives, the initial discriminator is tuned according to the k discrimination probabilities; the second objective function is used to ensure that the difference between the calculated probability and the discrimination probability of the second sample time series data for the same initial cluster partition is less than a second preset threshold.
[0062] The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities and the k calculated probabilities.
[0063] In some embodiments, the processing unit is further configured to:
[0064] Multiple sub-sample time series data are extracted from the third sample time series data, and the sub-sample time series data are the second sample time series data;
[0065] The processing unit is specifically used for:
[0066] The initial clustering partition to which the third sample time series data belongs is determined based on the initial clustering partitions to which multiple second sample time series data belong;
[0067] The initial clustering partition to which the third sample time series data belongs is updated based on the third sample time series data to obtain the updated clustering partition to which the third sample time series data belongs.
[0068] In some embodiments, the prediction model further includes an encoder;
[0069] The processing unit is specifically used for:
[0070] For any second sample time series data, the second sample time series data is input into the encoder for encoding to obtain the encoded second sample time series data;
[0071] The encoded second sample time series data is input into the initial discriminator;
[0072] The processing unit is also used for:
[0073] The encoded second sample time-series data is input into the decoder to obtain the decoding result;
[0074] Using the first objective function, the second objective function, and the third objective function as objectives, the encoder is tuned according to the k discrimination probabilities; the third objective function is used to ensure that the distance between the decoding result and the second sample time-series data is less than a fourth preset threshold.
[0075] The processing unit is specifically used for:
[0076] Using the first objective function, the second objective function, and the third objective function as objectives, the initial discriminator is tuned according to the k discrimination probabilities.
[0077] In some embodiments, the first objective function is determined in the following manner:
[0078] For any second sample time series data, after determining the initial clustering partition to which the second sample time series data belongs, the k data frequencies corresponding to the k initial clustering partitions are updated according to the attenuation coefficient; the data frequency is used to characterize the number of second sample time series data in any clustering partition; the attenuation coefficient is used to characterize the magnitude of the change in the data frequency;
[0079] For the next second sample time series data of the second sample time series data, obtain the k data frequencies, and determine the first objective function based on the k data frequencies and the k discrimination probabilities corresponding to the next second sample time series data.
[0080] In some embodiments, the second objective function is determined in the following manner:
[0081] For any initial clustering partition, calculate the discrimination probability and the variance of the calculated probability corresponding to multiple second sample time series data, and use the variance as the second objective function.
[0082] Thirdly, embodiments of the present invention also provide a computing device, comprising:
[0083] Memory, used to store computer programs;
[0084] The processor is configured to invoke a computer program stored in the memory and execute the clustering method for time-series data listed in any of the above methods according to the obtained program.
[0085] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer-executable program, the computer-executable program being used to cause a computer to perform a clustering method for time-series data listed in any of the above methods. Attached Figure Description
[0086] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0087] Figure 1 A schematic diagram of a system architecture provided for an embodiment of the present invention;
[0088] Figure 2 A flowchart illustrating a clustering method for time-series data provided in an embodiment of the present invention;
[0089] Figure 3a A schematic diagram of a prediction model provided in an embodiment of the present invention;
[0090] Figure 3b A flowchart illustrating a clustering method for time-series data provided in an embodiment of the present invention;
[0091] Figure 4 A schematic diagram of a prediction model provided in an embodiment of the present invention;
[0092] Figure 5 A flowchart illustrating a clustering method for time-series data provided in an embodiment of the present invention;
[0093] Figure 6 A flowchart illustrating a clustering method for time-series data provided in an embodiment of the present invention;
[0094] Figure 7 This is a schematic diagram of the structure of a time-series data clustering device provided in an embodiment of the present invention;
[0095] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0096] To make the objectives, implementation methods and advantages of this application clearer, the exemplary implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments of this application. Obviously, the described exemplary embodiments are only some embodiments of this application, and not all embodiments.
[0097] Based on the exemplary embodiments described in this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the appended claims. Furthermore, although the disclosures in this application are presented by way of one or more exemplary examples, it should be understood that each aspect of these disclosures can also constitute a complete implementation on its own.
[0098] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0099] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities and do not necessarily imply a specific order or sequence, unless otherwise indicated. It should be understood that such terms can be used interchangeably where appropriate, for example, to implement the application in a sequence other than those given in the embodiments illustrated or described herein.
[0100] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclusively include, for example, a product or device that includes a series of components is not necessarily limited to those that are explicitly listed, but may include other components that are not explicitly listed or that are inherent to such product or device.
[0101] To more clearly describe this application, the following explanations are provided for the terms used:
[0102] 1. Unsupervised refers to training and obtaining the final model based on data samples with unknown categories (unlabeled).
[0103] 2. Clustering refers to dividing a set of input data into multiple categories based on the similarity between the data, with each category containing similar data.
[0104] Figure 1 An exemplary system architecture applicable to an embodiment of the present invention is shown. This system architecture can be a server 100, including a processor 110, a communication interface 120, and a memory 130. This system architecture can be used to execute clustering methods for time-series data.
[0105] The communication interface 120 is used to communicate with the terminal device, send and receive information transmitted by the terminal device, and realize communication.
[0106] The processor 110 is the control center of the server 100, connecting various parts of the server 100 through various interfaces and routes. It performs various functions of the server 100 and processes data by running or executing software programs and / or modules stored in the memory 130 and calling data stored in the memory 130. In some embodiments, the processor 110 may include one or more processing units.
[0107] The memory 130 can be used to store software programs and modules. The processor 110 executes various functional applications and data processing by running the software programs and modules stored in the memory 130. The memory 130 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created according to business processing, etc. In addition, the memory 130 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0108] It should be noted that the above Figure 1 The structure shown is merely an example, and the embodiments of the present invention are not limited thereto.
[0109] Figure 1 The servers in the system can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0110] Figure 2 This invention illustrates a clustering method for time-series data, comprising:
[0111] Step 201: Obtain any time series data to be clustered;
[0112] Step 202: Input the time series data to be clustered into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions respectively; the k clustering partitions are obtained by training the prediction model with at least a first objective function as the objective and using sample time series data; the first objective function is used to ensure that the difference in the number of sample time series data in any two clustering partitions is less than a first preset threshold.
[0113] Step 203: Determine the clustering partition corresponding to the probability value that satisfies the preset conditions among the k probability values as the clustering partition to which the time series data to be clustered belongs.
[0114] In the clustering method provided in this embodiment of the invention, a prediction model is first trained using a subset of sample time-series data to obtain k clustering partitions, each with a corresponding cluster center. Then, the time-series data to be clustered is input into the prediction model, which outputs k probability values indicating which of the data belongs to each of the k clustering partitions. The clustering partition corresponding to the probability value that satisfies a preset condition is selected from these k probability values as the clustering partition to which the data belongs. This process enables the clustering of the time-series data.
[0115] The above steps are described in detail below.
[0116] In step 201, any time series data to be clustered is obtained.
[0117] The time series data to be clustered can originate from user input or from sample time series data in a sample library; this embodiment of the invention does not impose any limitations on this. For example, if a prediction model is trained using a portion of the sample time series data from the sample library, the remaining sample time series data can be used as the time series data to be clustered and input into the prediction model, thus allowing all sample time series data in the sample library to be clustered. For instance, after training the prediction model using sample time series data from the sample library, the user inputs the time series data to be clustered through a client; the system obtains the user-inputted time series data and inputs it into the prediction model, thereby obtaining the category to which the time series data to be clustered belongs.
[0118] In step 202, the time series data to be clustered is input into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions.
[0119] The prediction model is trained using sample time-series data to obtain k cluster partitions, each with a corresponding cluster center. The cluster center of each partition is determined by the time-series data within that partition; for example, the cluster center can be the mean, median, or mode of the time-series data within that partition.
[0120] The prediction model is trained using sample time-series data, with at least a first objective function as the objective. The first objective function aims to ensure that the difference in the number of sample time-series data points between any two clusters in the k clustering partitions is less than a first preset threshold. This training results in a more balanced and reasonable number of time-series data points in each of the k clustering partitions, preventing situations where some clusters contain too much or too little time-series data, or where the time-series data lacks discriminatory power.
[0121] By inputting the time series data to be clustered into a prediction model trained with at least the first objective function as the target, more reasonable and balanced clustering can be performed, reflecting the differences between different time series data, improving the discriminative power between time series data, and improving the accuracy of clustering.
[0122] For example, by training the prediction model with sample time-series data, three cluster partitions were obtained: partition A, partition B, and partition C, with cluster centers [1, 1, 1], [2, 2, 2], and [3, 3, 3], respectively. When the time-series data to be clustered was input into the prediction model, the probabilities that the data belonged to partition A, partition B, and partition C were 0.1, 0.2, and 0.7, respectively.
[0123] In step 203, the clustering partition corresponding to the probability value that satisfies the preset conditions among the k probability values is determined as the clustering partition to which the time series data to be clustered belongs.
[0124] For example, the cluster partition corresponding to the largest probability value among k probability values is determined as the cluster partition to which the time series data to be clustered belongs. In the example above, the probability values of the time series data to be clustered belonging to cluster partition A, cluster partition B, and cluster partition C are 0.1, 0.2, and 0.7, respectively. Therefore, cluster partition C, which corresponds to 0.7, is taken as the cluster partition to which the time series data to be clustered belongs.
[0125] Once the cluster partition to which the time series data to be clustered belongs is determined, the data can be assigned to that partition, and the cluster centers of that partition can be updated based on the existing time series data and the newly added data. Alternatively, the data can simply be assigned to the partition without updating its cluster centers.
[0126] The prediction model is trained based on a first objective function. This first objective function ensures that the difference in the number of sample time-series data in any two cluster partitions is less than a first preset threshold. This trained prediction model can more accurately distinguish between different categories of time-series data, avoiding situations where the number of feature vectors in a particular cluster partition is too high or too low, thus ensuring the balance and rationality of the clustering results and improving clustering accuracy. Subsequently, the time-series data to be clustered is input into the prediction model trained with at least the first objective function as the objective. This allows for more reasonable and balanced clustering, reflecting the differences between different time-series data, improving the discriminability between time-series data, and enhancing clustering accuracy.
[0127] Figure 3a A structural diagram of a possible prediction model is shown, combined with Figure 3aThe training process of the prediction model is described in detail. The training process of the prediction model is as follows: Figure 3b As shown, it includes:
[0128] Step 301: Cluster the multiple first sample time series data to obtain k initial cluster partitions.
[0129] Step 302: For any second sample time series data, input the second sample time series data into the initial discriminator to obtain k discrimination probabilities that the second sample time series data belongs to the k initial clustering partitions; with at least the first objective function as the objective, tune the initial discriminator according to the k discrimination probabilities to obtain an updated discriminator, and update the initial discriminator to the updated discriminator.
[0130] Step 303: Determine the initial clustering partition to which the second sample time series data belongs based on the k discrimination probabilities.
[0131] Step 304: Update the initial clustering partition to which the second sample time series data belongs based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs; update the initial clustering partition to the updated clustering partition, and return to the step of inputting the second sample time series data into the discriminator for any second sample time series data, until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function.
[0132] Before step 301, the sample time series data is subjected to feature extraction by an encoder to obtain sample time series data represented by a vector. For example, a certain sample time series data represents the changes in transaction volume within a month. After feature extraction by the encoder, a d-dimensional vector [1, 2, 3, 5, 7, 10, 8, 6, 5, 5] is obtained.
[0133] The encoder used for feature extraction is a trained encoder trained as follows: Unencoded n-dimensional time-series samples are input into the encoder for encoding, resulting in encoded d-dimensional time-series samples. This encoded d-dimensional time-series samples are then input into the decoder for decoding, resulting in decoded n-dimensional time-series samples. Our goal is to minimize the loss of original information during the encoding process while extracting effective features. Therefore, a fourth objective function is designed, which calculates and minimizes the distance between the unencoded and decoded n-dimensional time-series samples. For each input unencoded n-dimensional time-series sample, encoding and decoding are performed, and the distance between the unencoded and decoded n-dimensional time-series samples is calculated. The encoder and decoder are then tuned based on this distance until the distance between the unencoded and decoded n-dimensional time-series samples is minimized, thus obtaining the trained encoder and decoder.
[0134] In some embodiments, since the dimensionality of sample time series data is generally large, encoding high-dimensional sample time series data increases computational complexity and cannot guarantee encoding accuracy. To improve encoding accuracy, we can first sample n-dimensional sample time series data to obtain multiple m-dimensional sample time series data, where m is less than n. For example, sampling 10000-dimensional sample time series data yields 10 sample time series data with a dimension of 100, and these 10 sample time series data with a dimension of 100 can have overlapping portions.
[0135] An encoder trained with m-dimensional sample time-series data will be more accurate than an encoder trained with n-dimensional sample time-series data.
[0136] When using the encoder trained with m-dimensional sample time-series data, the following method can be adopted: Sample the n-dimensional sample time-series data L times to obtain L m-dimensional sample time-series data. For convenience, these L m-dimensional sample time-series data are referred to as subsample time-series data. Input any subsample time-series data into the encoder to obtain the encoded result of that subsample time-series data.
[0137] For example, a time series data sample based on a user's transaction volume within a month might be a single time series data point of length 100,000, named x1 = [3, 8, 6, 7, 9, ..., 15, 10, 9]. Five randomly sampled sub-sample time series data points are then defined as: x11 = [1, 2, 3, 5, 7, 10, 8, 6, 5, 5], x12 = [7, 7, 6, 2, 4, 2, 2, 3, 5, 5], ..., x15 = [4, 5, 8, 7, 10, 12, 15, 13, 11, 10]. Inputting any sub-sample time series data point into the encoder yields five 5-dimensional encoded sample time series data points: a11 = [4, 2, 0.1, 0.5, -0.2], a12 = [3, 5, -1, 0, 0.3], ..., a15 = [4, 6, 1, 2, -1].
[0138] In step 301, multiple first sample time series data are clustered to obtain k initial cluster partitions.
[0139] The first sample time series data here can be any sample time series data in the sample library. Two methods are provided here to cluster multiple first sample time series data to obtain initial cluster partitions.
[0140] Method 1: The first sample time series data consists of unsampled, complete n-dimensional sample time series data. If there are N first sample time series data points, the vectors obtained after encoding these N first sample time series data points are directly clustered to obtain k initial cluster partitions, each with a cluster center. The clustering method used here can be any clustering method well-known to those skilled in the art, such as k-means clustering, density-based clustering, etc.
[0141] Method 2: The first sample time series data is the sampled m-dimensional sample time series data, i.e., the subsample time series data. For any n-dimensional sample time series data, the average of the vectors of its corresponding L subsample time series data is taken to obtain the vector of the n-dimensional sample time series data. Then, the N n-dimensional sample time series data are clustered to obtain k initial cluster partitions, each with a cluster center. The clustering method used here can be any clustering method well known to those skilled in the art, such as k-means clustering, density-based clustering, etc.
[0142] For example, after clustering, three initial cluster partitions are obtained: cluster partition A, cluster partition B, and cluster partition C. The number of n-dimensional sample time series data in the three cluster partitions are 63589, 32215, and 29196, respectively. It can be seen that the distribution of the number of n-dimensional sample time series data in different cluster partitions is uneven, with cluster partition A having too much sample time series data, resulting in poor discrimination between different time series data.
[0143] In step 302, for any second sample time series data, the second sample time series data is input into the initial discriminator to obtain k discrimination probabilities that the second sample time series data belongs to the k initial clustering partitions; at least with the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities to obtain an updated discriminator, and the initial discriminator is updated to the updated discriminator.
[0144] The second sample time series data here comes from the sample library and can be the same as or different from the first sample time series data. This embodiment of the invention does not impose any restrictions on this.
[0145] One possible scenario is that the second sample time series data is a complete n-dimensional sample time series data. The second sample time series data is input into the initial discriminator, which is a discriminator that has not yet been trained. This yields k discrimination probabilities that the second sample time series data belongs to k initial cluster partitions. Since the parameters of the initial discriminator are not yet perfect, it is necessary to tune the initial discriminator based on the k discrimination probabilities, at least with the first objective function as the objective, to obtain an updated discriminator. This updates the initial discriminator to the updated discriminator. In other words, for the next input second sample time series data, the data is input into the updated discriminator, and the updated discriminator is tuned, and so on.
[0146] Another possible scenario is that the second sample time series data is m-dimensional sample time series data. That is, the second sample time series data is subsample time series data, which is one of the L subsample time series data obtained by sampling from the complete n-dimensional sample time series data—the third sample time series data.
[0147] In step 303, the initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities.
[0148] In one possible scenario, the second sample time series data is a complete n-dimensional sample time series data. Then, k discriminant probabilities are used to characterize the k probabilities that this n-dimensional sample time series data belongs to k initial cluster partitions. The initial cluster partition corresponding to the maximum value among the k discriminant probabilities is taken as the initial cluster partition to which the second sample time series data belongs. For example, if the second sample time series data is 100,000-dimensional sample time series data, and the three initial cluster partitions have three discriminant probabilities of 0.1, 0.2, and 0.7 respectively, then the retrieval partition C corresponding to 0 and 7 is taken as the initial cluster partition to which the second sample time series data belongs.
[0149] Another possible scenario is that the second sample time series data is m-dimensional sample time series data. That is, the second sample time series data is a sub-sample time series data, which is one of L sub-sample time series data obtained by sampling from the complete n-dimensional sample time series data—the third sample time series data. Then, the cluster partition of the third sample time series data is determined according to the cluster partition to which each second sample time series data belongs. For example, if a certain third sample time series contains 4 sub-sample time series data, and the initial cluster partitions to which the 4 sub-sample time series data belong are cluster partition A, cluster partition A, cluster partition A, and cluster partition B, then the mode cluster partition A of the initial cluster partitions to which the 4 sub-sample time series data belong is taken as the initial cluster partition to which the third sample time series data belongs.
[0150] In step 304, the initial clustering partition to which the second sample time series data belongs is updated according to the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs; the initial clustering partition is updated to the updated clustering partition, and the step of inputting the second sample time series data into the discriminator for any second sample time series data is returned until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function.
[0151] One possible scenario is that the second sample time series data is a complete n-dimensional sample time series data. The initial cluster partition to which the second sample time series data belongs is updated based on this data, resulting in an updated cluster partition. For example, if the initial cluster partition to which the second sample time series data belongs is cluster partition A, and the cluster centers of cluster partition A are [1, 1, 1], after adding the second sample time series data to cluster partition A, the cluster centers of cluster partition A will be updated. The average value of all sample time series data in cluster partition A after adding the second sample time series data is taken as the updated cluster center of cluster partition A.
[0152] The initial clustering partitions in step 302 are updated to updated clustering partitions. The next second sample time series data is selected, and the process returns to step 302. That is, the next second sample time series data is input into the updated discriminator to obtain k discrimination probabilities that the next second sample time series data belongs to the k initial clustering partitions. The parameters of the updated discriminator are adjusted again based on the k discrimination probabilities, and the clustering partitions are updated again. This continues until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function. Then, no more second sample time series data is input, and the discriminator training is complete.
[0153] First, k initial clustering partitions are obtained. Then, the initial clustering partitions are optimized and corrected using second sample time-series data to obtain updated clustering partitions. Specifically, the initial discriminator predicts k discrimination probabilities of the second sample time-series data belonging to the k initial clustering partitions. Based on these k discrimination probabilities, the initial discriminator is tuned to obtain an updated discriminator. This ensures that the difference in the number of sample time-series data in any two clustering partitions is less than a first preset threshold, guaranteeing the balance and rationality of the clustering results and improving the distinguishability of different time-series data. Through continuous optimization and correction, all k initial clustering partitions are eventually updated to updated clustering partitions. Compared to the initial clustering partitions, the updated clustering partitions better guarantee the balance and rationality of clustering and improve the accuracy of clustering.
[0154] Another possible scenario is that the second sample time series data is m-dimensional sample time series data. That is, the second sample time series data is a sub-sample time series data, which is one of L sub-sample time series data obtained by sampling from the complete n-dimensional sample time series data—the third sample time series data. Then, based on the initial cluster partitions to which the multiple second sample time series data belong, the initial cluster partition to which the third sample time series data belongs is determined; the initial cluster partition to which the third sample time series data belongs is updated based on the third sample time series data to obtain the updated cluster partition to which the third sample time series data belongs.
[0155] For example, in step 303, after determining the initial clustering partition to which the third sample time series data belongs based on the second sample time series data, the third sample time series data is added to that initial clustering partition. The initial clustering partition to which the third sample time series data belongs is then updated based on the third sample time series data to obtain the updated clustering partition to which the third sample time series data belongs. The method for updating cluster centers has been described previously and will not be repeated here.
[0156] In some embodiments, the discriminator is trained not only through a first objective function but also through a second objective function. The parameters of the discriminator are further optimized and corrected using statistical methods.
[0157] Therefore, the method provided in this embodiment of the invention further includes: calculating k distances between the second sample time series data and the initial cluster centers of the k initial clustering partitions, and determining k calculated probabilities that the second sample time series data belongs to the k initial clustering partitions respectively based on the k distances. Then, the initial discriminator is tuned according to the k discriminant probabilities, including: using the first objective function and the second objective function as objectives, and tuning the initial discriminator according to the k discriminant probabilities; the second objective function is used to ensure that the difference between the calculated probability and the discriminant probability of the second sample time series data for the same initial clustering partition is less than a second preset threshold.
[0158] For example, the probability pi of the second sample time series data belonging to the i-th clustering partition among the k initial clustering partitions is calculated using the following formula:
[0159] pi=(1+||a-ui|| 2 ) -1 / Σi((1+||a-ui|| 2 ) -1 )
[0160] a represents the second sample time series data, and ui represents the cluster center of the i-th initial cluster partition.
[0161] For example, the encoding result of the second sample time series data is a = [4,4,3,2,1], and the three cluster centers are u1 = [1,2,5,3,2], u2 = [-5,-7,0,1,4], and u3 = [4,6,-4,-2,-6]; the probability that a belongs to category 1 is: p1 = (1 + ||[4,4,3,2,1] - [1,2,5,3,2]|| 2 ) -1 / [(1+||[4,4,3,2,1]-[1,2,5,3,2]|| 2 ) -1 +(1+||[4,4,3,2,1]-[-5,-7,0,1,4]|| 2 ) -1 +(1+||[4,4,3,2,1]-[4,6,-4,-2,-6]|| 2 )^ -1 =0.05 / [0.05+0.0045+0.0084] =0.79.
[0162] Following the above method, three calculated probabilities were obtained for the second sample time series data to belong to the three initial clustering partitions.
[0163] The initial discriminator is tuned based on k discrimination probabilities, with the first and second objective functions as the objectives. The second objective function aims to ensure that the difference between the calculated probability and the discrimination probability of the second sample time series data for the same initial cluster partition is less than a second preset threshold. For example, the discriminator outputs discrimination probabilities q1, q2, and q3 for the second sample time series data. These three probabilities correspond to three initial cluster partitions, i.e., the discrimination probability of the second sample time series data belonging to cluster partition A is q1, the discrimination probability of belonging to cluster partition B is q2, and the discrimination probability of belonging to cluster partition C is q3. Statistically, the calculated probability of the second sample time series data belonging to cluster partition A is p1, the calculated probability of belonging to cluster partition B is p2, and the calculated probability of belonging to cluster partition C is p3. The second objective function is that the difference between q1 and p1 is less than the second preset threshold, the difference between q2 and p2 is less than the second preset threshold, and the difference between q3 and p3 is less than the second preset threshold.
[0164] If probability calculations are involved, both calculated probabilities and discriminant probabilities can be considered when determining the initial cluster partition to which the second sample time series data belongs. Determining the initial cluster partition to which the second sample time series data belongs based on the k discriminant probabilities includes: determining the initial cluster partition to which the second sample time series data belongs based on the k discriminant probabilities and the k calculated probabilities.
[0165] For example, the total probability q' corresponding to any initial cluster partition can be calculated using the following formula:
[0166] q' = [p(st-t) + q] / st;
[0167] Where q is the discrimination probability, p is the calculated probability, t is the group number of the current second sample time series data, and st is the total number of groups of all second sample time series data. For example, if the second sample time series data in the sample library is divided into 10 groups, with 20 second sample time series data in each group, then for each second sample time series data in the first group, q' = [p(10-1) + q] / 10; for each second sample time series data in the second group, q' = [p(10-2) + q] / 10... It can be seen that as the number of training samples increases, the proportion of the discrimination probability in the total probability increases, while the proportion of the calculated probability decreases, and the total probability gradually becomes dominated by the discrimination probability of the discriminator.
[0168] The total probabilities q1', q2', and q3' of the three initial cluster partitions are calculated using the above formula. The initial cluster partition corresponding to the maximum value of the three total probabilities is then taken as the initial cluster partition to which the second sample time series data belongs.
[0169] By adjusting the discriminator parameters using a second objective function, the difference between the calculated probability and the discriminant probability of the second sample time-series data for any initial cluster partition is made less than a second preset threshold. This ensures the discriminant probability is as close as possible to the calculated probability, further optimizing the discriminator. The resulting discriminant probability is both close to the calculated probability and takes into account the balance of time-series data across cluster partitions, thus improving clustering accuracy.
[0170] In some embodiments, the prediction model further includes an encoder. Figure 4 A schematic diagram of a possible prediction model is shown. Therefore, for any second sample time series data, the second sample time series data is input into the initial discriminator, including: for any second sample time series data, the second sample time series data is first input into the encoder for encoding to obtain the encoded second sample time series data, and the encoded second sample time series data is input into the initial discriminator.
[0171] Furthermore, the encoder parameters are tuned based on the decoding results. The encoder and decoder used here can be untrained or trained before step 301. This embodiment of the invention does not impose any limitations on this.
[0172] The encoded second sample time-series data is input into the decoder to obtain the decoding result; the encoder is tuned according to the k discrimination probabilities with the first objective function, the second objective function and the third objective function as objectives; the third objective function is used to ensure that the distance between the decoding result and the second sample time-series data is less than a fourth preset threshold.
[0173] The method for tuning the encoder and decoder here is the same as the method described before step 301, and will not be repeated here. The overall goal is that the encoder can extract effective features without losing the original information and can better reflect the differences between different time-series data.
[0174] In some embodiments, when tuning the discriminator, the first objective function, the second objective function, and the third objective function are also used as targets, and the initial discriminator is tuned according to the k discrimination probabilities.
[0175] The prediction model also includes an encoder and a decoder. The parameters of the encoder and decoder are trained based on a first objective function, a second objective function, and a third objective function. The third objective function aims to ensure that the distance between the decoded result and the unencoded sample time-series data is less than a fourth preset threshold. In other words, the third objective function ensures that the encoding result does not lose as much information as possible from the original time-series data, extracting richer features and improving the accuracy of the clustering results. Furthermore, since the parameters of the discriminator are trained based on the first, second, and third objective functions, the discriminator parameters are further optimized. The resulting discriminator, encoder, and decoder can extract richer features while retaining more information, with the discriminator's discrimination probability and computational probability being as close as possible, resulting in a more balanced and reasonable clustering result.
[0176] In some embodiments, the first objective function is determined in the following manner, such as... Figure 5 As shown, it includes:
[0177] Step 501: For any second sample time series data, after determining the initial clustering partition to which the second sample time series data belongs, update the k data frequencies corresponding to the k initial clustering partitions according to the attenuation coefficient; the data frequency is used to characterize the number of second sample time series data in any clustering partition; the attenuation coefficient is used to characterize the magnitude of the change in the data frequency.
[0178] For example, for the second sample time series data 1, if its initial clustering partition is determined to be clustering partition A through any of the above embodiments, then the three data frequencies corresponding to the three initial clustering partitions are updated according to the attenuation coefficient. The data frequencies h corresponding to the three initial clustering partitions are obtained by the following formula:
[0179] h=h0*β+[0,0,…,1,…,0]*(1-β);
[0180] Where h0 is the data frequency obtained in the previous time, the initial value of the data frequency of the three cluster partitions is [0, 0, 0], β is the attenuation coefficient, and in [0, 0, ..., 1, ..., 0], the value of the second sample time series data 1 is 1 according to the class to which it is classified, and the value of the rest is 0. For example, in this case, the second sample time series data 1 is classified into cluster partition A, then [0, 0, ..., 1, ..., 0] should be [1, 0, 0].
[0181] Assuming the previous data frequency was [0.1, 0.2, 0.7], we calculate h = [0.1, 0.2, 0.7]β + [1, 0, 0]*(1-β). We can observe that the data frequency of cluster partition A in the resulting h increases, while the data frequencies of cluster partitions B and C decrease.
[0182] The attenuation coefficient is used to characterize the magnitude of the data frequency change. If the attenuation coefficient is small, the data frequency obtained after classifying any second sample time series data will change less compared to the previous data frequency; if the attenuation coefficient is large, the data frequency obtained after classifying any second sample time series data will change more drastically compared to the previous data frequency. Those skilled in the art can adjust the attenuation coefficient according to experience and needs.
[0183] Step 502: For the next second sample time series data of the second sample time series data, obtain the k data frequencies, and determine the first objective function based on the k data frequencies and the k discrimination probabilities corresponding to the next second sample time series data.
[0184] For example, if the next second sample time series data 2 is obtained, then k data frequencies were obtained in step 501. Based on the k discrimination probabilities and k data frequencies obtained by inputting the second sample time series data 2 into the discriminator, the first objective function is determined as follows:
[0185] M = Σ_i[qi(hi-1 / k)];
[0186] Where i ranges from 0 to the number of cluster partitions, and in this example, i ranges from 1 to 3; qi is the discrimination probability corresponding to the i-th cluster partition; hi is the data frequency corresponding to the i-th cluster partition; and k is the number of cluster partitions, and in this example, k = 3.
[0187] To minimize the first objective function, when the frequency *hi* corresponding to any cluster partition increases to a level greater than the average frequency 1 / k, the corresponding discrimination frequency *qi* should decrease; conversely, when the frequency *hi* corresponding to any cluster partition decreases to a level less than the average frequency 1 / k, the corresponding discrimination frequency *qi* should increase. By designing this penalty mechanism, overly concentrated clustering results are penalized, thus avoiding an excessive or insufficient amount of time-series data in different cluster partitions, which could lead to unbalanced and unreasonable clustering results.
[0188] To better explain the embodiments of the present invention, the process of clustering the above-mentioned time-series data will be described below in a specific implementation scenario, such as... Figure 6 As shown. Includes:
[0189] Step 601: Extract L sub-sample time series data from the sample time series data x1, which are x11, x12, x13 and x14 respectively.
[0190] Step 602: Input the aforementioned sub-sample time-series data into the encoder for encoding to obtain a11, a12, a13, and a14. Input the encoded results a11, a12, a13, and a14 into the decoder for decoding to obtain j11, j12, j13, and j14. By minimizing the distance between j11 and x11, the distance between j12 and x12, the distance between j13 and x13, and the distance between j13 and x13, the encoder and decoder are trained to obtain the trained encoder and decoder.
[0191] Step 603: Input the sub-sample time series data x21, x22, x23 and x24 extracted from the first sample time series data x2 into the trained encoder respectively to obtain the encoding results a21, a22, a23 and a24.
[0192] Step 604: The mean of multiple subsample time series data is used as the vector of the first sample time series data. The vectors of multiple first sample time series data are initially clustered to obtain 3 initial clustering partitions, and each clustering partition corresponds to a cluster center.
[0193] For example, the vector of the first sample time series data x2 is the mean of a21, a22, a23, and a24. Multiple first sample time series data are then clustered.
[0194] Step 605: For any third sample time series data x3, extract multiple second sample time series data x31, x32, x33 and x34 from the third sample time series data. The second sample time series data are subsample time series data of the third sample time series data.
[0195] Step 606: Input the second sample time series data x31, x32, x33, and x34 into the encoder to obtain a31, a32, a33, and a34 respectively; input a31, a32, a33, and a34 into the initial discriminator. For a31, obtain the three discrimination probabilities q311, q312, and q313 that the second sample time series data belongs to the three initial cluster partitions; input a31, a32, a33, and a34 into the decoder to obtain j31, j32, j33, and j34; calculate the three calculated probabilities p311, p312, and p313 that the second sample time series data is located in the three initial cluster partitions using statistical methods. Similarly, perform the same calculation for a32, a33, and a34. For a32, the discrimination probabilities q321, q322, and q323 are obtained, and the probabilities p321, p322, and p323 are calculated; for a33, the discrimination probabilities q331, q332, and q333 are obtained, and the probabilities p331, p332, and p333 are calculated; for a34, the discrimination probabilities q341, q342, and q343 are obtained, and the probabilities p341, p342, and p343 are calculated.
[0196] Step 607: Using the first objective function, the second objective function, and the third objective function as objectives, the parameters of the initial discriminator are tuned based on the discrimination probability, the calculated probability, and the decoding result to obtain the updated discriminator.
[0197] The first objective function is M1 = Σ_i[qi(hi-1 / k)]. Minimizing the first objective function can penalize overly concentrated cluster partitions. The specific implementation method has been introduced earlier and will not be repeated here.
[0198] The second objective function is the variance between the discrimination probability and the calculated probability for each second-time data point in the third-time-series data for the same cluster partition. Minimizing the variance not only makes the discrimination probability as close as possible to the calculated probability, but also makes the discriminator give as consistent a discrimination conclusion as possible for each second-time-series data point in the same third-time-series data. For example, minimizing the variances of q311, p311, q321, p321, q331, p331, q341, and p341; minimizing the variances of q312, p312, q322, p322, q332, p332, q342, and p342; and minimizing the variances of q313, p313, q323, p323, q333, p333, q343, and p343.
[0199] The third objective function is to minimize the distance between the unencoded time-series data and its corresponding decoded result. For example, the distance between x31 and j31 should be minimized, the distance between x32 and j32 should be minimized, the distance between x33 and j33 should be minimized, and the distance between x34 and j34 should be minimized. This ensures that the encoded information can still effectively represent the original information, avoiding overfitting in cluster training and losing the ability to extract actual features, thus lacking generalization ability.
[0200] Step 608: Determine the initial clustering partition to which the third time series data belongs based on the calculated probability and discrimination probability corresponding to each second sample time series data.
[0201] For example, for the second sample time series data a31, its total probability is calculated based on the calculated probability and the discriminant probability, and the initial cluster partition to which a31 belongs is determined based on the total probability; for the second sample time series data a32, its total probability is calculated based on the calculated probability and the discriminant probability, and the initial cluster partition to which a32 belongs is determined based on the total probability; for the second sample time series data a33, its total probability is calculated based on the calculated probability and the discriminant probability, and the initial cluster partition to which a33 belongs is determined based on the total probability; for the second sample time series data a34, its total probability is calculated based on the calculated probability and the discriminant probability, and the initial cluster partition to which a34 belongs is determined based on the total probability; the cluster partition to which the third sample time series data x3 belongs is determined based on the mode of the initial cluster partitions to which a31, a32, a33, and a34 belong.
[0202] Step 609: After determining the initial clustering partition to which the third sample time series data belongs, the cluster centers of the initial clustering partition are updated, and the clustering partition is updated to obtain the updated clustering partition.
[0203] Step 610: Calculate the data frequency of each updated cluster partition. This data frequency will be used when the third sample time series data is input next time.
[0204] Based on the same technological concept Figure 7 An exemplary embodiment of the present invention illustrates the structure of a time-series data clustering apparatus that can perform a time-series data clustering process.
[0205] like Figure 7 As shown, the device specifically includes:
[0206] Acquisition unit 701 is used to acquire any time series data to be clustered;
[0207] Processing unit 702 is used for:
[0208] The time series data to be clustered is input into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions respectively; the k clustering partitions are obtained by training the prediction model with at least a first objective function as the objective and using sample time series data; the first objective function is used to ensure that the difference in the number of sample time series data in any two clustering partitions is less than a first preset threshold.
[0209] The clustering partition corresponding to the probability value that meets the preset conditions among the k probability values is determined as the clustering partition to which the time series data to be clustered belongs.
[0210] In some embodiments, the prediction model includes at least a discriminator;
[0211] The processing unit 702 is specifically used for:
[0212] Clustering is performed on multiple first-sample time-series data to obtain k initial cluster partitions;
[0213] For any second sample time series data, the second sample time series data is input into the initial discriminator to obtain k discrimination probabilities that the second sample time series data belongs to the k initial clustering partitions; with at least the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities to obtain an updated discriminator, and the initial discriminator is updated to the updated discriminator;
[0214] The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities;
[0215] The initial clustering partition to which the second sample time series data belongs is updated based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs; the initial clustering partition is updated to the updated clustering partition, and the step of inputting the second sample time series data into the discriminator for any second sample time series data is returned until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function.
[0216] In some embodiments, the processing unit 702 is further configured to:
[0217] Calculate the k distances between the second sample time series data and the initial cluster centers of the k initial cluster partitions, and determine the k calculated probabilities that the second sample time series data belongs to the k initial cluster partitions based on the k distances;
[0218] The processing unit 702 is specifically used for:
[0219] With the first objective function and the second objective function as the objectives, the initial discriminator is tuned according to the k discrimination probabilities; the second objective function is used to ensure that the difference between the calculated probability and the discrimination probability of the second sample time series data for the same initial cluster partition is less than a second preset threshold.
[0220] The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities and the k calculated probabilities.
[0221] In some embodiments, the processing unit 702 is further configured to:
[0222] Multiple sub-sample time series data are extracted from the third sample time series data, and the sub-sample time series data are the second sample time series data;
[0223] The processing unit 702 is specifically used for:
[0224] The initial clustering partition to which the third sample time series data belongs is determined based on the initial clustering partitions to which multiple second sample time series data belong;
[0225] The initial clustering partition to which the third sample time series data belongs is updated based on the third sample time series data to obtain the updated clustering partition to which the third sample time series data belongs.
[0226] In some embodiments, the prediction model further includes an encoder;
[0227] The processing unit 702 is specifically used for:
[0228] For any second sample time series data, the second sample time series data is input into the encoder for encoding to obtain the encoded second sample time series data;
[0229] The encoded second sample time series data is input into the initial discriminator;
[0230] The processing unit 702 is further configured to:
[0231] The encoded second sample time-series data is input into the decoder to obtain the decoding result;
[0232] Using the first objective function, the second objective function, and the third objective function as objectives, the encoder is tuned according to the k discrimination probabilities; the third objective function is used to ensure that the distance between the decoding result and the second sample time-series data is less than a fourth preset threshold.
[0233] The processing unit 702 is specifically used for:
[0234] Using the first objective function, the second objective function, and the third objective function as objectives, the initial discriminator is tuned according to the k discrimination probabilities.
[0235] In some embodiments, the first objective function is determined in the following manner:
[0236] For any second sample time series data, after determining the initial clustering partition to which the second sample time series data belongs, the k data frequencies corresponding to the k initial clustering partitions are updated according to the attenuation coefficient; the data frequency is used to characterize the number of second sample time series data in any clustering partition; the attenuation coefficient is used to characterize the magnitude of the change in the data frequency;
[0237] For the next second sample time series data of the second sample time series data, obtain the k data frequencies, and determine the first objective function based on the k data frequencies and the k discrimination probabilities corresponding to the next second sample time series data.
[0238] In some embodiments, the second objective function is determined in the following manner:
[0239] For any initial clustering partition, calculate the discrimination probability and the variance of the calculated probability corresponding to multiple second sample time series data, and use the variance as the second objective function.
[0240] Based on the same technical concept, embodiments of this application provide a computer device, such as... Figure 8 As shown, it includes at least one processor 801 and a memory 802 connected to at least one processor. In this embodiment, the specific connection medium between the processor 801 and the memory 802 is not limited. Figure 8 Taking the connection between the processor 801 and the memory 802 via a bus as an example, the bus can be divided into address bus, data bus, control bus, etc.
[0241] In this embodiment of the application, the memory 802 stores instructions that can be executed by at least one processor 801. By executing the instructions stored in the memory 802, at least one processor 801 can perform the steps of the above-described clustering method for time-series data.
[0242] The processor 801 is the control center of the computer device, capable of connecting various parts of the computer device via various interfaces and lines. It performs time-series data clustering by running or executing instructions stored in the memory 802 and accessing data stored in the memory 802. In some embodiments, the processor 801 may include one or more processing units. The processor 801 may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may not be integrated into the processor 801. In some embodiments, the processor 801 and the memory 802 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.
[0243] The processor 801 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0244] Memory 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 802 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 802 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 802 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0245] Based on the same technical concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer-executable program, the computer-executable program being used to cause a computer to perform a method for clustering time-series data as listed in any of the above methods.
[0246] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0247] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0248] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0249] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0250] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A clustering method for time-series data, characterized in that, include: Obtain any time series data to be clustered; The time series data to be clustered is input into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions respectively; the k clustering partitions are obtained by training the prediction model with at least a first objective function as the objective and using sample time series data; the first objective function is used to ensure that the difference in the number of sample time series data in any two clustering partitions is less than a first preset threshold. The clustering partition corresponding to the probability value that meets the preset conditions among the k probability values is determined as the clustering partition to which the time series data to be clustered belongs; The prediction model is trained in the following manner: Clustering is performed on multiple first sample time-series data to obtain k initial clustering partitions; the prediction model also includes an encoder; the prediction model also includes at least a discriminator; For any second sample time series data, the second sample time series data is input into the encoder for encoding to obtain encoded second sample time series data; the encoded second sample time series data is input into the initial discriminator to obtain k discrimination probabilities of the second sample time series data belonging to the k initial clustering partitions; The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities; The encoded second sample time-series data is input into the decoder to obtain the decoding result; Using the first objective function, the second objective function, and the third objective function as objectives, the encoder is tuned according to the k discrimination probabilities; the second objective function is used to ensure that the difference between the calculated probability and the discrimination probability of the second sample time series data for the same initial cluster partition is less than a second preset threshold; the third objective function is used to ensure that the distance between the decoding result and the second sample time series data is less than a fourth preset threshold.
2. The method as described in claim 1, characterized in that, Training the prediction model in the following manner further includes: At least with the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities to obtain an updated discriminator, and the initial discriminator is updated to the updated discriminator; The initial clustering partition to which the second sample time series data belongs is updated based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs; the initial clustering partition is updated to the updated clustering partition, and the step of inputting the second sample time series data into the discriminator for any second sample time series data is returned until the k discrimination probabilities obtained by the updated discriminator satisfy the first objective function.
3. The method as described in claim 2, characterized in that, After obtaining k initial cluster partitions, the following steps are also included: Calculate the k distances between the second sample time series data and the initial cluster centers of the k initial cluster partitions, and determine the k calculated probabilities that the second sample time series data belongs to the k initial cluster partitions based on the k distances; At least with the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities, including: Using the first objective function and the second objective function as objectives, the initial discriminator is tuned according to the k discrimination probabilities; Determining the initial clustering partition to which the second sample time series data belongs based on the k discriminant probabilities includes: The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities and the k calculated probabilities.
4. The method as described in claim 3, characterized in that, Before inputting the second sample time series data into the discriminator for any given second sample time series data, the method further includes: Multiple sub-sample time series data are extracted from the third sample time series data, and the sub-sample time series data are the second sample time series data; The initial clustering partition to which the second sample time series data belongs is updated based on the second sample time series data to obtain the updated clustering partition to which the second sample time series data belongs, including: The initial clustering partition to which the third sample time series data belongs is determined based on the initial clustering partitions to which multiple second sample time series data belong; The initial clustering partition to which the third sample time series data belongs is updated based on the third sample time series data to obtain the updated clustering partition to which the third sample time series data belongs.
5. The method as described in claim 4, characterized in that, At least with the first objective function as the objective, the initial discriminator is tuned according to the k discrimination probabilities, including: Using the first objective function, the second objective function, and the third objective function as objectives, the initial discriminator is tuned according to the k discrimination probabilities.
6. The method as described in claim 5, characterized in that, The first objective function is determined in the following manner: For any second sample time series data, after determining the initial clustering partition to which the second sample time series data belongs, the k data frequencies corresponding to the k initial clustering partitions are updated according to the attenuation coefficient; the data frequency is used to characterize the number of second sample time series data in any clustering partition; the attenuation coefficient is used to characterize the magnitude of the change in the data frequency; For the next second sample time series data of the second sample time series data, obtain the k data frequencies, and determine the first objective function based on the k data frequencies and the k discrimination probabilities corresponding to the next second sample time series data.
7. The method as described in claim 5, characterized in that, The second objective function is determined as follows: For any initial clustering partition, calculate the discrimination probability and the variance of the calculated probability corresponding to multiple second sample time series data, and use the variance as the second objective function.
8. A clustering device for time-series data, characterized in that, include: The acquisition unit is used to acquire any time series data to be clustered. Processing unit, used for: The time series data to be clustered is input into the prediction model to obtain k probability values of the time series data to be clustered belonging to k clustering partitions respectively; the k clustering partitions are obtained by training the prediction model with at least a first objective function as the objective and using sample time series data; the first objective function is used to ensure that the difference in the number of sample time series data in any two clustering partitions is less than a first preset threshold. The clustering partition corresponding to the probability value that meets the preset conditions among the k probability values is determined as the clustering partition to which the time series data to be clustered belongs; Specifically, the processing unit is used for: Clustering is performed on multiple first sample time-series data to obtain k initial clustering partitions; the prediction model also includes an encoder; the prediction model also includes at least a discriminator; For any second sample time series data, the second sample time series data is input into the encoder for encoding to obtain encoded second sample time series data; the encoded second sample time series data is input into the initial discriminator to obtain k discrimination probabilities of the second sample time series data belonging to the k initial clustering partitions; The initial clustering partition to which the second sample time series data belongs is determined based on the k discrimination probabilities; The encoded second sample time-series data is input into the decoder to obtain the decoding result; Using the first objective function, the second objective function, and the third objective function as objectives, the encoder is tuned according to the k discrimination probabilities; the second objective function is used to ensure that the difference between the calculated probability and the discrimination probability of the second sample time series data for the same initial cluster partition is less than a second preset threshold; the third objective function is used to ensure that the distance between the decoding result and the second sample time series data is less than a fourth preset threshold.
9. A computing device, characterized in that, include: Memory, used to store computer programs; A processor is configured to invoke a computer program stored in the memory and execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer-executable program for causing a computer to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Multi-target tracking repositioning method based on trajectory similarity measurement learning
CN112561960A
Game matching method and device, storage medium and electronic equipment
CN114887330A