Heterogeneous time series data processing method, device and electronic equipment
By aligning and aggregating heterogeneous time-series data, long-term and short-term feature vectors are determined, solving the noise problem in mixed modeling of heterogeneous time-series data and achieving more comprehensive data representation and accurate modeling.
Patent Information
- Application Number
- CN202211130297.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-16
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2042-09-16
AI Technical Summary
Due to differences in source and structure, heterogeneous time series data can introduce noise when directly mixed and applied, affecting the modeling effect.
Heterogeneous time series data are aligned to convert them into homogeneous time series data. Homogeneous sequences with the same object ID are then selected. By aggregating categorical and numerical vectors, target vectors for long-term stationary features and short-term fluctuation features are determined for model training.
By effectively utilizing the interactive information between heterogeneous time-series data, information loss can be reduced, accurate modeling can be achieved, and the data representation capability of the model can be improved.
Smart Images

Figure CN117762981B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data mining, and in particular to methods, apparatus and electronic devices for processing heterogeneous time-series data. Background Technology
[0002] In many current application scenarios, heterogeneous time-series data is frequently encountered. Heterogeneous time-series data broadly refers to time-series data with different data sources and structures (e.g., different data dimensions, different data content). For example, time-series data showing the access of a specific app (representing the app's access at different points in time), time-series data showing the execution of a specific operation on a specific object (e.g., an account being transferred funds) (representing the specific operation performed on the specified object at different points in time), and time-series data from image devices such as cameras (representing the state of the image device at different points in time) can all be considered heterogeneous time-series data.
[0003] In current applications, the differences between various heterogeneous time-series data lead to noise when these data are directly mixed together. For example, directly using the aforementioned heterogeneous time-series data for modeling (such as training a model) will introduce noise due to the inherent differences between the heterogeneous time-series data, affecting the modeling results. Summary of the Invention
[0004] This application discloses a method, apparatus, and electronic device for processing heterogeneous time-series data, in order to avoid noise introduced by the inherent differences in heterogeneous time-series data.
[0005] This application provides a method for processing heterogeneous time-series data, the method comprising:
[0006] The obtained heterogeneous time-series data are aligned to convert them into homogeneous time-series data; the heterogeneous time-series data contains at least data records with different object IDs and / or the same object ID at different time points.
[0007] Isomorphic sequences corresponding to the same object ID are selected from each isomorphic time series data. The isomorphic sequence corresponding to each object ID is obtained by arranging the data records of each time point belonging to that object ID in chronological order. Each data record at each time point contains a categorical vector Xc and a numerical vector Xn. The dimension of Xc is c*1, where c represents the number of categorical data in the data record, and the dimension of Xn is n*1, where n represents the number of numerical data in the data record.
[0008] For each data record at each time point in the isomorphic sequence corresponding to each object ID, the categorical vector Xc and the numerical vector Xn in the data record are aggregated to obtain the aggregated vector corresponding to the data record.
[0009] For each isomorphic sequence corresponding to an object ID, a first target vector and a second target vector are determined based on the aggregate vector corresponding to the data records at each time point in the isomorphic sequence. The first target vector is used to represent the vector of long-term stationary characteristics, and the second target vector is used to represent the vector of short-term fluctuation characteristics. The first target vector and the second target vector are used to replace the data records in the isomorphic sequence for model training, so as to train a target model for performing data processing.
[0010] This application provides a heterogeneous time-series data processing apparatus, the apparatus comprising:
[0011] The alignment unit is used to perform data alignment processing on the obtained heterogeneous time series data so as to convert the heterogeneous time series data into homogeneous time series data.
[0012] The filtering unit is used to filter out isomorphic sequences corresponding to the same object ID from each isomorphic time series data. The isomorphic sequence corresponding to each object ID is obtained by arranging the data records of each time point belonging to that object ID in chronological order. Each data record at each time point contains a categorical vector Xc and a numerical vector Xn. The dimension of Xc is c*1, where c represents the number of categorical data in the data record, and the dimension of Xn is n*1, where n represents the number of numerical data in the data record.
[0013] The aggregation unit is used to aggregate the categorical vector Xc and the numerical vector Xn in the data record of each time point in the isomorphic sequence corresponding to each object ID, so as to obtain the aggregated vector corresponding to the data record.
[0014] The processing unit is used to determine a first target vector and a second target vector for each isomorphic sequence corresponding to an object ID, based on the aggregate vector corresponding to the data records at each time point in the isomorphic sequence. The first target vector is used to represent a vector of long-term stable characteristics, and the second target vector is used to represent a vector of short-term fluctuation characteristics. The first target vector and the second target vector are used to train a model on behalf of the data records in the isomorphic sequence to train a target model for performing data processing.
[0015] This application provides an electronic device, which includes: a processor and a machine-readable storage medium;
[0016] The machine-readable storage medium is used to store machine-executable instructions;
[0017] The processor is configured to read and execute machine-executable instructions stored in the machine-readable storage medium to implement the steps in the method described above.
[0018] As can be seen from the above description, in this embodiment, different heterogeneous time series data are not directly mixed together for application such as modeling and training. Instead, the heterogeneous time series data are first aligned to convert them into homogeneous time series data. Then, homogeneous sequences corresponding to the same object ID are selected from the homogeneous time series data. For each homogeneous sequence corresponding to an object ID, the aggregation vector corresponding to the data record at each time point in the homogeneous sequence is first determined. Based on the aggregation vector corresponding to the data record at each time point, the first target vector and the second target vector are determined. Finally, different vectors of the same type (such as the first target vector and the second target vector) are determined. Then, the first target vector and the second target vector can be used to replace the data records in the homogeneous sequence for model training to train the target model for performing data processing. This realizes the modeling of homogeneous time series data and avoids the noise introduced by the differences in heterogeneous time series data itself.
[0019] Furthermore, in this embodiment, since heterogeneous time-series data is converted into homogeneous time-series data and mixed together for modeling, the interaction information between different time-series data can be effectively utilized for modeling, reducing information loss.
[0020] Furthermore, in this embodiment, a first target vector representing long-term stable characteristics and a second target vector representing short-term fluctuation characteristics are ultimately determined for model training. This use of vectors representing long-term and short-term characteristics enables a more comprehensive representation of the data and achieves the goal of accurate modeling. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of this specification.
[0022] Figure 1 A flowchart illustrating the method provided in this application embodiment;
[0023] Figure 2 A flowchart illustrating the implementation of step 103 in an embodiment of this application;
[0024] Figure 3 A flowchart illustrating the implementation of step 104 in an embodiment of this application;
[0025] Figure 4 This is a schematic diagram of the device structure provided in the embodiments of this application;
[0026] Figure 5 This is a schematic diagram of the hardware structure of the device provided in the embodiments of this application. Detailed Implementation
[0027] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0028] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0029] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0030] To enable those skilled in the art to better understand the technical solutions provided in the embodiments of this application, and to make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the technical solutions in the embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0031] See Figure 1 , Figure 1 This is a flowchart illustrating a method provided in an embodiment of this application. The method is applied to an electronic device. As one embodiment, the electronic device may be a PC or similar device; this embodiment is not specifically limited to this.
[0032] like Figure 1 As shown, the process may include the following steps:
[0033] Step 101: Perform data alignment processing on the obtained heterogeneous time series data to convert the heterogeneous time series data into homogeneous time series data.
[0034] Optionally, in this embodiment, corresponding time-series data can be mined from different sources, such as time-series data formed by account data of different users at different points in time mined from banking applications, time-series data formed by consumption data of different users at different points in time mined from a certain commodity consumption application, time-series data formed by access data of the specified APP being accessed by different users at different points in time mined from a specified APP such as a ride-hailing software, etc., and this embodiment is not specifically limited.
[0035] In this embodiment, at least two of the time series data obtained above have different structures. For example, the time series data mined from banking applications contains data corresponding to 6 different types of fields, the time series data mined from a certain product consumption application contains data corresponding to 5 different types of fields, the time series data mined from a specific APP such as a ride-hailing software contains data corresponding to 4 different types of fields, and so on.
[0036] For ease of description, this embodiment refers to the time-series data with different structures as heterogeneous time-series data. Based on the above description, each heterogeneous time-series data contains at least different object IDs (such as users) and / or data records of the same object ID (such as users) at different points in time, such as account data.
[0037] As an example, the aforementioned time-series data (also known as heterogeneous time-series data) can be represented by a corresponding data table. For instance, the data table corresponding to the time-series data mined from banking applications contains data corresponding to six different types of fields.
[0038] In this embodiment, the above-mentioned data alignment process is performed on the obtained heterogeneous time series data to convert them into homogeneous time series data. There are many ways to implement this process. For example, a vertical stacking method can be used to process the data tables corresponding to the heterogeneous time series data so that the data tables corresponding to the heterogeneous time series data have the same data structure.
[0039] As an example, there are many ways to process the data tables corresponding to heterogeneous time-series data using a vertical stacking approach. For instance, one could first summarize the type fields in the data tables corresponding to the heterogeneous time-series data to obtain a candidate type field set; then, deduplicate the candidate type field set to remove duplicate type fields, resulting in a target type field set; finally, for each data table corresponding to the heterogeneous time-series data, a new type field is added to the table (the new type field refers to a type field in the target type field set that is not already present in the data table), and the data corresponding to the new type field is empty. In this way, the data tables corresponding to the heterogeneous time-series data ultimately have the same data structure (all containing type fields from the target type field set), achieving alignment of the heterogeneous time-series data.
[0040] Step 102: Filter out the isomorphic sequences corresponding to the same object ID from each isomorphic time series data.
[0041] As an example, data records belonging to the same object ID at different time points can be arranged according to time order, such as from beginning to end, to obtain an isomorphic sequence corresponding to that object ID. Optionally, in this embodiment, based on the alignment process described above, the data records of any two object IDs obtained here at any time point have the same structure, for example, both contain data corresponding to each type field in the target type field set mentioned above (although the data corresponding to some type fields is null).
[0042] In this embodiment, each data record at any given time point contains a categorical vector (denoted as Xc) and a numerical vector (denoted as Xn). Xc has a dimension of c*1, where c represents the number of categorical data points in the record. Xn has a dimension of n*1, where n represents the number of numerical data points in the record. For example, if a data record contains five data types: A, B, C, D, and E, where A and B are categorical data (c = 2) and C, D, and E are numerical data (n = 3), then categorical data refers to data distinguished by categories, such as male or female. Numerical data refers to data distinguished by numerical values, such as transfer amounts of 100 or 1000.
[0043] Step 103: For each time point data record in each isomorphic sequence, aggregate the categorical vector Xc and the numerical vector Xn in the data record to obtain the aggregated vector corresponding to the data record.
[0044] As an example, step 103 can be implemented using pooling aggregation in the attention mechanism, as described below. Figure 2Examples have been provided, and will not be repeated here.
[0045] Step 104: For each isomorphic sequence, determine the first target vector and the second target vector based on the aggregation vector corresponding to the data records at each time point in the isomorphic sequence; the first target vector is used to represent the vector of long-term stationary characteristics, and the second target vector is used to represent the vector of short-term fluctuation characteristics; the first target vector and the second target vector are used to replace the data records in the isomorphic sequence for model training, so as to train the target model for performing data processing.
[0046] Optionally, in this embodiment, step 104 can utilize multiple semantic spaces and a self-attention mechanism to capture the interaction information between heterogeneous sequences, automatically learning the correlation between different types of sequences, reducing information loss from separate processing, and finally aggregating sequence information through the design of long-term and short-term features (queries) to obtain a first target vector and a second target vector. These first and second target vectors are then used to replace the data records in the homogeneous sequence for model training, training a target model for data processing, such as a classification model for image classification. The specific implementation of step 104 is illustrated below and will not be elaborated upon here.
[0047] This concludes the process. Figure 1 The process is shown below.
[0048] pass Figure 1 As can be seen from the process shown, in this embodiment, the heterogeneous time series data is not directly modeled. Instead, the heterogeneous time series data is first aligned to convert them into homogeneous time series data. Then, homogeneous sequences corresponding to the same object ID are selected from the homogeneous time series data. For each homogeneous sequence corresponding to an object ID, the aggregation vector corresponding to the data record at each time point in the homogeneous sequence is first determined. Based on the aggregation vector corresponding to the data record at each time point, the first target vector and the second target vector are determined. The first target vector and the second target vector are used to replace the data records in the homogeneous sequence for model training to train the target model for performing data processing. This achieves the modeling of homogeneous time series data and avoids the noise introduced by the differences in the heterogeneous time series data itself.
[0049] Furthermore, in this embodiment, since heterogeneous time-series data is converted into homogeneous time-series data and mixed together for modeling, the interaction information between different time-series data can be effectively utilized for modeling, reducing information loss.
[0050] Furthermore, in this embodiment, a first target vector representing long-term stable characteristics and a second target vector representing short-term fluctuation characteristics are ultimately determined for model training. This use of vectors representing long-term and short-term characteristics enables a more comprehensive representation of the data and achieves the goal of accurate modeling.
[0051] The following describes step 103 above:
[0052] See Figure 2 , Figure 2 This is a flowchart illustrating the implementation of step 103 in an embodiment of this application. Optionally, in this embodiment, step 103 is implemented using an attention mechanism combined with a mask, eliminating the need to fill in null values during the data alignment process and avoiding the introduction of manual intervention. The following section... Figure 2 The process is described as follows:
[0053] like Figure 2 As shown, the process may include the following steps:
[0054] Step 201: For each time point data record in the isomorphic sequence corresponding to each object ID, the categorical field vector Xc of dimension c*1 is converted into a categorical coding matrix Ect of dimension c*d using a pre-set categorical variable coding table; and the numerical variable baseline coding table and the numerical variable bias coding table are used to perform vector embedding on the numerical field vector Xn of dimension n*1 to obtain a numerical coding matrix Ent of dimension n*d.
[0055] Optionally, in this embodiment, for each time point in the isomorphic sequence corresponding to each object ID, a categorical field vector Xc with dimension c*1 is obtained from the data record. For each character in the categorical field vector Xc, the corresponding code is determined in the pre-set categorical variable encoding table, ultimately resulting in a categorical encoding matrix Ect with dimension c*d. Taking the categorical variable encoding table as a lookup encoding table as an example, Ect can be expressed by the following formula: Ect = Embedding_lookup(Xc, Wc). Wherein, Wc is the aforementioned categorical variable lookup encoding table, used to convert the categorical field vector Xc with dimension c*1 into a categorical encoding matrix Ect with dimension c×d, and d is the preset embedding dimension.
[0056] Optionally, in this embodiment, the aforementioned numerical variable baseline coding table can be a baseline coding table randomly generated initially, or an optimized baseline coding table; this embodiment is not specifically limited to either. Similarly, the numerical variable bias coding table can be a bias coding table randomly generated initially, or an optimized bias coding table.
[0057] Optionally, in this embodiment, a specified operation, such as multiplication, can be performed on the values in the numeric field vector Xn of dimension n*1 and the numeric variable bias encoding table to obtain the specified operation result. Then, the specified operation result is added to the numeric variable baseline encoding table to finally achieve vector embedding of the numeric field vector Xn, resulting in an n*d-dimensional numeric encoding matrix Ent. In this embodiment, Wn_base represents the numeric variable baseline encoding table with dimension n*d, and Wn_bias represents the numeric variable bias encoding table with dimension n*d. Taking multiplication as an example, the specified operation is Ent, which can be expressed by the following formula: Ent = Wn_base + Xn * Wn_bias. It can be seen that in this embodiment, when modeling heterogeneous time series data, not only the vector embedding of categorical variables (denoted as the categorical encoding matrix Ect) is considered, but also the vector embedding of numeric variables (i.e., the numeric encoding matrix Ent) is considered, ensuring the integrity of the data.
[0058] Step 202: Process the category encoding matrix Ect and the numerical encoding matrix Ent using the mask method to obtain a dense matrix Et with dimension (c+n)*d; perform aggregation operation on the dense matrix Et according to the configured attention mechanism for aggregation to obtain the aggregation vector corresponding to the data record.
[0059] As an example, the above-mentioned processing of the category coding matrix Ect and the numerical coding matrix Ent using the Mask method to obtain a dense matrix Et with dimension (c+n)*d may include: performing corresponding operations on the numerical coding matrix Ent and the category coding matrix Ect using a first specified function to obtain a first operation result; performing Mask processing on the first operation result to obtain a second operation result; and determining the dense matrix Et with dimension (c+n)*d based on the second operation result.
[0060] Optionally, in this embodiment, the first specified function can be the CONCAT function (a function used to combine text or other content from different matrices or cells without using separators). Based on this, the dense matrix Et can be represented by the following formula:
[0061] Et = Mask(Concat(Ent, Ect)).
[0062] Optionally, in this embodiment, after obtaining the dense matrix Et, a pooling aggregation operation can be performed on the dense matrix Et to obtain the dense representation (also called the aggregated vector corresponding to the data record) of the data record. The pooling aggregation operation here can be performed using an attention mechanism. See step 203 below for details.
[0063] Step 203: Perform aggregation operation on the dense matrix Et according to the configured attention mechanism for aggregation to obtain the aggregation vector corresponding to the data record.
[0064] Optionally, in this embodiment, there are many ways to perform aggregation operations on the dense matrix Et according to the configured attention mechanism for aggregation. For example, the corresponding operation is performed on the numerical variable baseline encoding table and the category encoding matrix Ect using the first specified function to obtain the third operation result; the dense matrix Et and the third operation result are input to the configured attention mechanism to obtain the output result of the attention mechanism; and the aggregation vector corresponding to the data record is determined based on the output result of the attention mechanism.
[0065] As an example, if the first specified function is the Contact function, then the third operation result (denoted as Kt) can be expressed by the following formula: Kt = Concat(Wn_base, Ect).
[0066] As an example, the above attention mechanism can be an m-head attention mechanism, as detailed below:
[0067]
[0068] Among them, attscore i (k,q)=softmax((W ki k)·q). Considering the m-head attention mechanism, taking the i-th head as an example, W ki W vi q i These represent the d*d Key transformation matrix, d*d Value transformation matrix, and d*1 attention query vector in the i-th aggregation unit, respectively.
[0069] Based on the above m-head attention mechanism, determining the aggregate vector corresponding to the data record based on the output of the attention mechanism can include: taking the d*1 dimension vector h output by one of the heads. i As the aggregation vector corresponding to the aforementioned data records, that is, the final (c+n)*d Et above is transformed into a d*1 vector h. i Alternatively, output the vector h of dimension d*1 from the m-head. m The final md*1 dimensional vector H is obtained by concatenating the elements using the concat function (H = concat(h1, h2, ..., h...). m This embodiment is not specifically limited to these terms.
[0070] This concludes the process. Figure 2 The process is shown below.
[0071] pass Figure 2The process shown demonstrates how to determine the aggregation vector corresponding to each data record at each time point in the isomorphic sequence corresponding to each object ID.
[0072] The following describes how, in step 104, the first and second target vectors are determined based on the aggregated vectors corresponding to the data records at each time point in the isomorphic sequence corresponding to each object ID:
[0073] See Figure 3 , Figure 3 A flowchart illustrating the implementation of step 104 in an embodiment of this application. Figure 3 As shown, the process may include the following steps:
[0074] Step 301: For each isomorphic sequence corresponding to an object ID, combine the aggregate vectors corresponding to the data records at each time point in the isomorphic sequence into a first vector sequence.
[0075] In this embodiment, the isomorphic sequence contains data records at L time points. If the aggregate vector corresponding to each data record is a vector with dimension d*1, then the dimension of the first vector sequence is L*d; if the aggregate vector corresponding to each data record is a vector with dimension md*1, then the dimension of the first vector sequence is L*md.
[0076] Step 302: For each set semantic space mapping matrix, the first vector sequence is transformed using the semantic space mapping matrix to obtain a second vector sequence. The second vector sequence is then input into the set self-attention mechanism to obtain sequence interaction information. The self-attention mechanism is used to cross-reference information at different time points.
[0077] In this embodiment, in order to characterize the various semantic information of the heterogeneous time-series data itself, K semantic space mapping matrices can be defined to map the above-mentioned first vector sequence to K semantic spaces, thereby enhancing the model expression. K is greater than or equal to 1.
[0078] Optionally, in this embodiment, for each semantic space mapping matrix, the transformation process described in step 302 is performed on the first vector sequence using the semantic space mapping matrix to obtain a second vector sequence. The dimension of the second vector sequence is the same as that of the first vector sequence. Then, the second vector sequence is input into the pre-set self-attention mechanism to obtain sequence interaction information. Optionally, in this embodiment, the self-attention mechanism can use a multi-layer standard Transformer Encoder structure, utilizing its self-attention mechanism to cross-reference different temporal information with the second vector sequence input to construct sequence interaction information. The final result is the aforementioned sequence interaction information.
[0079] Step 303: Based on the long-term query vector and short-term query vector of the established attention mechanism, the above sequence interaction information is aggregated to obtain a first candidate aggregation vector and a second candidate aggregation vector; based on the first candidate aggregation vector, a first target vector is determined, and based on the second candidate aggregation vector, a second target vector is determined.
[0080] In this embodiment, the aforementioned sequence interaction information is aggregated using an attention mechanism (such as Attention Pooling). To capture both long-term stationary characteristics and short-term fluctuations, a long-term query vector (denoted as q) can be designed. long ) and short-term query vector (denoted as q) short ).
[0081] As an example, q long This can be expressed by the following formula: q long =Mean(E seq );
[0082] As an example, q short This can be expressed by the following formula: q short =last(E seq )-q long ;
[0083] Here, Eseq represents the sequence interaction information mentioned above, Mean represents mean pooling, and last represents taking the aggregation vector corresponding to the data record at the last time point in the sequence interaction information as the pooling vector.
[0084] In attention mechanisms such as attention pooling, the above q is set. long q short The above sequence interaction information is input into an attention mechanism such as attention pooling, based on q long Then the first candidate aggregation vector is obtained, based on q. short Then the second candidate aggregation vector is obtained.
[0085] Subsequently, if the number of semantic space mapping matrices is one, then as an example, the first candidate aggregation vector can be directly determined as the first target vector, and the second candidate aggregation vector can be determined as the second target vector. If the number of semantic space mapping matrices is greater than one, then the first candidate aggregation vectors obtained based on each semantic space mapping matrix are concatenated to obtain the first target vector, and the second candidate aggregation vectors obtained based on each semantic space mapping matrix are concatenated to obtain the second target vector. This ultimately achieves the determination of the first and second target vectors in step 104 above, for each isomorphic sequence corresponding to an object ID, based on the aggregation vectors corresponding to the data records at each time point in the isomorphic sequence.
[0086] This concludes the process. Figure 3 The process is shown below.
[0087] pass Figure 3 The process shown demonstrates how to determine the first target vector and the second target vector based on the aggregate vector corresponding to the data records at each time point in the isomorphic sequence corresponding to each object ID.
[0088] Furthermore, after obtaining the first target vector and the second target vector, the first target vector and the second target vector can be used to replace the corresponding data records for model training, so as to train a target model for performing data processing, such as a classification model or a regression network model for time series data classification.
[0089] Taking the classification model as an example, since this classification model is based on performing operations on various heterogeneous time series data... Figures 1 to 3 The first and second target vectors obtained from the process shown are used for training. The data is relatively sufficient, which can achieve the purpose of accurate modeling and improve the accuracy of the classification model when classifying time series data in the future.
[0090] The methods provided in the embodiments of this application have been described above. The apparatus provided in the embodiments of this application is described below:
[0091] See Figure 4 , Figure 4 This is a structural diagram of the device provided in an embodiment of this application. Figure 4 As shown, the device may include:
[0092] The alignment unit is used to perform data alignment processing on the obtained heterogeneous time series data so as to convert the heterogeneous time series data into homogeneous time series data.
[0093] The filtering unit is used to filter out isomorphic sequences corresponding to the same object ID from each isomorphic time series data. The isomorphic sequence corresponding to each object ID is obtained by arranging the data records of each time point belonging to that object ID in chronological order. Each data record at each time point contains a categorical vector Xc and a numerical vector Xn. The dimension of Xc is c*1, where c represents the number of categorical data in the data record, and the dimension of Xn is n*1, where n represents the number of numerical data in the data record.
[0094] The aggregation unit is used to aggregate the categorical vector Xc and the numerical vector Xn in the data record of each time point in the isomorphic sequence corresponding to each object ID, so as to obtain the aggregated vector corresponding to the data record.
[0095] The processing unit is used to determine a first target vector and a second target vector for each isomorphic sequence corresponding to an object ID, based on the aggregate vector corresponding to the data records at each time point in the isomorphic sequence; the first target vector is used to represent a vector of long-term stable characteristics, and the second target vector is used to represent a vector of short-term fluctuation characteristics; the first target vector and the second target vector are used to train a model on behalf of the data records in the isomorphic sequence to train a target model for performing data processing.
[0096] Optionally, each heterogeneous time series data is represented by a corresponding data table;
[0097] The step of aligning the acquired heterogeneous time-series data includes:
[0098] A vertical stacking method is used to process the data tables corresponding to each heterogeneous time series data so that the data tables corresponding to each heterogeneous time series data have the same data structure.
[0099] Optionally, for each time point in the isomorphic sequence corresponding to each object ID, the aggregation of the categorical vector Xc and the numerical vector Xn in the data record to obtain the aggregated vector corresponding to the data record includes:
[0100] For each time point in the isomorphic sequence corresponding to each object ID, the categorical field vector Xc with dimension c*1 is converted into a categorical coding matrix Ect with dimension c*d using a pre-set categorical variable coding table; and the numerical variable baseline coding table and the numerical variable bias coding table are used to perform vector embedding on the numerical field vector Xn with dimension n*1 to obtain the numerical coding matrix Ent with dimension n*d.
[0101] The category encoding matrix Ect and the numerical encoding matrix Ent are processed using a mask method to obtain a dense matrix Et with dimension (c+n)*d;
[0102] The dense matrix Et is aggregated according to the configured attention mechanism for aggregation to obtain the aggregated vector corresponding to the data record.
[0103] Optionally, the step of processing the category encoding matrix Ect and the numerical encoding matrix Ent using a mask method to obtain a dense matrix Et of dimension (c+n)*d includes:
[0104] The numerical encoding matrix Ent and the category encoding matrix Ect are operated on using a first specified function to obtain a first operation result;
[0105] The first calculation result is masked to obtain the second calculation result;
[0106] Based on the second calculation result, a dense matrix Et with dimension (c+n)*d is determined.
[0107] Optionally, the aggregation operation on the dense matrix Et based on the configured attention mechanism for aggregation to obtain the aggregation vector corresponding to the data record includes:
[0108] The first specified function is used to perform corresponding operations on the numerical variable baseline coding table and the category coding matrix Ect to obtain the third operation result;
[0109] The dense matrix Et and the third operation result are input into the configured attention mechanism to obtain the output result of the attention mechanism. The aggregation vector corresponding to the data record is determined based on the output result of the attention mechanism. The attention mechanism is an m-head attention mechanism, and the aggregation vector corresponding to the data record is a d*1 vector output by one of the heads. Alternatively, the aggregation vector corresponding to the data record is a md*1 vector obtained by concatenating the d*1 vectors output by the m heads.
[0110] Optionally, determining the first target vector and the second target vector for each isomorphic sequence corresponding to an object ID, based on the aggregated vector corresponding to the data records at each time point in the isomorphic sequence, includes:
[0111] For each isomorphic sequence corresponding to an object ID, the aggregate vectors corresponding to the data records at each time point in the isomorphic sequence are combined into a first vector sequence.
[0112] For each set semantic space mapping matrix, the first vector sequence is transformed using the semantic space mapping matrix to obtain a second vector sequence. The second vector sequence is then input into the set self-attention mechanism to obtain sequence interaction information. The self-attention mechanism is used to cross-reference information at different time points.
[0113] Based on the long-term query vector and short-term query vector of the pre-set attention mechanism, the sequence interaction information is aggregated to obtain a first candidate aggregation vector and a second candidate aggregation vector; based on the first candidate aggregation vector, a first target vector is determined, and based on the second candidate aggregation vector, a second target vector is determined.
[0114] Optionally, determining the first target vector based on the first candidate aggregation vector and determining the second target vector based on the second candidate aggregation vector includes:
[0115] If the number of semantic space mapping matrices is set to 1, then the first candidate aggregation vector is determined as the first target vector, and the second candidate aggregation vector is determined as the second target vector;
[0116] If the number of semantic space mapping matrices is greater than 1, then the first candidate aggregation vectors are concatenated to obtain the first target vector, and the second candidate aggregation vectors are concatenated to obtain the second target vector.
[0117] Optionally, the target model is a classification model for image classification; or,
[0118] The target model is a regression network model.
[0119] This concludes the process. Figure 4 Structural description of the device shown.
[0120] Correspondingly, embodiments of this application also provide a hardware structure diagram of an electronic device, specifically as follows: Figure 5 As shown, the electronic device can be a device implementing the above-described method. Figure 5 As shown, the hardware architecture includes a processor and a machine-readable storage medium.
[0121] The machine-readable storage medium is used to store machine-executable instructions;
[0122] The processor is configured to read and execute machine-executable instructions stored in the machine-readable storage medium to implement the method embodiment shown above.
[0123] Based on the same inventive concept, this embodiment also provides a machine-readable storage medium. The machine-readable storage medium is used to store machine-executable instructions; the machine-executable instructions stored in the machine-readable storage medium are executed by a processor to implement the method embodiment shown above.
[0124] As one embodiment, a machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, etc. For example, the memory can be volatile memory, non-volatile memory, or similar storage media. Specifically, the memory can be RAM (Random Access Memory), flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.
[0125] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for processing heterogeneous time-series data in a data mining scenario, characterized in that, The method includes: Data alignment processing is performed on heterogeneous time-series data with different structures from different business applications obtained in data mining scenarios, so that each heterogeneous time-series data is converted into homogeneous time-series data with the same data structure; the heterogeneous time-series data at least contains data records of different object IDs and / or the same object ID at different time points; the dimensions of the heterogeneous time-series data of at least two business applications are inconsistent; Isomorphic sequences corresponding to the same object ID are selected from each isomorphic time series dataset. Each isomorphic sequence corresponding to an object ID is obtained by arranging the data records belonging to that object ID at each time point in chronological order. Each data record at each time point contains a categorical vector Xc and a numerical vector Xn; the dimension of Xc is c.
1. c represents the number of categorical data points in this data record, and Xn has n dimensions. 1, where n represents the number of numeric data types in the data record; For each data record at each time point in the isomorphic sequence corresponding to each object ID, the categorical vector Xc and the numerical vector Xn in the data record are aggregated to obtain the aggregated vector corresponding to the data record. For each isomorphic sequence corresponding to an object ID, a first vector sequence composed of aggregated vectors corresponding to data records at each time point in the isomorphic sequence is transformed using a pre-set semantic space mapping matrix to obtain a second vector sequence. This second vector sequence is then input into a pre-set self-attention mechanism to obtain sequence interaction information. Based on the long-term and short-term query vectors of the pre-set attention mechanism, the sequence interaction information is aggregated to obtain a first candidate aggregated vector and a second candidate aggregated vector. A first target vector is determined based on the first candidate aggregated vector, and a second target vector is determined based on the second candidate aggregated vector. The first target vector represents a vector indicating long-term stationary characteristics, and the second target vector represents a vector indicating short-term fluctuation characteristics. The first and second target vectors are used to replace the data records in the corresponding isomorphic sequence for model training to train a target model for performing data processing, which may be a classification model or a model performing other data processing.
2. The method according to claim 1, characterized in that, Each heterogeneous time series data is represented by a corresponding data table; The step of aligning the acquired heterogeneous time-series data includes: A vertical stacking method is used to process the data tables corresponding to each heterogeneous time series data so that the data tables corresponding to each heterogeneous time series data have the same data structure.
3. The method according to claim 1, characterized in that, For each time point in the isomorphic sequence corresponding to each object ID, the categorical vector Xc and numerical vector Xn in the data record are aggregated to obtain the aggregated vector corresponding to the data record, including: For each data record at each time point in the isomorphic sequence corresponding to each object ID, a pre-set categorical variable encoding table is used to encode the data record with dimension c. The categorical field vector Xc of dimension 1 is converted to a vector of dimension c. The category coding matrix Ect of d; and, using the obtained baseline coding table and bias coding table for numerical variables, for dimension n A vector embedding is performed on a numeric field vector Xn to obtain a vector with dimension n. The numerical encoding matrix Ent of d; The category encoding matrix Ect and the numerical encoding matrix Ent are masked using a masking method to obtain a dimension of (c+n). A dense matrix Et of d; The dense matrix Et is aggregated according to the configured attention mechanism for aggregation to obtain the aggregated vector corresponding to the data record.
4. The method according to claim 3, characterized in that, The category encoding matrix Ect and the numerical encoding matrix Ent are masked using a masking method to obtain a dimension of (c+n). The dense matrix Et of d includes: The numerical encoding matrix Ent and the category encoding matrix Ect are operated on using a first specified function to obtain a first operation result; The first calculation result is masked to obtain the second calculation result; Based on the result of the second calculation, the dimension is determined to be (c+n). Et is a dense matrix of d.
5. The method according to claim 3, characterized in that, The aggregation operation performed on the dense matrix Et according to the configured attention mechanism for aggregation, to obtain the aggregation vector corresponding to the data record, includes: The first specified function is used to perform corresponding operations on the numerical variable baseline coding table and the category coding matrix Ect to obtain the third operation result; The dense matrix Et and the third operation result are input into the configured attention mechanism to obtain the output result of the attention mechanism. Based on the output result of the attention mechanism, the aggregation vector corresponding to the data record is determined. Here, the attention mechanism is an m-head attention mechanism, and the aggregation vector corresponding to the data record is the output of one head with dimension d. A vector of size 1; or, the aggregate vector corresponding to the data record is: the dimension of the output for the m-head is d. The dimension of the concatenated vectors of size md is obtained by concatenating the vectors of size md. A vector of 1.
6. The method according to claim 1, characterized in that, The steps of determining the first target vector based on the first candidate aggregation vector and determining the second target vector based on the second candidate aggregation vector include: If the number of semantic space mapping matrices is set to 1, then the first candidate aggregation vector is determined as the first target vector, and the second candidate aggregation vector is determined as the second target vector; If the number of semantic space mapping matrices is greater than 1, then the first candidate aggregation vectors are concatenated to obtain the first target vector, and the second candidate aggregation vectors are concatenated to obtain the second target vector.
7. The method according to any one of claims 1 to 6, characterized in that, The target model is a classification model used for time series data classification; or, The target model is a regression network model.
8. A heterogeneous time-series data processing device applied in data mining scenarios, characterized in that, The device includes: Alignment units are used to align heterogeneous time-series data from different business applications with different structures obtained in data mining scenarios, so as to transform each heterogeneous time-series data into homogeneous time-series data with the same data structure; at least two business applications have heterogeneous time-series data with inconsistent dimensions. The filtering unit is used to filter out isomorphic sequences corresponding to the same object ID from various isomorphic time series data. Each isomorphic sequence corresponding to an object ID is obtained by arranging the data records belonging to that object ID at each time point in chronological order. Each data record at each time point contains a categorical vector Xc and a numerical vector Xn; the dimension of Xc is c.
1. c represents the number of categorical data points in this data record, and Xn has n dimensions. 1, where n represents the number of numeric data types in the data record; The aggregation unit is used to aggregate the categorical vector Xc and the numerical vector Xn in the data record of each time point in the isomorphic sequence corresponding to each object ID, so as to obtain the aggregated vector corresponding to the data record. The processing unit is configured to, for each isomorphic sequence corresponding to an object ID, use a pre-set semantic space mapping matrix to transform a first vector sequence composed of aggregated vectors corresponding to data records at each time point in the isomorphic sequence to obtain a second vector sequence. The second vector sequence is then input into a pre-set self-attention mechanism to obtain sequence interaction information. Based on the long-term and short-term query vectors of the pre-set attention mechanism, the sequence interaction information is aggregated to obtain a first candidate aggregated vector and a second candidate aggregated vector. Based on the first candidate aggregated vector, a first target vector is determined, and based on the second candidate aggregated vector, a second target vector is determined. The first target vector represents a vector with long-term stationary characteristics, and the second target vector represents a vector with short-term fluctuation characteristics. The first and second target vectors are used to proxy the data records in the isomorphic sequence for model training to train a target model for performing data processing, whereby the target model is a classification model or a model for performing other data processing.
9. An electronic device, characterized in that, The electronic device includes: a processor and a machine-readable storage medium; The machine-readable storage medium is used to store machine-executable instructions; The processor is configured to read and execute machine-executable instructions stored in the machine-readable storage medium to implement the steps in the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Traffic flow model training method based on attention mechanism
CN110889546A
Recommendation method based on self-attention mechanism
CN113822742A