Feature mining and comparative learning time sequence clustering method and system

The characteristics of the trading behavior of the power market are extracted through wavelet transformation and data augmentation technology and clustered using comparative learning methods, which solves the problem that existing technology is difficult to deal with complex power market transaction behavior, and achieves more efficient data analysis and clustering effects .

CN119441910APending Publication Date: 2025-02-14GUANGXI POWER GRID CORP
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411374283.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

The prior art is difficult to effectively deal with complex power market trading behaviors, and the existing time series data enhancement methods are difficult to describe the transformation invariance of time series.

Method used

Wavelet transform is used to reduce noise and remove outliers on the time series data of power users' trading behavior, and sample feature extraction is performed through data enhancement methods and autoencoder. Then, the matrix is ​​clustered using a time series clustering method based on the contrast learning idea.

Benefits of technology

It improves the accuracy of the analysis of trading behavior in the power market and the interpretability of clustering results, can process complex power market transaction data more effectively, and provides stronger adaptability and computing efficiency in dynamically changing markets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441910A_ABST
    Figure CN119441910A_ABST
Patent Text Reader

Abstract

The invention discloses a time series clustering method and system based on feature mining and comparative learning, and the method comprises the steps: collecting the related data of a power market transaction subject, constructing variables from a first-level index of power transaction market clustering and a subordinate second-level index, and carrying out the granularity alignment of time series data. And carrying out noise reduction and abnormal value removal processing on the time sequence data of the power consumer transaction behaviors by adopting wavelet transform. Performing data enhancement on the time sequence of the power consumer transaction behaviors, constructing a sample pair, and performing sample feature extraction by adopting an auto-encoder; and clustering the sample pair matrix after data enhancement by adopting a time sequence clustering method based on a comparative learning idea. The invention provides a unique and novel feature mining method suitable for electricity market data, and good feature extraction also improves the subsequent clustering effect. The problem that an existing time sequence data enhancement method is difficult to describe the transformation invariance of the time sequence is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data analysis of power market transaction entities, and in particular to a time series clustering method and system for feature mining and contrast learning. Background Art

[0002] In the field of data analysis technology for power market trading entities, it is crucial to accurately understand and predict the trading behavior of power market entities. With the continuous development of the power market and the improvement of marketization, the trading behavior of power market entities has become more complex and changeable.

[0003] Feature mining techniques such as preprocessing and feature extraction of time series data are the basis for analyzing trading behavior in the power market. Time series data usually contains a lot of noise and outliers, which will affect the accuracy of subsequent analysis. Therefore, it is necessary to use wavelet transform to reduce noise and remove outliers from time series data. Wavelet transform can effectively extract local features of time series data and enhance the analyzability of data. In addition, sample feature extraction through data enhancement methods and autoencoders can further enrich the feature representation of data and provide more comprehensive feature support for subsequent clustering analysis.

[0004] Time series clustering is the core goal of this patent. Traditional clustering methods often ignore the frequency domain characteristics of data when processing time series data, resulting in unsatisfactory clustering results. At the same time, many machine learning clustering algorithms separate feature extraction from clustering, resulting in feature extraction being unable to improve clustering results.

[0005] Contrastive learning is an emerging machine learning method that learns the feature representation of samples by comparing the similarities and differences between different samples. In this patent, time series contrastive learning is applied to time series clustering, and the differences between samples are learned in a self-supervised manner by mining the representative features of the samples to achieve the purpose of clustering. This method can effectively improve the accuracy and interpretability of clustering results.

[0006] This patent adopts a time series clustering method based on contrastive learning to optimize the clustering results by maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs. At the same time, cluster-level contrast constraints and cluster allocation regularization are introduced to further optimize the clustering effect and ensure the consistency and stability of the clustering results.

[0007] Through the combination of the above key technologies, this patent provides a new feature mining technology for the transaction behavior of power market entities, as well as a feature clustering method based on clustering, which provides a new solution for the analysis of the behavior of power market entities. This method can not only improve the accuracy of the analysis of power market transaction behavior, but also provide stronger support for the decision-making of the power market. Summary of the invention

[0008] In view of the above-mentioned problems, the present invention is proposed.

[0009] Therefore, the technical problem solved by the present invention is that: with the continuous development of the power market and the improvement of the marketization degree, the trading behavior of the power market players has become more complex and changeable. The existing technology is difficult to process and calculate the complex power market trading behavior. The existing time series data enhancement method is difficult to describe the transformation invariance of the time series.

[0010] To solve the above technical problems, the present invention provides the following technical solutions: a time series clustering method of feature mining and contrastive learning, comprising: collecting relevant data of power market trading entities, constructing variables from the primary indicators of power trading market clustering and the subordinate secondary indicators, and aligning the granularity of time series data.

[0011] Wavelet transform is used to reduce noise and remove outliers in the time series data of power users' trading behavior.

[0012] The time series of electricity users' trading behavior is enhanced, sample pairs are constructed, and autoencoders are used to extract sample features.

[0013] The time series clustering method based on contrastive learning is used to cluster the sample pair matrix after data enhancement.

[0014] As a preferred scheme of the time series clustering method of feature mining and contrastive learning described in the present invention, the first-level indicators of the power trading market clustering include basic information of trading units, trading contract types, and power consumption patterns of trading units; the subordinate second-level indicators include retail and wholesale trading contract types, affiliated power supply bureaus, industry classifications, user categories, number of transactions, power consumption categories, power consumption patterns, and power consumption conditions.

[0015] The categorical text features are digitized using the one-hot encoding method, and the sequential text features are digitized using the BERT-SORT method. The labels are embedded, and the semantic and hierarchical information of the labels is retained during the digitization process. The missing data is filled using the KNN interpolation method.

[0016] The coarse-grained time series is aligned with the finest-grained time series using linear interpolation, and the digitized text data is aligned with the time series data. After preliminary variable construction, a numerical variable matrix containing user basic information, transaction contract type, and user electricity consumption mode is obtained, which is expressed as:

[0017] F=(x1,x2,...,x k )

[0018] x i =(x i1 ,x i2 , ..., x in ),i=1,2,...k

[0019] Among them, F represents the feature matrix, which contains the user's basic information, transaction contract type and electricity consumption pattern variables. i represents the feature vector of each user, represents the different features of the user, k represents the number of features, x ij represents the j-th feature value of user i, and n represents the number of features of each user.

[0020] The z-score method is used to standardize the variables, expressed as:

[0021]

[0022] in, represents the standardized variable value, represents the mean of the i-th variable, σ i Represents the standard deviation of the i-th variable, which is used to measure the degree of dispersion of the variable. ij * represents the jth eigenvalue of the i-th variable after standardization, x ij represents the j-th eigenvalue of the original i-th variable, and n represents the number of variables.

[0023] After digitization, granularity alignment and standardization, the feature matrix is ​​obtained

[0024] As a preferred solution of the time series clustering method of feature mining and contrastive learning described in the present invention, the use of wavelet transform to reduce noise and remove outliers on the time series data of power user transaction behavior includes using Haar function as the basis function of wavelet transform, and the wavelet function based on continuous transform is expressed as:

[0025]

[0026] Among them, τ represents the conversion factor, and φ(t) represents the basis wavelet.

[0027] When the base wavelet satisfies the wavelet admissible condition, the wavelet transform is expressed as:

[0028]

[0029] Among them, φ a,τ(t) represents the wavelet basis function, which is used to analyze the signal at different time points. a represents the ratio scaling parameter, which controls the expansion and contraction of the wavelet function and determines the frequency resolution of the wavelet. τ represents the conversion factor, φ(t) represents the basis wavelet, and t represents the time variable. CWT x (a,τ) represents the result of continuous wavelet transform, which represents the transformation of the signal at different times and frequencies. x(t) represents the square integrable function, represents the complex conjugate of the wavelet function.

[0030] There is redundant information in continuous wavelet transform, and high-pass and low-pass filters are needed to filter the redundant information to achieve the purpose of noise reduction.

[0031] There are two types of wavelets in the filter, the parent wavelet And the mother wavelet ψ(t), expressed as:

[0032]

[0033] The mother wavelet characterizes the high-frequency signal, while the father wavelet characterizes the low-frequency signal.

[0034] The time series after high-pass and low-pass filter transformation is expressed as:

[0035] x(t)=S J (t)+D J (t)+D J-1 +...+D1(t)

[0036] Among them, S J (t) represents the multinomial approximation based on the parent wavelet, which is the roughest approximation of the original time series. J (t), D J-1 , ..., D1(t) represents the multinomial approximation based on the mother wavelet. J represents the number of decomposition levels, and the two-level wavelet decomposition is repeated twice, J=2.

[0037] As a preferred solution of the time series clustering method of feature mining and contrastive learning described in the present invention, the data enhancement of the time series of power user trading behavior includes further signal enhancement of the time series data and joint feature extraction of all variables.

[0038] The shape-based data enhancement formula is expressed as:

[0039]

[0040] Among them, α represents the enhancement coefficient. By setting different α, the data is enhanced to obtain two different sets of data enhancement samples. Tα(x,a) represents the result after data enhancement, x represents the original input time series, x' represents the result after the original time series is transformed, max(x') represents the maximum value in the time series x', ° represents the Hadamard product, and 1 represents a full 1 vector to keep the dimension consistent.

[0041] By using different enhancement coefficients α, the two groups of samples are arranged in rows to obtain two enhancement matrices X t (t=a,b).

[0042] The two enhanced matrices are input into the sequence encoder, and the sequence encoder function h(·)(MLP / CNN / RNN / LSTM) is used for sample representation learning to obtain two feature representation matrices R a and R b .

[0043] As a preferred solution of the time series clustering method of feature mining and contrastive learning described in the present invention, wherein: the time series clustering method based on contrastive learning idea is used to cluster the sample pair matrix after data enhancement, including respectively using instance-level contrast constraints and cluster-level contrast constraints to act together on the sequence encoder.

[0044] Instance-level contrast constraints include, due to the direct representation matrix R a , R b The contrast constraint may lead to solution degradation, so a two-layer MLP function g(·) is used to map the representation matrix to a new space, and the mapped matrix Z = [Z a , Z b ], expressed as:

[0045]

[0046] Among them, O1 g Represents the output after ReLU activation function processing, indicating the nonlinear mapping of features. s Represents the mapping matrix, which is used to transform the original feature R t Mapped to a new space. t Represents the input feature representation matrix, which represents the features of the time series after encoding. b1 g represents the bias term, t represents different data enhancement methods, and t=a,b represents two different data enhancement samples. t represents the feature matrix after mapping, and represents the features after being processed by the MLP network. g(R t ) represents the feature mapping function g(·), which transforms the original feature R tMapped to the new feature space. W2 g Represents the mapping matrix, which is used to output the intermediate layer O1 g Mapped to the final feature. b1 g Represents the bias term.

[0047] Cluster-level contrast constraints include following the idea of ​​contrast clustering, introducing cluster-level contrast constraints in the learning process of the feature representation matrix, and the cluster distribution in the clustering results obtained after two enhancements of the same set of data is consistent. The similarity of feature representation is measured using the f(·) of the multi-layer perceptron classifier, and the probability form matrix Y′=[Y a , Y b ], expressed as:

[0048]

[0049] Among them, Y a , Y b represents the category allocation, K represents the number of categories, O1 f Represents the intermediate output processed by the ReLU activation function, which represents the nonlinear mapping of the input features. f Represents the weight matrix, mapping feature Z t To the new feature space. t represents the input feature, b1 f represents the bias term, Y t Represents the category assignment result, which indicates the category to which each sample belongs after the final clustering. f(R i ) represents the classifier function, which is used to measure the similarity of features and assign categories. Softmax represents the activation function, W2 f Represents the weight matrix, which is used to map from the intermediate layer output to the final output. b2 f Represents the bias term.

[0050] As a preferred solution of the time series clustering method of feature mining and contrastive learning described in the present invention, the contrast constraint includes calculating the loss of the contrast constraint, firstly defining the interval similarity of the time series from the perspective of positive and negative sample data, and calculating the cosine similarity based on the rows and columns of the feature representation matrix, which is expressed as:

[0051]

[0052] Among them, <·,·> represents the inner product operation, and |·| represents the vector bi-norm. s(z i ,z j ) represents sample z i and z j The cosine similarity between them indicates the similarity between two vectors. <z i ,zj > represents the vector z i and z j The inner product of ∣z i ∣ represents vector z i The second norm of , |z j ∣ represents vector z j The second norm of .

[0053] By maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs, Z = [Z a , Z b ] are respectively calculated for cosine similarity on the rows and columns to obtain the instance-level contrast constraint loss, expressed as:

[0054]

[0055] Among them, L r represents the total loss of instance-level contrast constraints, which is used to optimize the similarity between samples. N represents the number of samples, l k r represents the loss of the k-th sample pair, s(z i ,z i ′) represents the cosine similarity between sample pairs, τ represents the parameter that controls the smoothness of the similarity of sample pairs, and l [kneqi,kneqi′] Represents the indicator function, which is used to exclude positive sample pairs.

[0056] Based on the idea of ​​maximizing the cluster representation between the same samples and reducing the representation between different samples, we can a , Y b ] to perform cluster-level contrast constraints, thereby obtaining the loss function of cluster-level contrast constraints, expressed as:

[0057]

[0058] Among them, L c represents the total loss of cluster-level contrast constraints, which is used to optimize the clustering effect. K represents the number of cluster categories, l k c represents the loss of the k-th cluster, s(y i ′,y i ′) indicates the similarity of clustering results.

[0059] As a preferred solution of the time series clustering method for feature mining and contrastive learning described in the present invention, wherein: the time series clustering method based on contrastive learning idea is used to cluster the sample pair matrix after data enhancement, and further includes defining a minimized overall loss function, introducing a maximized probability distribution entropy and a cluster distribution regularization loss, which is expressed as:

[0060]

[0061]

[0062] Among them, L reg represents the category assignment regularization loss, which is used to prevent over-clustering. Pka represents the average assignment probability of the kth category under a augmented sample, P k b Y represents the average probability of the kth category under b enhanced samples. ik t represents the probability of assigning the i-th sample to category k, and t∈{a,b} represents different enhanced data samples. Represents the average assignment probability of category k. It regularizes the cluster assignment by maximizing the entropy of all category assignment probabilities to prevent a large number of samples from being classified into the same category.

[0063] Define the minimization of the overall loss function. The overall loss function of the final model is a linear combination of the instance-level contrast loss, cluster-level contrast loss, and cluster assignment regularization, with the linear combination parameters of 1, expressed as:

[0064]

[0065] Finally, Adam is used to minimize the overall loss function, and the network h(·) and f(·) are updated. The clustering process is repeated for a specified number of times, and the algorithm converges. The final clustering result Y is expressed as:

[0066]

[0067] Where L represents the total loss function, which consists of instance-level contrast loss, cluster-level contrast loss, and cluster assignment regularization loss. r represents the instance-level contrast loss, L c represents the cluster-level contrast loss, L reg represents the cluster assignment regularization loss.

[0068] A time series clustering system for feature mining and contrastive learning, characterized by: comprising:

[0069] The acquisition module collects data related to power market trading entities, constructs variables from the primary indicators of power trading market clusters and their subordinate secondary indicators, and performs granular alignment of time series data.

[0070] The preprocessing module uses wavelet transform to reduce noise and remove outliers from the time series data of power users' trading behavior.

[0071] The feature extraction module performs data enhancement on the time series of electricity users’ trading behaviors, constructs sample pairs, and uses autoencoders to extract sample features.

[0072] The clustering module uses a time series clustering method based on contrastive learning to cluster the sample pair matrix after data enhancement.

[0073] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0074] A computer-readable storage medium stores a computer program, which implements the steps of the method described above when executed by a processor.

[0075] Beneficial effects of the invention: Based on electricity market transaction data, our invention proposes a unique and novel feature mining method suitable for electricity market data, performs complete preprocessing operations on electricity data, and uses a sequence encoder to extract the nonlinear features of the data to obtain a feature matrix. Good feature extraction also improves the subsequent clustering effect.

[0076] From the perspective of the shape of time series, a data enhancement method suitable for contrastive learning is proposed, which solves the problem that existing time series data enhancement methods are difficult to describe the transformation invariance of time series.

[0077] The application of contrastive learning clustering methods, combined with the powerful feature extraction capabilities of autoencoders, can not only improve the accuracy and robustness of clustering, but also show stronger generalization capabilities and computational efficiency in dynamically changing data environments. The innovation and effectiveness of this method give it a significant advantage in dealing with complex time series data clustering tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0079] Figure 1 An overall flow chart of a time series clustering method and system for feature mining and contrastive learning provided in the first embodiment of the present invention.

[0080] Figure 2 A detailed flow chart of a time series clustering method and system for feature mining and contrastive learning provided in the first embodiment of the present invention. DETAILED DESCRIPTION

[0081] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0082] Example 1, reference Figure 1 , Figure 2 , is an embodiment of the present invention, and provides a time series clustering method for feature mining and contrastive learning, comprising:

[0083] S1: Collect data related to electricity market trading entities, construct variables from the primary indicators of electricity trading market clusters and their subordinate secondary indicators, and align the granularity of time series data.

[0084] It should be noted that the overall framework of the indicator system for power trading market clustering is shown in Table 1.

[0085] Table 1 Overall framework of the indicator system for power trading market clustering

[0086]

[0087] The first-level indicators of power trading market clustering include basic information of trading units, types of trading contracts, and electricity consumption patterns of trading units. The subordinate second-level indicators include types of retail and wholesale trading contracts, affiliated power supply bureaus, industry classifications, user categories, number of transactions, electricity consumption categories, electricity consumption patterns, and electricity consumption conditions.

[0088] The categorical text features are digitized using the one-hot encoding method, and the sequential text features are digitized using the BERT-SORT method. The labels are embedded, and the semantic and hierarchical information of the labels is retained during the digitization process. The missing data is filled using the KNN interpolation method.

[0089] The coarse-grained time series is aligned with the finest-grained time series using linear interpolation, and the digitized text data is aligned with the time series data. After preliminary variable construction, a numerical variable matrix containing user basic information, transaction contract type, and user electricity consumption mode is obtained, which is expressed as:

[0090] F=(x1,x2,...,x k )

[0091] x i =(x i1 ,x i2,...,x in ),i=1,2,...k

[0092] Among them, F represents the feature matrix, which contains the user's basic information, transaction contract type and electricity consumption pattern variables. i represents the feature vector of each user, represents the different features of the user, k represents the number of features, x ij represents the j-th feature value of user i, and n represents the number of features of each user.

[0093] The z-score method is used to standardize the variables, expressed as:

[0094]

[0095] in, represents the standardized variable value, represents the mean of the i-th variable, σ i Represents the standard deviation of the i-th variable, which is used to measure the degree of dispersion of the variable. ij * represents the jth eigenvalue of the i-th variable after standardization, x ij represents the j-th eigenvalue of the original i-th variable, and n represents the number of variables.

[0096] After digitization, granularity alignment and standardization, the feature matrix is ​​obtained

[0097] S2: Wavelet transform is used to reduce noise and remove outliers from the time series data of electricity users’ trading behavior.

[0098] Using Haar function as the basis function of wavelet transform, the wavelet function based on continuous transformation is expressed as:

[0099]

[0100] Among them, τ represents the conversion factor, and φ(t) represents the basis wavelet.

[0101] When the base wavelet satisfies the wavelet admissible condition, the wavelet transform is expressed as:

[0102]

[0103] Among them, φ a,τ (t) represents the wavelet basis function, which is used to analyze the signal at different time points. a represents the ratio scaling parameter, which controls the expansion and contraction of the wavelet function and determines the frequency resolution of the wavelet. τ represents the conversion factor, φ(t) represents the basis wavelet, and t represents the time variable. CWT x(a,τ) represents the result of continuous wavelet transform, which represents the transformation of the signal at different times and frequencies. x(t) represents the square integrable function, represents the complex conjugate of the wavelet function.

[0104] There is redundant information in continuous wavelet transform, and high-pass and low-pass filters are needed to filter the redundant information to achieve the purpose of noise reduction.

[0105] There are two types of wavelets in the filter, the parent wavelet And the mother wavelet ψ(t), expressed as:

[0106]

[0107] The mother wavelet characterizes the high-frequency signal, while the father wavelet characterizes the low-frequency signal.

[0108] The time series after high-pass and low-pass filter transformation is expressed as:

[0109] x(t)=S J (t)+D J (t)+D J-1 +...+D1(t)

[0110] Among them, S J (t) represents the multinomial approximation based on the parent wavelet, which is the roughest approximation of the original time series. J (t), D J-1 , ..., D1(t) represents the multinomial approximation based on the mother wavelet. J represents the number of decomposition levels, and the two-level wavelet decomposition is repeated twice, J=2.

[0111] S3: Perform data enhancement on the time series of electricity users’ trading behaviors, construct sample pairs, and use autoencoders to extract sample features.

[0112] Further signal enhancement is performed on time series data, and joint feature extraction is performed on all variables.

[0113] The shape-based data enhancement formula is expressed as:

[0114]

[0115] Among them, α represents the enhancement coefficient. By setting different α, the data is enhanced to obtain two different sets of data enhancement samples. α (x,a) represents the result after data enhancement, x represents the original input time series, x' represents the result after the original time series is transformed, max(x') represents the maximum value in the time series x', ° represents the Hadamard product, and 1 represents an all-1 vector to keep the dimensions consistent.

[0116] By using different enhancement coefficients α, the two groups of samples are arranged in rows to obtain two enhancement matrices X t (t=a,b).

[0117] The two enhanced matrices are input into the sequence encoder, and the sequence encoder function h(·)(MLP / CNN / RNN / LSTM) is used for sample representation learning to obtain two feature representation matrices R a and R b .

[0118] S4: A time series clustering method based on contrastive learning is used to cluster the sample pair matrix after data enhancement.

[0119] Instance-level contrast constraints and cluster-level contrast constraints are used together on the sequence encoder.

[0120] Instance-level contrast constraints include, due to the direct representation matrix R a , R b The contrast constraint may lead to solution degradation, so a two-layer MLP function g(·) is used to map the representation matrix to a new space, and the mapped matrix Z = [Z a , Z b ], expressed as:

[0121]

[0122] Among them, O1 g Represents the output after ReLU activation function processing, indicating the nonlinear mapping of features. s Represents the mapping matrix, which is used to transform the original feature R t Mapped to a new space. t Represents the input feature representation matrix, which represents the features of the time series after encoding. b1 g represents the bias term, t represents different data enhancement methods, and t=a,b represents two different data enhancement samples. t represents the feature matrix after mapping, and represents the features after being processed by the MLP network. g(R t ) represents the feature mapping function g(·), which transforms the original feature R t Mapped to the new feature space. W2 g Represents the mapping matrix, which is used to output the intermediate layer O1 g Mapped to the final feature. b1 g Represents the bias term.

[0123] Cluster-level contrast constraints include following the idea of ​​contrast clustering, introducing cluster-level contrast constraints in the learning process of the feature representation matrix, and the cluster distribution in the clustering results obtained after two enhancements of the same set of data is consistent. The similarity of feature representation is measured using the f(·) of the multi-layer perceptron classifier, and the probability form matrix Y′=[Y a , Y b ], expressed as:

[0124]

[0125] Among them, Y a , Y b represents category allocation, K represents the number of categories, O1 f Represents the intermediate output processed by the ReLU activation function, which represents the nonlinear mapping of the input features. f Represents the weight matrix, mapping feature Z t To the new feature space. t represents the input feature, b1 f represents the bias term, Y t Represents the category assignment result, which indicates the category to which each sample belongs after the final clustering. f(R i ) represents the classifier function, which is used to measure the similarity of features and assign categories. Softmax represents the activation function, W2 f Represents the weight matrix, which is used to map from the intermediate layer output to the final output. b2 f Represents the bias term.

[0126] To calculate the loss of contrast constraints, we first define the interval similarity of the time series from the perspective of positive and negative sample data, and then calculate the cosine similarity based on the rows and columns of the feature representation matrix, which is expressed as:

[0127]

[0128] Among them, <·,·> represents the inner product operation, and |·| represents the bi-norm of the vector. s(z i ,z j ) represents sample z i and z j The cosine similarity between them indicates the similarity between two vectors. <z i ,z j > represents the vector z i and z j The inner product of ∣z i ∣ represents vector z i The second norm of , |z j ∣ represents vector z j The second norm of .

[0129] By maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs, Z = [Z a , Z b ] are respectively calculated for cosine similarity on the rows and columns to obtain the instance-level contrast constraint loss, expressed as:

[0130]

[0131]

[0132] Among them, L r represents the total loss of instance-level contrast constraints, which is used to optimize the similarity between samples. N represents the number of samples, l k r represents the loss of the k-th sample pair, s(z i ,z i ′) represents the cosine similarity between sample pairs, τ represents the parameter that controls the smoothness of the similarity of sample pairs, and l [kneqi,kneqi′] Represents the indicator function, which is used to exclude positive sample pairs.

[0133] Based on the idea of ​​maximizing the cluster representation between the same samples and reducing the representation between different samples, we can a , Y b ] to perform cluster-level contrast constraints, thereby obtaining the loss function of cluster-level contrast constraints, expressed as:

[0134]

[0135] Among them, L c represents the total loss of cluster-level contrast constraints, which is used to optimize the clustering effect. K represents the number of cluster categories, l k c represents the loss of the k-th cluster, s(y i ′,y i ′) indicates the similarity of clustering results.

[0136] Define the minimization of the overall loss function, introduce the maximization of the probability distribution entropy and the cluster distribution regularization loss, expressed as:

[0137]

[0138] Among them, L reg represents the category assignment regularization loss, which is used to prevent over-clustering. Pka represents the average assignment probability of the kth category under a augmented sample, P k b Y represents the average probability of the kth category under b enhanced samples. ik trepresents the probability of assigning the i-th sample to category k, and t∈{a,b} represents different enhanced data samples. Represents the average assignment probability of category k. It regularizes the cluster assignment by maximizing the entropy of all category assignment probabilities to prevent a large number of samples from being classified into the same category.

[0139] Define the minimization of the overall loss function. The overall loss function of the final model is a linear combination of the instance-level contrast loss, cluster-level contrast loss, and cluster assignment regularization, with the linear combination parameters of 1, expressed as:

[0140]

[0141] Finally, Adam is used to minimize the overall loss function, and the network h(·) and f(·) are updated. The clustering process is repeated for a specified number of times, and the algorithm converges. The final clustering result Y is expressed as:

[0142]

[0143] Where L represents the total loss function, which consists of instance-level contrast loss, cluster-level contrast loss, and cluster assignment regularization loss. r represents the instance-level contrast loss, L c represents the cluster-level contrast loss, L reg represents the cluster assignment regularization loss.

[0144] The computer device may be a server. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data cluster data of a power monitoring system. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method is implemented.

[0145] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0146] Example 2 is an embodiment of the present invention, which provides a time series clustering method and system for feature mining and contrastive learning. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through simulation experiments.

[0147] This experiment selected the electricity consumption behavior data of 7 electricity trading entities for the experiment, covering primary and secondary indicators such as various transaction contracts, electricity consumption patterns, and industry classifications.

[0148] Experimental steps:

[0149] The historical transaction data of seven trading entities in the power market are collected, covering key indicators such as transaction contract type, power consumption mode, industry classification, and user category. (The existing technology uses direct linear interpolation and missing value filling methods for data preprocessing.)

[0150] The BERT-SORT method is used to digitize the sequential text features, preserving the hierarchical relationship and semantic information in the data. For missing data, the KNN interpolation method is used to fill in the missing data, further improving the data integrity. The coarse-grained and fine-grained time series data are aligned through linear interpolation to ensure that all variables can be compared on the same time scale. (The existing technology uses the traditional moving average method to process noise, which has limited effect.)

[0151] The present invention adopts Haar wavelet transform to filter the high-frequency noise in the time series, and further eliminates redundant information through high-pass and low-pass filters to make the data smoother.

[0152] The existing technology adopts a simple data supplement method for data enhancement, which is unable to enhance the diversity of data in terms of morphology.

[0153] The present invention uses a shape enhancement method, uses different enhancement coefficients (0.5, 1.0) to generate two groups of enhanced samples, and extracts deep features of the samples through an autoencoder to form two enhancement matrices. (The traditional K-Means clustering algorithm is used in the prior art, but the algorithm lacks consideration of frequency domain characteristics when processing time series data.) The present invention combines the idea of ​​contrastive learning, inputs the enhanced sample pairs into the sequence encoder, adopts instance-level and cluster-level contrast constraints, and performs feature mapping and clustering through an MLP network and a softmax classifier. After optimization, the final feature representation generates a more accurate clustering result. The experimental results are shown in Table 1.

[0154] Table 1 Experimental results

[0155]

[0156] By comparing the data in the table, it can be seen that the performance of the present invention in data processing and clustering results is significantly better than that of the prior art. In terms of the "abnormal data rate" indicator, the abnormal rate of the transaction subject data processed by the prior art is generally high, for example, the transaction subject D reaches 4.0%, while after the wavelet transform denoising of the present invention, the abnormal rate is significantly reduced, and the transaction subject C is only 1.9%. This shows that the present invention can more effectively remove outliers and redundant information when processing high-noise time series data. From the "volatility coefficient" indicator, it can be seen that the data processed by the prior art fluctuates greatly, such as the volatility coefficient of transaction subject D reaches 15.0%, which may cause clustering instability in actual operation. However, the present invention significantly reduces the volatility coefficient through feature extraction after data enhancement, for example, the volatility coefficients of transaction subject A and transaction subject C are 10.2% and 9.8% respectively. This shows that the present invention improves the stability of data through the enhancement method. In the "clustering category", the K-Means clustering method of the prior art ignores the frequency domain characteristics of the data, resulting in inaccurate clustering between different transaction subjects. For example, transaction subject E and transaction subject G should be divided into different categories, but the prior art fails to effectively distinguish them. The present invention adopts a clustering method based on contrastive learning, taking the shape characteristics of the time series into consideration, and can more accurately classify similar trading entities into the same category. Trading entities A, C, D, and G are classified as category 1, which is consistent. In the item of "electricity consumption pattern classification", the existing technology cannot accurately distinguish the different electricity consumption patterns of trading entities due to rough processing. The present invention can accurately classify through the sequence encoder combined with feature extraction and clustering constraints, and entities with different electricity consumption patterns have a more obvious distinguishing effect in clustering, which is of great significance in the behavioral analysis of trading entities in the power market.

[0157] In summary, when processing complex power market transaction data, the present invention not only has significant advantages in data noise reduction and enhancement, but also has obvious advantages over the prior art in clustering accuracy and stability. These innovative steps enable the present invention to provide stronger adaptability and computational efficiency in a dynamically changing market.

[0158] Embodiment 3 is an embodiment of the present invention, which provides a time series clustering system for feature mining and contrastive learning, including:

[0159] The acquisition module collects data related to power market trading entities, constructs variables from the primary indicators of power trading market clusters and their subordinate secondary indicators, and performs granular alignment of time series data.

[0160] The preprocessing module uses wavelet transform to reduce noise and remove outliers from the time series data of power users' trading behavior.

[0161] The feature extraction module performs data enhancement on the time series of electricity users’ trading behaviors, constructs sample pairs, and uses autoencoders to extract sample features.

[0162] The clustering module uses a time series clustering method based on contrastive learning to cluster the sample pair matrix after data enhancement.

[0163] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A time series clustering method for feature mining and contrastive learning, characterized in that: include: Collect data related to power market trading entities, construct variables from the primary indicators of power trading market clusters and their subordinate secondary indicators, and align the granularity of time series data; Wavelet transform is used to reduce noise and remove outliers from the time series data of power users' trading behavior; The time series of electricity users' trading behaviors are enhanced, sample pairs are constructed, and autoencoders are used to extract sample features. The time series clustering method based on contrastive learning is used to cluster the sample pair matrix after data enhancement.

2. The time series clustering method for feature mining and contrastive learning according to claim 1, characterized in that: The primary indicators of the power trading market clustering include basic information of trading units, trading contract types, and trading unit electricity consumption patterns, and the subordinate secondary indicators include retail and wholesale trading contract types, affiliated power supply bureaus, industry classifications, user categories, transaction times, electricity consumption categories, electricity consumption patterns, and electricity consumption conditions; The categorical text features are digitized using the one-hot encoding method, and the sequential text features are digitized using the BERT-SORT method. The labels are embedded, and the semantic and hierarchical information of the labels is retained during the digitization process. The missing data is filled using the KNN interpolation method. The coarse-grained time series is aligned with the finest-grained time series using linear interpolation, and the digitized text data is aligned with the time series data. After preliminary variable construction, a numerical variable matrix containing user basic information, transaction contract type, and user electricity consumption mode is obtained, which is expressed as: F=(x1,x2,...,x k ) x i =(x i1 ,x i2 ,...,x in ),i=1,2,...k Among them, F represents the feature matrix, which contains the basic information of users, transaction contract types and electricity consumption pattern variables; xi represents the feature vector of each user, which represents the different features of the user; k represents the number of features; x ij represents the j-th feature value of user i, and n represents the number of features of each user; The z-score method is used to standardize the variables, expressed as: in, represents the standardized variable value, represents the mean of the i-th variable, σ i Represents the standard deviation of the i-th variable, which is used to measure the degree of dispersion of the variable. ij * represents the jth eigenvalue of the i-th variable after standardization, x ij represents the jth eigenvalue of the original i-th variable, and n represents the number of variables; After digitization, granularity alignment and standardization, the feature matrix is ​​obtained 3. The time series clustering method for feature mining and contrastive learning according to claim 2, characterized in that: The use of wavelet transform to reduce noise and remove outliers in the time series data of power user transaction behavior includes using Haar function as the basis function of wavelet transform, and the wavelet function based on continuous transform is expressed as: Among them, τ represents the conversion factor, φ(t) represents the base wavelet; When the base wavelet satisfies the wavelet admissible condition, the wavelet transform is expressed as: Among them, φ a,τ (t) represents the wavelet basis function, which is used to analyze the signal at different time points; a represents the ratio scaling parameter, which controls the expansion and contraction of the wavelet function and determines the frequency resolution of the wavelet; τ represents the conversion factor, φ(t) represents the basis wavelet, and t represents the time variable; CWT x (a,τ) represents the result of continuous wavelet transform, which indicates the transformation of the signal at different times and frequencies; x(t) represents the square integrable function, represents the complex conjugate of the wavelet function; There is redundant information in the continuous wavelet transform, and high-pass and low-pass filters are needed to filter the redundant information to achieve the purpose of noise reduction; There are two types of wavelets in the filter, the parent wavelet And the mother wavelet ψ(t), expressed as: The mother wavelet characterizes the high-frequency signal, while the father wavelet characterizes the low-frequency signal; The time series after high-pass and low-pass filter transformation is expressed as: x(t)=S J (t)+D J (t)+D J-1 +...+D1(t) Among them, S J (t) represents the multinomial approximation based on the parent wavelet, which is the roughest approximation of the original time series; D J (t), D J-1 , ..., D1(t) represents the multinomial approximation based on the mother wavelet; J represents the number of decomposition levels, the two-level wavelet decomposition is repeated twice, J=2.

4. The time series clustering method for feature mining and contrastive learning according to claim 3, characterized in that: The data enhancement of the time series of power user transaction behavior includes further signal enhancement of the time series data and joint feature extraction of all variables; The shape-based data enhancement formula is expressed as: Among them, α represents the enhancement coefficient. By setting different α, the data is enhanced to obtain two different sets of data enhancement samples; T α (x,a) represents the result after data enhancement, x represents the original input time series, x' represents the result after the original time series is transformed, max(x') represents the maximum value in the time series x', ° represents the Hadamard product, and 1 represents a full 1 vector to keep the dimension consistent; By using different enhancement coefficients α, the two groups of samples are arranged in rows to obtain two enhancement matrices X t (t=a,b); The two enhanced matrices are input into the sequence encoder, and the sequence encoder function h(·) (MLP / CNN / RNN / LSTM) is used for sample representation learning to obtain two feature representation matrices R b and R b .

5. The time series clustering method for feature mining and contrastive learning according to claim 4, characterized in that: The method of clustering the sample pair matrix after data enhancement by using the time series clustering method based on contrastive learning includes: using instance-level contrast constraints and cluster-level contrast constraints to act on the sequence encoder respectively; Instance-level contrast constraints include, due to the direct representation matrix R a , R b The contrast constraint may lead to solution degradation, so a two-layer MLP function g(·) is used to map the representation matrix to a new space, and the mapped matrix Z = [Z a , Z b ], expressed as: Among them, O1 g Represents the output after ReLU activation function processing, indicating the nonlinear mapping of features; W2 s Represents the mapping matrix, which is used to transform the original feature R t Mapping to a new space; R t represents the input feature representation matrix, which represents the features of the time series after encoding; b1 g represents the bias term, t represents different data enhancement methods, t=a,b represents two different data enhancement samples; Z t represents the feature matrix after mapping, which represents the features after being processed by the MLP network; g(R t ) represents the feature mapping function g(·), which transforms the original feature R t Mapping to the new feature space; W2 g Represents the mapping matrix, which is used to output the intermediate layer O1 g Mapped to the final feature; b1 g represents the bias term; The cluster-level contrast constraint includes: following the idea of ​​contrast clustering, introducing cluster-level contrast constraint in the learning process of feature representation matrix, and obtaining consistent cluster distribution in clustering results after two enhancements of the same set of data; using the f(·) of multi-layer perceptron classifier to measure the similarity of feature representation, and obtaining probability form matrix Y′=[Y a , Y b ], expressed as: Among them, Y a , Y b represents category allocation, K represents the number of categories, O1 f Represents the intermediate output processed by the ReLU activation function, which represents the nonlinear mapping of the input features; W1 f Represents the weight matrix, mapping feature Z t To the new feature space; Z t represents the input feature, b1 f represents the bias term, Y t Represents the category assignment result, indicating the category to which each sample belongs after the final clustering; f(R i ) represents the classifier function, which is used to measure the similarity of features and perform category assignment; softmax represents the activation function, W2 f Represents the weight matrix, which is used to map from the intermediate layer output to the final output; b2 f Represents the bias term.

6. The time series clustering method for feature mining and contrastive learning according to claim 5, characterized in that: The contrast constraint includes calculating the loss of the contrast constraint. First, the interval similarity of the time series is defined from the perspective of positive and negative sample data. The cosine similarity is calculated based on the rows and columns of the feature representation matrix, which is expressed as: Among them, <·,·> represents the inner product operation, |·| represents the bi-norm of the vector; s(z i ,z j ) represents sample z i and z j The cosine similarity between them indicates the similarity between the two vectors; <z i ,z j > represents the vector z i and z j The inner product of i ∣ represents vector z i The second norm of , |z j ∣ represents vector z j The second norm of ; By maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs, Z = [Z a , Z b ] are respectively calculated for cosine similarity on the rows and columns to obtain the instance-level contrast constraint loss, expressed as: Among them, L r represents the total loss of instance-level contrast constraints, which is used to optimize the similarity between samples; N represents the number of samples, l k r represents the loss of the k-th sample pair, s(z i ,z i ′) represents the cosine similarity between sample pairs, τ represents the parameter that controls the smoothness of the similarity of sample pairs, l [ kneqi,kneqi′ ] represents the indicator function, which is used to exclude positive sample pairs; Based on the idea of ​​maximizing the cluster representation between the same samples and reducing the representation between different samples, we can a , Y b ] to perform cluster-level contrast constraints, thereby obtaining the loss function of cluster-level contrast constraints, expressed as: Among them, L c represents the total loss of cluster-level contrast constraints, which is used to optimize the clustering effect; K represents the number of cluster categories, l k c represents the loss of the k-th cluster, s(y i ′,y i ′) indicates the similarity of clustering results.

7. The time series clustering method for feature mining and contrastive learning according to claim 6, characterized in that: The clustering of the sample pair matrix after data enhancement by using the time series clustering method based on contrastive learning also includes defining a minimized overall loss function, introducing a maximized probability distribution entropy and a cluster distribution regularization loss, which is expressed as: Among them, L reg represents the category assignment regularization loss, which is used to prevent over-clustering; Pka represents the average assignment probability of the kth category under a enhanced sample, P k b represents the average distribution probability of the kth category under b enhanced samples; Y ik t represents the probability of assigning the i-th sample to category k, and t∈{a,b} represents different enhanced data samples; represents the average assignment probability of category k, and regularizes the cluster assignment by maximizing the entropy of all category assignment probabilities to prevent a large number of samples from being classified into the same category; Define the minimization of the overall loss function. The overall loss function of the final model is a linear combination of the instance-level contrast loss, cluster-level contrast loss, and cluster assignment regularization, with the linear combination parameters of 1, expressed as: Finally, Adam is used to minimize the overall loss function, and the network h(·) and f(·) are updated. The clustering process is repeated for a specified number of times, and the algorithm converges. The final clustering result Y is expressed as: Where L represents the total loss function, which consists of instance-level contrast loss, cluster-level contrast loss, and cluster assignment regularization loss; L r represents the instance-level contrast loss, L c represents the cluster-level contrast loss, L reg represents the cluster assignment regularization loss.

8. A time series clustering system using a feature mining and contrastive learning method according to any one of claims 1 to 7, characterized in that: The acquisition module collects data related to power market trading entities, constructs variables from the primary indicators of power trading market clusters and their subordinate secondary indicators, and performs granular alignment of time series data; The pre-processing module uses wavelet transform to reduce noise and remove outliers from the time series data of power users’ trading behavior; The feature extraction module performs data enhancement on the time series of power users’ trading behaviors, constructs sample pairs, and uses an autoencoder to extract sample features; The clustering module uses a time series clustering method based on contrastive learning to cluster the sample pair matrix after data enhancement.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Spot day-ahead market decision sample matrix clustering preprocessing method and system

    CN121365263A

  • Cross-domain image classification method based on double contrast constraints

    CN121937792A