Vectorization word segmentation method based on time series data
By performing window segmentation and clustering of timing data, constructing timing data dictionaries and training vectors, solving the problem that the traditional timing data processing method is difficult to capture complex time -dependent relationships, and realize more efficient data analysis and cross -domain applications.
Patent Information
- Application Number
- CN202411341026.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-24
AI Technical Summary
Traditional time-series data processing methods are difficult to capture complex time dependencies, require manual feature selection, high professional knowledge requirements, and high calculation costs in large data volume or high dimensions, and poor results.
The vectorized word segmentation method based on time series data is used to segment the time series data through windows, perform clustering and discretization, construct a time series data dictionary, and use word vector training to obtain time series word vectors.
Temporal word vectors can better capture the patterns of data changes over time, improve data processing and analysis efficiency, are suitable for clustering processing of large amounts of data, can control clustering accuracy, and support cross-domain temporal information integration.
Smart Images

Figure CN119357918A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electric power big data, and in particular to a vectorized word segmentation method based on time series data. Background Art
[0002] In the era of big models, the research and application of the combination of power time series data and big language models is an inevitable product of the digital transformation of the power industry and the development of smart grids. However, traditional time series data processing methods are difficult to capture complex time dependencies, especially in terms of nonlinear relationships and long-distance dependencies; and traditional methods often require manual feature selection and engineering, which is not only time-consuming, but also requires high professional knowledge in the field, and may not be able to automatically capture all potential useful features; at the same time, when the data volume is large or the dimension is high, traditional methods may become computationally expensive and ineffective, especially when processing large-scale streaming data. For these reasons, traditional time series data processing methods can no longer meet the current development trend of intelligence. Therefore, we can learn from the way of obtaining word vectors in NLP, use time series data to train models to obtain time series word vectors, and combine them with big language models to fully utilize the advantages of deep learning, improve the performance and application scope of the model, and thus achieve a higher level of analysis and understanding.
[0003] The "Time-scale Distribution Transformer Heavy Overload Judgment Method" disclosed in the Chinese patent literature has a publication number of CN110457770A and a publication date of 2019-11-15, which includes the following steps: Step 1: Sampling the original load operation data of the distribution transformer and discretizing it into 24-point time series data; Step 2: Extracting features of the time series data based on the LSTM-BP network; Step 3: Clustering the extracted features using the fuzzy C-means clustering algorithm to obtain multiple clusters, each cluster representing the characteristic law of a certain specific heavy overload on the time scale; Step 4: Judging the heavy overload situation of the distribution transformer according to the heavy overload time characteristics of each distribution transformer. This technology adopts the traditional time series data processing method, which performs feature extraction and classification on the time series data and then inputs the corresponding model to obtain the analysis result. However, in the specific process of feature extraction, manual feature selection and training are required to obtain the corresponding feature extraction network, which requires high professional knowledge and may not be able to capture all potential features. At the same time, it is still difficult to capture time dependencies in terms of nonlinear relationships and long-distance dependencies, which may cause complex relationships to be omitted or ignored during the initial processing of time series data, making it impossible to perform more accurate and in-depth analysis. Summary of the invention
[0004] The present invention aims to overcome the problem in the prior art that features of time series data are extracted and then input into the corresponding model for analysis to obtain results. Manual feature selection and training are required to obtain the corresponding feature extraction network, which requires high professional knowledge and may not be able to capture all potential features; as well as the difficulty in capturing nonlinear relationships and time dependencies in terms of long-distance dependencies. A vectorized word segmentation method based on time series data is provided.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions: A vectorized word segmentation method based on time series data, including: Get the time series data and use the window to split it to get a two-dimensional array; Perform clustering on the two-dimensional array in batches, and perform secondary clustering based on the results of the first clustering of all batches to obtain the final clustering results; Construct a time series data dictionary based on the cluster centers and cluster clusters of the final clustering results; Discretize time series data based on the time series data dictionary; The word vector is trained based on the discretized time series data to obtain the time series word vector.
[0006] The present invention is based on the research on power time series data and proposes a method for discretizing (quantizing) time series data by clustering; the continuous time series data is segmented by using windows; the data is clustered by a specific clustering algorithm, and a cluster center is calculated for the data of the same type of cluster cluster, and the serial number of each cluster center is the cluster label; when the distance between the elements of each cluster cluster is small enough, the cluster center of the cluster can approximately represent the elements in the cluster; the segmented data segments are replaced by cluster labels to realize the discretization process of continuous time series data; after the discretization is completed, the data structure composed of cluster centers can be mapped to a dictionary in the text, that is, each cluster center can be mapped to a word in the dictionary, the number of samples in the cluster is mapped to the word frequency in the dictionary, and the cluster label is mapped to the word ID, which is imitated as a word dictionary form, so as to draw on the training of word vectors in NLP to train time series word vectors; the time series data is mapped to a continuous vector space through time series word vectors, so that modern machine learning and deep learning technologies can be used to mine and understand the complex patterns behind the data, thereby supporting a series of advanced analysis and decision support applications.
[0007] Preferably, the acquiring of time series data and segmentation processing using a window to obtain a two-dimensional array comprises: Normalize and concatenate different types of time series data; The spliced time series data is segmented into several data segments by using a rolling window method, and each data segment is used as a row to form a two-dimensional array, and the number of columns of the two-dimensional array is the size of the rolling window.
[0008] Preferably, the process of obtaining the final clustering result includes: The two-dimensional array is divided into several batches, and each batch is clustered once to obtain the primary clusters and primary cluster centers of the batch; a new two-dimensional array is formed with all the primary cluster centers, and secondary clustering is performed to obtain secondary clusters and secondary cluster centers; all the data corresponding to each secondary cluster are merged, and the cluster centers are recalculated to obtain the final clustering result.
[0009] Preferably, the primary clustering and secondary clustering methods are the same; the process of clustering any two-dimensional array includes: Calculate the distance similarity between the vector corresponding to each row of the two-dimensional array M and all vectors to obtain the two-dimensional array D; Traverse each column of distance cluster Di in D to obtain the distance cluster Dmax with the largest number of data that satisfy the distance similarity less than the distance threshold d; form a cluster Ci with the data in Dmax whose distance similarity is less than d and obtain the cluster center CCi; Eliminate the data in Ci from M to form a new two-dimensional array M for clustering until the number of data in M is 1.
[0010] Preferably, constructing a time series data dictionary using cluster centers and cluster clusters of the final clustering result includes: Sort the clusters in the final clustering result from large to small according to the number of samples in the cluster, and mark the cluster labels from small to large according to the sorting results; The cluster center of each cluster is mapped to the word in the dictionary, the number of samples in the cluster is mapped to the word frequency in the dictionary, and the cluster label is mapped to the word ID.
[0011] Preferably, the discretization processing of the time series data based on the time series data dictionary includes: For time series data, several data segments are obtained by using windows to split them; Traverse all data segments and replace the data segment with the cluster label of the cluster to which the data segment belongs.
[0012] Preferably, the calculation of the distance similarity between the vector corresponding to each row of the two-dimensional array M and all vectors includes: respectively calculating the absolute value of the mean difference, the absolute value of the standard deviation, and the absolute value of the forward differential inclination difference of the two vectors; and summing the calculation results of the three absolute values to obtain the distance similarity between the two vectors.
[0013] Preferably, the setting of the distance threshold d includes: Calculate the mean of all elements in the two-dimensional array D, and multiply the mean of all elements in D by the set ratio to obtain the distance threshold d.
[0014] Preferably, the step of merging all data corresponding to each secondary cluster and recalculating the cluster center to obtain the final clustering result includes: Traverse all secondary clusters, and for each secondary cluster, merge all the data in the primary cluster to which the primary cluster center corresponding to the samples in the cluster belongs into a cluster of the final clustering result, and recalculate the cluster center of the cluster.
[0015] Preferably, the step of performing word vector training based on discretized time series data to obtain a time series word vector comprises: The discretized time series data is converted into a corpus formed by cluster labels; training data is constructed and input into the SkipGram network for training to obtain time series word vectors.
[0016] The present invention has the following beneficial effects: the time-varying pattern of data can be captured in the form of time series word vectors, and complex time dependencies can be better captured than traditional time series data processing; and time series word vectors are not limited to text data, but can also be applied to other types of time series data such as text and images, and can effectively integrate time series information from multiple fields; converting time series data into vectors of fixed length can significantly improve the efficiency of data processing and analysis, and the discretized time series data can be processed using more efficient machine learning or deep learning algorithms than traditional time series data; the method for discretizing time series data of the present invention is suitable for clustering processing of large amounts of data, can control clustering accuracy, and can complete clustering without determining the number of clusters in advance. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flow chart of the vectorized word segmentation method based on time series data in the present invention.
[0018] Figure 2 It is the user load time series data in the embodiment of the present invention.
[0019] Figure 3 It is a schematic diagram of the first type of clustering cluster in the final clustering result of the embodiment of the present invention.
[0020] Figure 4 Schematic diagram of the second clustering cluster in the final clustering result of the embodiment of the present invention.
[0021] Figure 5 Schematic diagram of the third type of clustering cluster in the final clustering result of the embodiment of the present invention.
[0022] Figure 6Schematic diagram of the fourth clustering cluster in the final clustering result of the embodiment of the present invention.
[0023] Figure 7 Schematic diagram of the fifth cluster in the final clustering result of the embodiment of the present invention. DETAILED DESCRIPTION
[0024] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments.
[0025] In the era of big models, the research and application of the combination of power time series data and big language models is an inevitable product of the digital transformation of the power industry and the development of smart grids. Traditional time series data processing methods can no longer meet the current development trend of intelligence. Therefore, we can learn from the way of obtaining word vectors in NLP, use time series data to train the model to obtain time series word vectors, and combine them with big language models to fully utilize the advantages of deep learning, improve the performance and application scope of the model, and thus achieve a higher level of analysis and understanding.
[0026] like Figure 1 As shown, a vectorized word segmentation method based on time series data includes: Get the time series data and use the window to split it to get a two-dimensional array; Perform clustering on the two-dimensional array in batches, and perform secondary clustering based on the results of the first clustering of all batches to obtain the final clustering results; Construct a time series data dictionary based on the cluster centers and cluster clusters of the final clustering results; Discretize time series data based on the time series data dictionary; The word vector is trained based on the discretized time series data to obtain the time series word vector.
[0027] It should be noted that the present invention is based on the research on power time series data and proposes a method for discretizing (quantizing) time series data by clustering; the continuous time series data is segmented by using windows; the data is clustered by a specific clustering algorithm, and a cluster center is calculated for the data of the same type of cluster, and the serial number of each cluster center is a cluster label; when the distance between the elements of each cluster is small enough, the cluster center of the cluster can approximately represent the elements in the cluster; the segmented data segments are replaced by cluster labels to realize the discretization process of continuous time series data; After discretization, the data structure composed of cluster centers can be mapped to the dictionary in the text, that is, each cluster center can be mapped to a word in the dictionary, the number of samples in the cluster is mapped to the word frequency in the dictionary, and the cluster label is mapped to the word ID, imitating it in the form of a word dictionary, so as to learn from the training of word vectors in NLP to train time series word vectors; through time series word vectors, time series data can be mapped to a continuous vector space, so that modern machine learning and deep learning technologies can be used to mine and understand the complex patterns behind the data, thereby supporting a series of advanced analysis and decision support applications.
[0028] It is worth noting that traditional methods for processing time series data have certain limitations. Lack of contextual understanding: Traditional methods for processing time series data have difficulty capturing complex temporal dependencies, especially in terms of nonlinear relationships and long-distance dependencies. High demand for feature engineering: Traditional methods often require manual feature selection and engineering, which is not only time-consuming, but also requires high domain expertise and may not be able to automatically capture all potentially useful features. Limited scalability: When the amount of data is large or the dimension is high, traditional methods may become computationally expensive and ineffective, especially when processing large-scale streaming data. Low model flexibility: Traditional models may have difficulty adapting to changes in data distribution, such as concept drift, which is a major challenge in dynamic environments. Difficulty in processing multimodal data: Traditional methods typically focus on a single type of data, such as numerical sequences, and have difficulty effectively integrating information from other modalities such as text and images.
[0029] Compared with traditional time series data processing methods, the time series word vectors obtained by discretizing the time series data and training them in the present invention have obvious advantages.
[0030] Capturing temporal dependencies: Temporal word embeddings can capture patterns in how data changes over time, which is critical for understanding the behavior of dynamic systems. For example, in natural language processing, word embeddings can capture the evolution of sentences over time and help models understand the context of text.
[0031] Efficiency improvement: Converting time series data into fixed-length vectors can significantly improve the efficiency of data processing and analysis. Traditional time series data may be very long, and after vectorization, it can be processed using more efficient machine learning or deep learning algorithms.
[0032] Pattern recognition and prediction: Time-series word embeddings help identify and predict future trends. In fields such as finance, healthcare, and weather forecasting, this capability can help make more accurate predictions.
[0033] Anomaly detection: Anomaly detection is an important application in time series data analysis. By learning time series word embeddings of normal behaviors, the model can identify abnormal events that deviate from normal patterns.
[0034] Data Compression: Vectorization can be thought of as a form of data compression that reduces storage requirements and speeds up data retrieval while retaining critical information.
[0035] Cross-domain applications: Time series word embedding is not limited to text data, but can also be applied to various types of time series data, such as sensor data, stock market data, biological signals, etc., thereby promoting cross-domain knowledge transfer and model reuse.
[0036] Improves model generalization: By learning word embeddings at different time points, the model can generalize better to unseen data, especially when dealing with data with seasonal or other cyclical patterns.
[0037] Support complex query and analysis: In time series databases, time series word vectors can support complex query and analysis tasks, such as similarity search, clustering, classification, etc.
[0038] Specifically, the present invention can be implemented by Python language with the help of pandas, numpy, and scipy libraries, including: Data preprocessing module: First, preprocess the time series data, including completing the time series data, normalizing it, and splicing different time series data together to form a large time series data; then use the rolling window to split the time series data into several data segments and combine them into a two-dimensional array, that is, process the one-dimensional array into a two-dimensional array; this module implements data processing through the pandas and numpy libraries.
[0039] Data clustering module: The data is processed in batches, and each batch of data is clustered once to obtain a primary cluster and a primary cluster center; then, the primary cluster centers of different batches of data are put together for secondary clustering, and the distance threshold is set to half of the distance threshold during the primary clustering for re-clustering; finally, based on the secondary clustering results of the primary cluster center, the samples corresponding to the primary cluster center are merged to form the final cluster cluster and cluster center.
[0040] Dictionary construction module: The clusters of the final clustering results are labeled with cluster labels. If the distance between the elements of each cluster is small enough, the cluster center of the cluster can approximately represent the elements in the cluster. Because each cluster center has its own cluster label, the different data segments of the entire time series data are replaced by the cluster labels of the clusters to which the data segments belong, thus realizing the discretization of time series data. Construct a dictionary about time series data. Each cluster center can be mapped to a word in the dictionary, the number of samples in the cluster is mapped to the frequency of the word in the dictionary, and the cluster label marked by the cluster center is mapped to the ID of the word.
[0041] Time series word embedding training module: After the time series data is discretized, each data segment in the time series data is replaced with the corresponding cluster label to obtain a corpus formed by cluster labels; construct training data and input it into the SkipGram network for training; obtain the time series word embedding.
[0042] As a specific embodiment, acquiring time series data and performing segmentation processing using a window to obtain a two-dimensional array includes: Normalize and concatenate different types of time series data; The spliced time series data is segmented into several data segments by using a rolling window method, and each data segment is used as a row to form a two-dimensional array, and the number of columns of the two-dimensional array is the size of the rolling window.
[0043] Specifically, first obtain complete time series data through data completion tools and normalize them, and then splice different types of time series data together to construct a large time series data. This splicing of different types of time series data can make time series word vectors not only limited to text data, but also applicable to various types of time series data, such as sensor data, stock market data, biological signals, etc., thereby promoting cross-domain knowledge transfer and model reuse.
[0044] After the time series data is concatenated, the time series data is segmented into several data segments using a rolling window, and each data segment is used as a row to form a two-dimensional array. The window size p of the rolling window can be set according to actual needs. For time series data of length p*q, q data segments can be obtained after segmentation by a rolling window of size p, thereby processing to obtain a two-dimensional array of q rows and p columns.
[0045] Converting time series data into vectors of fixed length can significantly improve the efficiency of data processing and analysis. When obtaining a two-dimensional array corresponding to the complete time series data, since the length of the time series data is very long, it corresponds to clustering and discretization of massive data. Therefore, in the present invention, it is necessary to divide the two-dimensional array of the complete time series data into several batches, and perform clustering in batches. After clustering once to reduce the number of samples, a second clustering is performed based on the first clustering result, and the final clustering result is obtained by merging.
[0046] As a specific embodiment, the process of obtaining the final clustering result includes: The two-dimensional array is divided into several batches, and each batch is clustered once to obtain the primary clusters and primary cluster centers of the batch; a new two-dimensional array is formed with all the primary cluster centers, and secondary clustering is performed to obtain secondary clusters and secondary cluster centers; all the data corresponding to each secondary cluster are merged, and the cluster centers are recalculated to obtain the final clustering result.
[0047] It should be noted that the methods of primary clustering and secondary clustering in the present invention are the same, both of which cluster the two-dimensional array; the difference is that primary clustering is to cluster each batch of the original two-dimensional array into several batches to obtain primary cluster clusters and primary cluster centers; and secondary clustering is to cluster the new two-dimensional array formed by the primary cluster centers. For massive time series data, primary clustering can reduce the number of samples, and secondary clustering can merge the results of primary clustering to obtain the final clustering result.
[0048] Furthermore, the process of clustering any two-dimensional array includes: Calculate the distance similarity between the vector corresponding to each row of the two-dimensional array M and all vectors to obtain the two-dimensional array D; Traverse each column of distance cluster Di in D to obtain the distance cluster Dmax with the largest number of data that satisfy the distance similarity less than the distance threshold d; form a cluster Ci with the data in Dmax whose distance similarity is less than d and obtain the cluster center CCi; Eliminate the data in Ci from M to form a new two-dimensional array M for clustering until the number of data in M is 1.
[0049] Specifically, first divide the two-dimensional array of complete time series data into several batches, and perform clustering on each batch: for any batch of two-dimensional arrays M (n*m), where m represents the window size of the rolling window segmentation, and n represents the number of data segments in each batch when the two-dimensional array is divided into batches (corresponding to the number of rows of the two-dimensional array). When calculating the distance similarity of the two-dimensional array, each row of data segments in the two-dimensional array M can be used as a vector, and the distance similarity of any row vector and other row vectors including itself can be calculated to obtain n*1 distance clusters, and the distance clusters of each vector are combined to obtain a two-dimensional array D representing the distance similarity.
[0050] Set the distance threshold d, traverse each distance cluster Di in the two-dimensional array D, calculate the number of elements in each distance cluster Di that satisfy the distance similarity less than the threshold distance d, and thus obtain the distance cluster Dmax with the largest number of elements that satisfy the distance similarity less than the distance threshold d.
[0051] The data corresponding to all elements in the obtained distance cluster Dmax whose distance similarity is less than the distance threshold d are formed into a primary cluster C1i, and the cluster center CC1i of the cluster is calculated. The data in the clustered primary cluster C1i is removed from the two-dimensional array M to form a new two-dimensional array M to be clustered. The distance similarity is recalculated with the new two-dimensional array M to be clustered to obtain a new two-dimensional array D. The clustering process is repeated to obtain different primary clusters and primary cluster centers until all primary clustering is completed when the amount of data in the newly generated two-dimensional array M is 1.
[0052] After completing all the primary clustering of the two-dimensional array of the complete time series data, the primary clustering centers are combined to form a new two-dimensional array M'(w*m), where w is the number of primary clustering clusters, and each row of the two-dimensional array M' corresponds to a data segment of the primary clustering center. The method of secondary clustering of the two-dimensional array M' is the same as the primary clustering. Each row of the data segment in the two-dimensional array M' is taken as a vector, and the distance similarity of any row of vectors and other row vectors including itself is calculated to obtain n*1 distance clusters. The distance clusters of each vector are combined to obtain a two-dimensional array D' representing the distance similarity.
[0053] Set the distance threshold d', traverse each distance cluster D'i in the two-dimensional array D', calculate the number of elements in each distance cluster D'i that satisfy the distance similarity less than the threshold distance d', and thus obtain the distance cluster D'max with the largest number of elements that satisfy the distance similarity less than the distance threshold d'.
[0054] The data corresponding to all elements in the obtained distance cluster D'max whose distance similarity is less than the distance threshold d' are formed into a secondary clustering cluster C2i, and the cluster center CC2i of the clustering cluster is calculated. The data in the clustered secondary clustering cluster C2i is removed from the two-dimensional array M' to form a new two-dimensional array M' to be clustered. The distance similarity is recalculated with the new two-dimensional array M' to be clustered to obtain a new two-dimensional array D', and the clustering process is repeated to obtain different secondary clustering clusters and secondary clustering centers until the amount of data in the newly generated two-dimensional array M' is 1 and the secondary clustering is completed.
[0055] After completing the secondary clustering, all the data corresponding to each secondary cluster are merged, and the cluster center is recalculated to obtain the final clustering result: Traverse all secondary clusters, and for each secondary cluster, merge all the data in the primary cluster to which the primary cluster center corresponding to the samples in the cluster belongs into a cluster of the final clustering result, and recalculate the cluster center of the cluster.
[0056] It should be noted that, because the secondary clustering is the clustering of the two-dimensional array M' composed of all the primary cluster centers, the samples in each secondary cluster are actually several primary cluster centers. The primary cluster center here represents all the data in the corresponding primary cluster. Therefore, when performing the merge calculation, all the data in the primary cluster to which the primary cluster center in the secondary cluster belongs need to be merged into a new cluster, and the cluster center of the cluster is calculated with these merged data. In the final clustering result obtained in this way, the number of clusters is the same as the number of secondary clusters.
[0057] Furthermore, calculating the distance similarity between the vector corresponding to each row of the two-dimensional array M and all vectors includes: respectively calculating the absolute value of the mean difference, the absolute value of the standard deviation, and the absolute value of the forward differential inclination difference of the two vectors; and summing the calculation results of the three absolute values to obtain the distance similarity between the two vectors.
[0058] Specifically, taking vectors u and v as an example, the absolute value of the mean difference between the two vectors is: ave=abs(mean(u)-mean(v)) The absolute value of the standard deviation of two vectors is: std = abs(std(u) - std(v)) The absolute value of the forward differential inclination difference between the two vectors is: atan=abs(arctan(u[-1]-u[0])-arctan(v[-1]-v[0])) Where abs() represents the absolute value calculation function, mean() represents the mean calculation function, std() represents the standard deviation calculation function, arctan() represents the inverse tangent calculation function, u[-1] and v[-1] represent the last element of the two vectors, and u[0] and v[0] represent the first element of the two vectors. The distance similarity of two vectors is expressed as: dist=ave+std+atan The distance similarity calculation method of the present invention fully considers the characteristics of time series data, including the mean, standard deviation, and whether the data trend is rising or falling. Compared with the existing distance similarity calculation methods such as Euclidean distance and Manhattan distance, it not only considers the size of the data itself, but also considers the mining of the deep value of the data.
[0059] Furthermore, the setting of the distance threshold d includes: Calculate the mean of all elements in the two-dimensional array D, and multiply the mean of all elements in D by the set ratio to obtain the distance threshold d.
[0060] It should be noted that for each batch of clusters in the first clustering, the corresponding distance threshold d must be determined based on its two-dimensional array D, that is, the distance threshold d corresponding to different batches of first clustering may be different. For the second clustering, the corresponding distance threshold d' needs to be determined based on its two-dimensional array D'. In a specific embodiment of the present invention, the distance threshold d can be obtained by multiplying the mean of all elements in the two-dimensional array D by one sixteenth, or it can be verified and determined according to actual needs.
[0061] As a specific embodiment, constructing a time series data dictionary with cluster centers and cluster clusters of the final clustering result includes: sorting the cluster clusters in the final clustering result from large to small according to the number of samples in the clusters, and marking cluster labels from small to large according to the sorting results; in this way, cluster clusters with a large number of samples are marked with small cluster labels, and cluster clusters with a small number of samples are marked with large cluster labels; this is consistent with the rules of the dictionary in the language model; The cluster center of each cluster is mapped to the word in the dictionary, the number of samples in the cluster is mapped to the word frequency in the dictionary, and the cluster label is mapped to the word ID to form an overall time series data dictionary.
[0062] Furthermore, discretization processing of time series data based on the time series data dictionary includes: For time series data, several data segments are obtained by using windows to split them; Traverse all data segments and replace the data segment with the cluster label of the cluster to which the data segment belongs.
[0063] Since the distance between the elements of each cluster is small enough, the cluster center of the cluster can approximately represent the elements in the cluster. Therefore, the different data segments of the entire time series data can be replaced by the cluster labels of the cluster center of the cluster to which the data segment belongs, thus realizing the discretization of the time series data.
[0064] Furthermore, the word vector training based on the discretized time series data to obtain the time series word vector includes: The discretized time series data is converted into a corpus formed by cluster labels; training data is constructed and input into the SkipGram network for training to obtain time series word vectors.
[0065] Specifically, first define the skip-gram training network structure, and use binary_cross_entropy_with_logits to calculate the loss function; secondly, after completing the network definition, start the model training, and print the loss function loss every 100 steps to ensure that the current network is converged; observe the similar words calculated by skip-gram every 1000 steps; finally, visualize the network training effect. The process of sequential word vector training in the present invention draws on the existing word vector training process, which can be directly obtained through the existing word vector training process, so it is not described in detail.
[0066] In an embodiment of the present invention, the following is selected: Figure 2 The user load data of a special transformer with 96 load points in one month and 31 days is shown, with a total of 2976 points. The data is divided into 744 clustered data points according to a 1-hour time window (window size is 4) to form a two-dimensional array, and clustered using the clustering algorithm of the present invention, setting the cluster size threshold to 1 (i.e., the number of samples in the two-dimensional array M that determines the completion of clustering during the clustering process), and the distance threshold to 0.06, and the result is automatically divided into 108 categories (i.e., 108 clusters are obtained after clustering).
[0067] like Figure 3-Figure 7 It is a typical result with a higher proportion among the 108 clusters obtained by clustering. Figure 3 The middle shows the load curve with lower electricity consumption, the left side shows the curve of each sample in the cluster, and the right side shows the curve of the cluster center, which occupies 289 of the total 744 samples. Figure 4 The middle shows the load curve with electricity consumption centered, the left side shows the curve of each sample in the cluster, and the right side shows the curve of the cluster center, which occupies 16 of the total 744 samples. Figure 5 The middle represents the load curve with higher electricity consumption, the left diagram shows the curve of each sample in the cluster, and the right is the curve of the cluster center, which occupies 13 of the total 744 samples. Figure 6The middle shows the load curve of electricity consumption, the left side shows the curve of each sample in the cluster, and the right side shows the curve of the cluster center, which occupies 7 of the total 744 samples. Figure 7 The figure shows the load curve of the downward trend of electricity consumption. The left figure shows the curve of each sample in the cluster, and the right figure shows the curve of the cluster center, which occupies 7 of the total 744 samples.
[0068] After completing the clustering of the time series data and obtaining 108 clusters, each cluster is arranged from large to small according to the number of samples in the cluster, and the cluster labels from 1 to 108 from small to large are marked in the order of arrangement. The time series data dictionary is constructed with the cluster center and cluster of the final clustering result, and the user load data is discretized. The time series word vector of the user load is obtained by training based on the discretization result.
[0069] The above embodiments are further elaborations and illustrations of the present invention for ease of understanding, and are not limitations of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A vectorized word segmentation method based on time series data, characterized in that: include: Get the time series data and use the window to split it to get a two-dimensional array; Perform clustering on the two-dimensional array in batches, and perform secondary clustering based on the results of the first clustering of all batches to obtain the final clustering results; Construct a time series data dictionary based on the cluster centers and cluster clusters of the final clustering results; Discretize time series data based on the time series data dictionary; The word vector is trained based on the discretized time series data to obtain the time series word vector.
2. According to the vectorized word segmentation method based on time series data in claim 1, it is characterized in that: The step of acquiring the time series data and performing segmentation processing using a window to obtain a two-dimensional array includes: Normalize and concatenate different types of time series data; The spliced time series data is segmented into several data segments by using a rolling window method, and each data segment is used as a row to form a two-dimensional array, and the number of columns of the two-dimensional array is the size of the rolling window.
3. A vectorized word segmentation method based on time series data according to claim 1 or 2, characterized in that: The process of obtaining the final clustering result includes: Divide the two-dimensional array into several batches, perform clustering on each batch to obtain the primary cluster and primary cluster center of the batch; A new two-dimensional array is formed with all the primary clustering centers, and secondary clustering is performed to obtain secondary clustering clusters and secondary clustering centers; All the data corresponding to each secondary cluster are merged, and the cluster center is recalculated to obtain the final clustering result.
4. According to the vectorized word segmentation method based on time series data of claim 3, it is characterized in that: The methods of the first clustering and the second clustering are the same; the process of clustering any two-dimensional array includes: Calculate the distance similarity between the vector corresponding to each row of the two-dimensional array M and all vectors to obtain the two-dimensional array D; Traverse each column of distance cluster Di in D to obtain the distance cluster Dmax with the largest number of data that satisfy the distance similarity less than the distance threshold d; form a cluster Ci with the data in Dmax whose distance similarity is less than d and obtain the cluster center CCi; Eliminate the data in Ci from M to form a new two-dimensional array M for clustering until the number of data in M is 1.
5. A vectorized word segmentation method based on time series data according to claim 1, 2 or 4, characterized in that: The method of constructing a time series data dictionary based on the cluster centers and cluster clusters of the final clustering results includes: Sort the clusters in the final clustering result from large to small according to the number of samples in the cluster, and mark the cluster labels from small to large according to the sorting results; The cluster center of each cluster is mapped to the word in the dictionary, the number of samples in the cluster is mapped to the word frequency in the dictionary, and the cluster label is mapped to the word ID.
6. According to the vectorized word segmentation method based on time series data in claim 5, it is characterized in that: The discretization processing of the time series data based on the time series data dictionary includes: For time series data, several data segments are obtained by using windows to split them; Traverse all data segments and replace the data segment with the cluster label of the cluster to which the data segment belongs.
7. According to the vectorized word segmentation method based on time series data in claim 4, it is characterized in that: The calculation of the distance similarity between the vector corresponding to each row of the two-dimensional array M and all vectors includes: The absolute value of the mean difference, the absolute value of the standard deviation, and the absolute value of the forward difference inclination difference of the two vectors are calculated respectively; the calculation results of the three absolute values are summed up to obtain the distance similarity between the two vectors.
8. A vectorized word segmentation method based on time series data according to claim 4 or 7, characterized in that: The setting of the distance threshold d includes: Calculate the mean of all elements in the two-dimensional array D, and multiply the mean of all elements in D by the set ratio to obtain the distance threshold d.
9. According to the vectorized word segmentation method based on time series data in claim 3, it is characterized in that: The step of merging all the data corresponding to each secondary cluster and recalculating the cluster center to obtain the final clustering result includes: Traverse all secondary clusters, and for each secondary cluster, merge all the data in the primary cluster to which the primary cluster center corresponding to the samples in the cluster belongs into a cluster of the final clustering result, and recalculate the cluster center of the cluster.
10. A vectorized word segmentation method based on time series data according to claim 1 or 2 or 4 or 6 or 7 or 9, characterized in that: The word vector training based on the discretized time series data to obtain the time series word vector includes: The discretized time series data is converted into a corpus formed by cluster labels; training data is constructed and input into the SkipGram network for training to obtain time series word vectors.
Citation Information
Patent Citations
Time scale-oriented distribution transformer heavy overload judgment method
CN110457770A