A timing window determination method, apparatus and electronic device
By analyzing the characteristic information of time series data and automatically selecting the historical window length, the problem of high computational overhead in existing technologies is solved, and the efficiency and accuracy of data prediction are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE COMM LTD RES INST
- Filing Date
- 2021-11-24
- Publication Date
- 2026-07-03
Smart Images

Figure CN116166706B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus and electronic device for determining a timing window. Background Technology
[0002] Currently, in big data analytics scenarios, it is often necessary to predict future data trends based on past time series data. The length of the historical data window significantly impacts the accuracy of the prediction model. Specifically, a window that is too short may prevent the model from learning useful information from the historical data, while a window that is too long may lead to excessive noise and prevent the model from focusing on important data.
[0003] In existing technologies, the common approach to selecting a suitable historical window length is to pre-define a certain historical window interval, iterate through the prediction results corresponding to historical windows of different lengths within that interval, and then select the one with the best performance as the target historical window length. However, this approach requires iterating through all historical windows of various lengths within the interval and training the model to calculate the prediction results for each historical window length, resulting in high computational overhead and long processing time. Summary of the Invention
[0004] This application provides a timing window determination method, apparatus, and electronic device to solve the problems of high computational overhead and long processing time in existing solutions.
[0005] In a first aspect, embodiments of this application provide a timing window determination method, including:
[0006] Obtain the first time series data, which includes N data points at N time points, where N is an integer greater than 2;
[0007] Based on the N data points at the N time points, determine the target feature information of the first time series data;
[0008] Based on the target feature information, the window length of historical time series data used for data prediction is determined.
[0009] Optionally, determining the target feature information of the first time-series data based on the N data points at the N time points includes at least one of the following:
[0010] Based on N data points at N time points, M sets of historical window data and M sets of predicted data are determined; based on the M sets of historical window data and the M sets of predicted data, first feature information of the first time series data is determined; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the following: the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of the self-attention between each set of historical window data and the corresponding set of predicted data;
[0011] Based on the N data points at the N time points, the time series period of the first time series data is determined.
[0012] Optionally, when the first feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, determining the first feature information of the first time series data based on the M groups of historical window data and the M groups of predicted data includes:
[0013] For the first historical window data and the first predicted data, calculate the distance between each data in the first historical window data and each data in the first predicted data, wherein the first historical window data is any one of the M sets of historical window data, and the first predicted data is a set of predicted data in the M sets of predicted data that corresponds to the first predicted data.
[0014] Based on the distance, the correlation between the first historical window data and the first predicted data is determined.
[0015] Optionally, determining the time series period of the first time series data based on the N data points at the N time points includes:
[0016] Determine the average value of the time window corresponding to each of the N data points at the N time points to obtain the second time series data composed of the N average values;
[0017] Autocorrelation is calculated on N average values in the second time series data, and L extreme points where the autocorrelation satisfies the first preset condition are determined, where L is a positive integer;
[0018] Based on the L extreme points, the average time series period is determined, wherein the average time series period is the time series period of the first time series data.
[0019] Optionally, determining the window length of historical time-series data for data prediction based on the target feature information includes:
[0020] When the target feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, based on the correlation between each group of historical window data and the corresponding group of predicted data, the length of a group of historical window data whose correlation satisfies the second preset condition is determined as the candidate historical window length.
[0021] Alternatively, if the target feature information includes the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data, the length of a group of historical window data whose similarity satisfies the third preset condition is determined as the candidate historical window length based on the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data.
[0022] Alternatively, if the target feature information includes the time series period of the first time series data, the time series period is determined as the length of the candidate historical window based on the time series period of the first time series data.
[0023] The target historical window length is determined from the candidate historical window lengths, wherein the target historical window length is the window length of the historical time series data used for data prediction.
[0024] Optionally, determining the target history window length from the candidate history window lengths includes:
[0025] When the number of candidate historical window lengths is greater than 1, the prediction effect of each candidate historical window length is tested using a test set and a prediction model.
[0026] The candidate historical window length with the best prediction effect is selected as the target historical window length.
[0027] Optionally, determining M sets of historical window data and M sets of predicted data based on N data points at N time points includes:
[0028] Based on M predetermined historical window lengths, the sliding window method is used to split the N data points at the N time points to generate M sets of historical window data and corresponding M sets of prediction data.
[0029] Optionally, the lengths of the M different history windows are determined in the following manner:
[0030] Based on the data granularity of the first time series data, the first period of the first time series data is determined;
[0031] The data length is determined based on the first period and the data granularity;
[0032] Based on the preset M multiplier values and the data length, the M different historical window lengths are determined, wherein a historical window length is equal to the product of a multiplier value and the data length.
[0033] Secondly, embodiments of this application also provide a timing window determination apparatus, comprising:
[0034] The acquisition module is used to acquire first time-series data, which includes N data points at N time points, where N is an integer greater than 2;
[0035] The first determining module is used to determine the target feature information of the first time series data based on the N data at the N time points;
[0036] The second determining module is used to determine the window length of historical time series data for data prediction based on the target feature information.
[0037] Optionally, the first determining module includes at least one of the following:
[0038] The first determining submodule is used to determine M sets of historical window data and M sets of predicted data based on N data points at N time points; and to determine first feature information of the first time series data based on the M sets of historical window data and the M sets of predicted data; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of self-attention between each set of historical window data and the corresponding set of predicted data.
[0039] The second determining submodule is used to determine the timing period of the first time series data based on the N data points at the N time points.
[0040] Optionally, the first feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, and the first determining submodule includes:
[0041] The calculation unit is used to calculate the distance between each data in the first historical window data and each data in the first predicted data for the first historical window data and the first predicted data, wherein the first historical window data is any one of the M sets of historical window data, and the first predicted data is a set of predicted data corresponding to the first predicted data in the M sets of predicted data.
[0042] The first determining unit is used to determine the correlation between the first historical window data and the first predicted data based on the distance.
[0043] Optionally, the second determining submodule includes:
[0044] The second determining unit is used to determine the average value of the time window corresponding to each data point in the N data points at the N time points, so as to obtain the second time series data composed of the N average values;
[0045] The third determining unit is used to calculate the autocorrelation of N average values in the second time series data and determine L extreme points where the autocorrelation satisfies the first preset condition, where L is a positive integer.
[0046] The fourth determining unit is used to determine the average time series period based on the L extreme points, wherein the average time series period is the time series period of the first time series data.
[0047] Optionally, the second determining module includes:
[0048] The third determining submodule is used to determine the length of a set of historical window data whose correlation satisfies the second preset condition as the candidate historical window length, based on the correlation between the historical window data and the corresponding predicted data, when the target feature information includes the correlation between each set of historical window data and the corresponding predicted data.
[0049] Alternatively, the fourth determining submodule is used to determine the length of a set of historical window data whose similarity satisfies the third preset condition as the candidate historical window length, based on the similarity of the self-attention of the self-attention of the set of historical window data and the corresponding set of prediction data, when the target feature information includes the similarity of the self-attention of each set of historical window data and the corresponding set of prediction data.
[0050] Alternatively, the fifth determining submodule is used to determine the time period as the candidate historical window length based on the time period of the first time series data when the target feature information includes the time period of the first time series data.
[0051] The sixth determining submodule is used to determine the target historical window length from the candidate historical window lengths, wherein the target historical window length is the window length of the historical time series data used for data prediction.
[0052] Optionally, the sixth determining submodule includes:
[0053] The testing unit is used to test the prediction effect of each candidate historical window length using a test set and a prediction model when the number of candidate historical window lengths is greater than 1.
[0054] The selection unit is used to select the candidate historical window length with the best prediction effect as the target historical window length.
[0055] Optionally, the first determining submodule is used to split the N data points at the N time points using a sliding window method based on M predetermined different historical window lengths, so as to generate M sets of historical window data and corresponding M sets of prediction data.
[0056] Optionally, the lengths of the M different history windows are determined in the following manner:
[0057] Based on the data granularity of the first time series data, the first period of the first time series data is determined;
[0058] The data length is determined based on the first period and the data granularity;
[0059] Based on the preset M multiplier values and the data length, the M different historical window lengths are determined, wherein a historical window length is equal to the product of a multiplier value and the data length.
[0060] Thirdly, embodiments of this application also provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in the timing window determination method described above.
[0061] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the timing window determination method described above.
[0062] In this embodiment, first time-series data is acquired, comprising N data points at N time points, where N is an integer greater than 2. Based on the N data points at N time points, target feature information of the first time-series data is determined. Based on the target feature information, the window length of historical time-series data used for data prediction is determined. Thus, by analyzing the target feature information of the time-series data, the historical window length for data prediction can be determined automatically and quickly, significantly reducing computational and time overhead compared to existing methods that iterate through and optimize the historical window length. Attached Figure Description
[0063] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0064] Figure 1This is a flowchart of the timing window determination method provided in the embodiments of this application;
[0065] Figure 2 This is an example flowchart of the timing window determination method provided in the embodiments of this application;
[0066] Figure 3 This is a structural diagram of the timing window determination device provided in the embodiments of this application;
[0067] Figure 4 This is a structural diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0068] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0069] See Figure 1 , Figure 1 This is a flowchart of the timing window determination method provided in the embodiments of this application, such as... Figure 1 As shown, it includes the following steps:
[0070] Step 101: Obtain the first time series data, which includes N data points at N time points, where N is an integer greater than 2.
[0071] In this embodiment of the application, data within a certain period of time in the corresponding scenario can be obtained based on the data that needs to be predicted in the actual prediction scenario, thereby obtaining a time series and the data corresponding to each time point in the time series, which can also be a time series data including N data points at N time points.
[0072] For example, in the scenario of time-series prediction of wireless cell traffic, the time-series traffic data of a cell to be predicted can be obtained, specifically, the traffic data generated by the cell each day within a week.
[0073] Step 102: Based on the N data points at the N time points, determine the target feature information of the first time series data.
[0074] The aforementioned target feature information can be information such as the correlation between data, periodicity, self-attention features, etc.
[0075] Specifically, the target feature information can be determined by analyzing N data points corresponding to N time points in the first time series data. For example, it can be analyzed whether the first time series data has periodicity and how long the period is. Correlation analysis can also be performed on the first time series data according to different time points, such as analyzing the relationship between one or several data points after the time point and several historical data points before the time point, and so on.
[0076] Step 103: Based on the target feature information, determine the window length of the historical time series data used for data prediction.
[0077] In this embodiment of the application, a suitable target historical window length for data prediction can be selected or generated based on the target feature information determined by analyzing the first time series data. The target historical window length is also the length of the historical time series data used in the prediction.
[0078] For example, the target historical window length for prediction can be determined based on the periodicity information of the first time series data, using the data period length, such as 3 hours. Alternatively, the length of a historical time series data with high correlation can be determined based on the correlation information between historical time series data of different lengths in the first time series data and the corresponding prediction data, and used as the target historical window length for prediction. Of course, when the target feature information includes multiple types, a historical window length can be determined as an alternative based on different feature information, and finally, the historical window length with better prediction effect is selected as the final target historical window length for prediction.
[0079] Optionally, step 102 includes at least one of the following:
[0080] Based on N data points at N time points, M sets of historical window data and M sets of predicted data are determined; based on the M sets of historical window data and the M sets of predicted data, first feature information of the first time series data is determined; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the following: the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of the self-attention between each set of historical window data and the corresponding set of predicted data;
[0081] Based on the N data points at the N time points, the time series period of the first time series data is determined.
[0082] In one embodiment, the target feature information may include one or more of the following: correlation between data in the first time series data, self-attention features, and periodicity.
[0083] To determine the correlation and / or self-attention features among the data in the first time series data, the first time series data can be divided into multiple groups of historical window data of different lengths and corresponding prediction data, resulting in a one-to-one correspondence of M groups of historical window data and M groups of prediction data. Specifically, this can be achieved by taking data of different window lengths from the first time series data to obtain multiple groups of historical window data of different lengths, and then taking a corresponding set of prediction data from the first time series data for each group of historical window data. For example, for the first time series data X(x1,x2,x3,…,x…) N Historical window data of lengths 3, 4, 5, 6, etc. can be taken respectively, such as (x1,x2,x3), (x1,x2,x3,x4), (x1,x2,x3,x4,x5). Correspondingly, for each group of historical window data, several data points after it can be taken as the corresponding prediction data, such as (x4,x5), (x5,x6), (x6,x7).
[0084] Then, based on the determined M sets of historical window data and M sets of prediction data, the feature information of the first time series data can be analyzed. Specifically, the correlation between each set of historical window data and the corresponding set of prediction data can be analyzed, as well as the similarity of the self-attention between each set of historical window data and the corresponding set of prediction data can be analyzed.
[0085] For example, the correlation between the first set of historical window data and the predicted data, the correlation between the second set of historical window data and the predicted data, the correlation between the third set of historical window data and the predicted data, ..., the correlation between the Mth set of historical window data and the predicted data can be analyzed sequentially.
[0086] Alternatively, the self-attention of the first set of historical window data and the self-attention of the predicted data can be calculated sequentially, as can the self-attention of the first set of historical window data and the self-attention of the predicted data, the self-attention of the second set of historical window data and the self-attention of the predicted data, the self-attention of the third set of historical window data and the predicted data, and so on, up to the Mth set of historical window data and the predicted data. Then, the similarity of the self-attention of the first set of historical window data and the predicted data, the similarity of the self-attention of the second set of historical window data and the predicted data, the similarity of the self-attention of the third set of historical window data and the predicted data, and so on, up to the Mth set of historical window data and the predicted data can be calculated.
[0087] Specifically, a self-attention model (AM) can be used to calculate the self-attention of each group of historical window data and the corresponding group of predicted data, and cosine similarity can be used to calculate the similarity between the self-attentions of the two groups. The formula for calculating self-attention is as follows:
[0088]
[0089] Where Q, K, and V are calculated from the original input (i.e., the historical window data or prediction data for which self-attention needs to be calculated) through their respective matrix transformations, and are respectively the query vector matrix, key vector matrix, and value vector matrix. k It is the dimension of k.
[0090] In this way, the correlation between each group of historical window data and the corresponding group of predicted data can be obtained, and / or the similarity of the self-attention between each group of historical window data and the corresponding group of predicted data can be obtained, which will help to select an appropriate historical window length based on the correlation and / or similarity in the subsequent step 103.
[0091] To determine the time series period of the first time series data, N data points in the first time series data can be observed and analyzed. Specifically, the autocorrelation between each data point can be calculated to find the periodic variation pattern of each data point in the first time series data, thereby determining the time series period of the first time series data. For example, by analyzing the autocorrelation between the N data points, the time series period of the first time series data can be determined to be 5 hours.
[0092] In this way, the time series period of the first time series data can be obtained, which will help to consider the time series period of the data in the subsequent step 103 and select a more reasonable historical window length.
[0093] Furthermore, determining M sets of historical window data and M sets of predicted data based on the N data points at the N time points includes:
[0094] Based on M predetermined historical window lengths, the sliding window method is used to split the N data points at the N time points to generate M sets of historical window data and corresponding M sets of prediction data.
[0095] In one specific implementation, to obtain the M sets of historical window data and M sets of prediction data, M different historical window lengths can be preset. Specifically, these lengths can be set based on the prediction scenario and prior experience. Then, the first time series data can be processed using a sliding window method to sequentially generate M sets of historical window data of different lengths and the corresponding M sets of prediction data. The lengths of the generated M sets of historical window data are the preset M different historical window lengths.
[0096] This ensures that multiple sets of historical window data and forecast data can be generated quickly and on demand.
[0097] Furthermore, the lengths of the M different history windows are determined in the following manner:
[0098] Based on the data granularity of the first time series data, the first period of the first time series data is determined;
[0099] The data length is determined based on the first period and the data granularity;
[0100] Based on the preset M multiplier values and the data length, the M different historical window lengths are determined, wherein a historical window length is equal to the product of a multiplier value and the data length.
[0101] In one implementation, the data granularity of the time-series data itself can be considered to reasonably set the length of the M historical windows.
[0102] Specifically, the data granularity of the first time-series data can be determined, also called the time granularity. The data granularity can be measured by the interval between adjacent data in the time-series data. For example, for the first time-series data X(x1, x2, x3, ..., x...), the granularity can be determined by the time interval between adjacent data in the time-series data. N ), whose timestamp is T(t1, t2, t3, ..., t N If the data granularity (freq) of the first time series data is detected, it can be determined that the data granularity (freq) is the time interval between adjacent timestamps such as t1 and t2, t2 and t3. Then, based on the data granularity (freq) of the first time series data, the large period of the first time series data, i.e., the first period, can be determined. Specifically, this can be achieved through the time rule mapping function `fun`. time This yields the large period F of the data granularity frequency, i.e., F = fun. time (freq).
[0103] Furthermore, the data length Len can be determined based on the large period F and the data granularity freq. period The data length Len period This can be the number of frequencies contained in the large period F, i.e., Len period = [F / freq], where square brackets [] indicate rounding. For example, if the time granularity of the time series data itself is 5 minutes, and its large period is 60 minutes, then the length of data contained in the large period is Len. period The answer is 60 / 5 = 12.
[0104] It should be noted that if the time granularity of the time series data cannot be used to calculate the large period F, then the length of the data contained in the large period F can be equal to the prediction window length (the length of the prediction data), i.e., Len. period =Len pre .
[0105] In this implementation, several multiplier values can be preset, such as M multiplier values, for setting the historical window length. Specifically, these values can be set based on the prediction scenario and prior experience. For example, five multiplier values can be set: 1, 1.5, 2, 2.5, and 3. Then, the determined data length Len can be... period According to the implementation of M multiple values, take M different multiples of data length Len. period Finally, M different historical window lengths are obtained, where a historical window length is equal to the product of a multiple and the data length.
[0106] In this way, this implementation method can ensure that the lengths of the M historical windows are reasonably determined based on the time granularity and periodicity of the time series data, thereby ensuring the reliability of the subsequent correlation analysis and attention similarity analysis based on the M historical window data and the prediction data, and ultimately ensuring that a relatively optimal target historical window length is selected.
[0107] Optionally, when the first feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, determining the first feature information of the first time series data based on the M groups of historical window data and the M groups of predicted data includes:
[0108] For the first historical window data and the first predicted data, calculate the distance between each data in the first historical window data and each data in the first predicted data, wherein the first historical window data is any one of the M sets of historical window data, and the first predicted data is a set of predicted data in the M sets of predicted data that corresponds to the first predicted data.
[0109] Based on the distance, the correlation between the first historical window data and the first predicted data is determined.
[0110] In one implementation, when it is necessary to determine the correlation between each group of historical window data and the corresponding group of predicted data, the optimal path between each group of historical window data and the corresponding predicted data can be found by calculating the distance between each data point, thereby determining the correlation between the group of historical window data and the corresponding predicted data.
[0111] Specifically, for any set of historical window data in the M sets of historical window data and the corresponding set of predicted data, the distance between each data in the set of historical window data and each data in the corresponding set of predicted data can be calculated, such as Euclidean distance. Then, based on the calculated distances, the correlation between the set of historical window data and the corresponding set of predicted data can be analyzed.
[0112] To quickly calculate the correlation between each group of historical window data and the corresponding group of predicted data, the Dynamic Time Warping (DTW) algorithm can be used to calculate the dynamic correlation (Corr) of historical window data of different lengths with their respective predicted data. dtw The specific calculation process is as follows:
[0113] 1) Define two time series data X′=(x1,...,x m ) and Y = (y1,...,y n ), where X′=(x1,...,x m ) represents historical window data, Y = (y1,...,y n ) represents the corresponding predicted data. By calculating the distance between each point in these two time series datasets, an m×n matrix can be obtained, where the k-th element is represented as w. k =(i,j) k w k w is the Euclidean distance between data point i in X′ and data point j in Y′. k =d(X′) i ,Y j )≥0.
[0114] 2) Find the optimal path while satisfying constraints (such as boundary conditions, continuity, and monotonicity), i.e.
[0115] 3) The process of finding the optimal path is to find the cumulative distance γ in the path. (i,j) The process of reaching the minimum, in which, This represents the current distance between all points.
[0116] In this implementation, the γ of each group of historical window data and the corresponding group of predicted data can be used as a basis. (i,j) To measure the correlation between the set of historical window data and the corresponding set of predicted data, such as γ. (i,j) The smaller the value, the greater the correlation between the historical window data and the corresponding predicted data.
[0117] In this way, the correlation between each group of historical window data and the corresponding group of predicted data can be calculated accurately and quickly.
[0118] Optionally, determining the time series period of the first time series data based on the N data points at the N time points includes:
[0119] Determine the average value of the time window corresponding to each of the N data points at the N time points to obtain the second time series data composed of the N average values;
[0120] Autocorrelation is calculated on N average values in the second time series data, and L extreme points where the autocorrelation satisfies the first preset condition are determined, where L is a positive integer;
[0121] Based on the L extreme points, the average time series period is determined, wherein the average time series period is the time series period of the first time series data.
[0122] In one embodiment, the target feature information may include the time series period of the first time series data.
[0123] To determine the timing period of the first time series data, the time window corresponding to each of the N data points at N time points in the first time series data can be determined first, and the average value of the time window corresponding to each data point can be taken to obtain N average values, and then the second time series data composed of the N average values can be obtained.
[0124] Specifically, for the first time-series data X(x1,x2,x3,…,x…) N We can first set the value of X at the first time step x1 and the value of X at the last time step x2. N Perform upward and downward padding respectively, then for each time point, take the average of the values in the most recent time window to obtain a time series X1 of equal length. For example, assuming a time window of 3, x1 can be padded upwards with the data x0 from the previous time point, and for x... N Fill down the data x for the next time point N+1 The time window values corresponding to x1 are x0, x1, and x2, and the time window values corresponding to x2 are x1, x2, and x3. N The corresponding time window value is x N-1 x N and x N+1 Thus, for the time window corresponding to x1, we take the average value x1′ = (x0 + x1 + x2) / 3, and for the time window corresponding to x2, we take the average value x2′ = (x1 + x2 + x3) / 3. N The average value x is taken from the corresponding time window. N ′=(x N-1 +x N +x N+1 ) / 3.
[0125] Then, autocorrelation can be calculated on the N average values in the second time series data X″. Specifically, the correlation between any two data points in the second time series data X″ can be calculated to obtain the autocorrelation calculation result S. acf S acf That is, it is a set of correlation results between the data in the second time series data X″.
[0126] Next, the autocorrelation analysis results S can be obtained from the results. acf The autocorrelation of the data is statistically analyzed to find L correlation results that satisfy the first preset condition. These L correlation results are the L extreme points. The first preset condition can be the highest correlation, the correlation greater than a preset threshold, the correlation located in a preset interval, etc.
[0127] Finally, based on the L extreme points, the average distance Len of the differences between the extreme points can be calculated. acf The average time series period is the time series period of the first time series data.
[0128] It should be noted that if the autocorrelation analysis result S acf If there are no extreme points, it can be determined that the first time series data has no numerical periodicity, that is, the time series data does not have periodic changes. In this case, the target historical window length for prediction cannot be determined based on the periodicity of the time series data, but can be determined based on other feature information of the time series data.
[0129] In this way, the time series period of the first time series data can be accurately and quickly analyzed, which helps to select a more reasonable historical window length based on the time series period of the data in the subsequent step 103.
[0130] Optionally, step 103 includes:
[0131] When the target feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, based on the correlation between each group of historical window data and the corresponding group of predicted data, the length of a group of historical window data whose correlation satisfies the second preset condition is determined as the candidate historical window length.
[0132] Alternatively, if the target feature information includes the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data, the length of a group of historical window data whose similarity satisfies the third preset condition is determined as the candidate historical window length based on the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data.
[0133] Alternatively, if the target feature information includes the time series period of the first time series data, the time series period is determined as the length of the candidate historical window based on the time series period of the first time series data.
[0134] The target historical window length is determined from the candidate historical window lengths, wherein the target historical window length is the window length of the historical time series data used for data prediction.
[0135] In one specific implementation, when the target feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, the correlation coefficient (Corr) can be calculated based on the correlation between each group of historical window data and the corresponding group of predicted data. dtw A set of historical window data whose correlation satisfies a second preset condition is identified, and the length of this set of historical window data is used as the candidate historical window length. The second preset condition can be the highest correlation, correlation greater than a first preset value, etc. Specifically, the correlation results of each set can be Corr dtw Sort the data, such as from largest to smallest, to obtain the window length Len of the historical window data with the highest relevance. corr .
[0136] When the target feature information includes the similarity of the self-attention between each group of historical window data and the corresponding group of predicted data, a group of historical window data whose similarity satisfies a third preset condition can be determined based on the calculated similarity between the self-attention of each group of historical window data and the corresponding group of predicted data. The length of this group of historical window data is then used as the candidate historical window length. The third preset condition can be the highest similarity, similarity greater than a second preset value, etc. Specifically, the window length Len of the historical window data with the highest similarity can be selected. att .
[0137] When the target feature information includes the time series period of the first time series data, the calculated time series period Len of the first time series data can be directly used. acf The selected historical window length has been determined.
[0138] Thus, after determining the candidate historical window lengths, a target historical window length can be selected from these candidate lengths. Specifically, if there is only one candidate historical window length, that length can be directly used as the target historical window length. If there are multiple candidate historical window lengths, the optimal one can be selected as the target historical window length. For example, if the candidate historical window lengths include Len... corr Len att and Len acf In such cases, the one with the best prediction performance can be selected as the target historical window length.
[0139] In this way, this implementation method can ensure that a suitable historical window length can be selected from one or more perspectives such as the correlation of time series data, self-attention characteristics, and periodicity, and finally the target historical window length can be determined. This can reduce computational overhead while ensuring good prediction results.
[0140] Further, determining the target history window length from the candidate history window lengths includes:
[0141] When the number of candidate historical window lengths is greater than 1, the prediction effect of each candidate historical window length is tested using a test set and a prediction model.
[0142] The candidate historical window length with the best prediction effect is selected as the target historical window length.
[0143] In one implementation, the data prediction effect of each candidate historical window length can be tested separately, and then the candidate historical window length with the best prediction effect can be selected as the target historical window length actually used in the final prediction.
[0144] Specifically, after calculating the above Len corr Len att and / or Len acf Then, the historical window length used for data prediction can be set to equal Len. corr Len att Len acf Then, based on the prediction task, corresponding training and testing sets are constructed, and appropriate prediction models are used according to the actual prediction scenario. For example, a multilayer perceptron (MLP) is selected to train the model corresponding to the above-mentioned Len. corr Len att and / or Len acf The prediction model is then tested on its respective test set. The prediction performance can be represented by the Mean Absolute Percentage Error (MAPE). For example, for the Len mentioned above... corr Len att and Len acf The prediction results Eval were obtained respectively. corr Eval att and Eval acf The historical window length with the best prediction effect can be selected as the final target historical window length Len. final .
[0145] In this implementation, the optimal target historical window length can be selected by comparing actual prediction experimental data, thereby ensuring the prediction accuracy of the prediction model in actual prediction scenarios.
[0146] A flowchart illustrating the specific implementation of a historical window length automatic selection method based on a time period in this application is shown below. Figure 2As shown, by considering the correlation, attention characteristics, and periodicity of time series data, the lengths Len of the three candidate historical windows are determined respectively. corr Len att and Len acf Then, by testing the prediction performance of each candidate historical window length, the optimal historical window length Len is selected. final .
[0147] The time-series window determination method of this application embodiment acquires first time-series data, which includes N data points at N time points, where N is an integer greater than 2; based on the N data points at N time points, it determines target feature information of the first time-series data; and based on the target feature information, it determines the window length of historical time-series data used for data prediction. In this way, by analyzing the target feature information of the time-series data, the historical window length used for data prediction can be determined automatically and quickly, significantly reducing computational and time overhead compared to existing methods that iterate through and optimize the historical window length.
[0148] The application scenarios of this application are quite broad. It can be applied to the process of determining the historical window length and optimizing the model effect in time series prediction and spatiotemporal prediction tasks by algorithm engineers. It can also be applied to automated modeling platforms to provide users with a way to automatically set historical length data parameters.
[0149] Taking the time-series prediction of wireless cell traffic as an example, after obtaining the time-series traffic data of the cell to be predicted, data preprocessing work such as missing value imputation and outlier handling is performed to obtain a good cell traffic dataset, which includes a column of timestamps and a column of traffic metrics. Then, the following steps are performed:
[0150] 1. Detect the time granularity and long cycle length of time-series traffic data.
[0151] By analyzing the timestamp sequence of cell traffic data, the time granularity of the cell traffic data was detected to be f and its major period to be F.
[0152] 2. Calculate the historical window length corresponding to the maximum dynamic correlation.
[0153] Dynamic correlation calculations are performed between historical window length sequences with different F values and the sequence to be predicted; the historical window length with the strongest dynamic correlation is denoted as Len. corr .
[0154] 3. Calculate the historical window length corresponding to the maximum attention score.
[0155] Attention scores are calculated using historical window length sequences with different values of F and the sequence to be predicted; the historical window length with the highest attention score is denoted as Len. att .
[0156] 4. Calculate the historical window length corresponding to the periodicity of time-series flow data.
[0157] For each time point, the values within the most recent time window are averaged to obtain time series data of equal length. Then, autocorrelation analysis is performed on this time series data to obtain the autocorrelation analysis result S. acf The top 10 S with the highest statistical relevance acf The extreme points are calculated, and the average distance Len of the difference between the extreme points is obtained. acf .
[0158] 5. Determine the final target history window length for automatic selection.
[0159] Based on steps 2 to 4, three historical window lengths are obtained. Then, training and test sets are constructed for each length using a prediction task. Three usable prediction models are trained using the model, and their performance is tested on their respective test sets. The historical window length with the best prediction performance is automatically selected as the final prediction historical length (Len). final .
[0160] This application also provides a timing window determination device. See [link to relevant documentation]. Figure 3 , Figure 3 This is a structural diagram of the timing window determination device provided in the embodiments of this application. Since the principle of the timing window determination device in solving the problem is similar to that of the timing window determination method in the embodiments of this application, the implementation of this timing window determination device can refer to the implementation of the method, and the repeated parts will not be described again.
[0161] like Figure 3 As shown, the timing window determination device 300 includes:
[0162] The acquisition module 301 is used to acquire first time series data, which includes N data points at N time points, where N is an integer greater than 2;
[0163] The first determining module 302 is used to determine the target feature information of the first time series data based on the N data at the N time points;
[0164] The second determining module 303 is used to determine the window length of historical time series data for data prediction based on the target feature information.
[0165] Optionally, the first determining module 302 includes at least one of the following:
[0166] The first determining submodule is used to determine M sets of historical window data and M sets of predicted data based on N data points at N time points; and to determine first feature information of the first time series data based on the M sets of historical window data and the M sets of predicted data; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of self-attention between each set of historical window data and the corresponding set of predicted data.
[0167] The second determining submodule is used to determine the timing period of the first time series data based on the N data points at the N time points.
[0168] Optionally, the first feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, and the first determining submodule includes:
[0169] The calculation unit is used to calculate the distance between each data in the first historical window data and each data in the first predicted data for the first historical window data and the first predicted data, wherein the first historical window data is any one of the M sets of historical window data, and the first predicted data is a set of predicted data corresponding to the first predicted data in the M sets of predicted data.
[0170] The first determining unit is used to determine the correlation between the first historical window data and the first predicted data based on the distance.
[0171] Optionally, the second determining submodule includes:
[0172] The second determining unit is used to determine the average value of the time window corresponding to each data point in the N data points at the N time points, so as to obtain the second time series data composed of the N average values;
[0173] The third determining unit is used to calculate the autocorrelation of N average values in the second time series data and determine L extreme points where the autocorrelation satisfies the first preset condition, where L is a positive integer.
[0174] The fourth determining unit is used to determine the average time series period based on the L extreme points, wherein the average time series period is the time series period of the first time series data.
[0175] Optionally, the second determining module 303 includes:
[0176] The third determining submodule is used to determine the length of a set of historical window data whose correlation satisfies the second preset condition as the candidate historical window length, based on the correlation between the historical window data and the corresponding predicted data, when the target feature information includes the correlation between each set of historical window data and the corresponding predicted data.
[0177] Alternatively, the fourth determining submodule is used to determine the length of a set of historical window data whose similarity satisfies the third preset condition as the candidate historical window length, based on the similarity of the self-attention of the self-attention of the set of historical window data and the corresponding set of prediction data, when the target feature information includes the similarity of the self-attention of each set of historical window data and the corresponding set of prediction data.
[0178] Alternatively, the fifth determining submodule is used to determine the time period as the candidate historical window length based on the time period of the first time series data when the target feature information includes the time period of the first time series data.
[0179] The sixth determining submodule is used to determine the target historical window length from the candidate historical window lengths, wherein the target historical window length is the window length of the historical time series data used for data prediction.
[0180] Optionally, the sixth determining submodule includes:
[0181] The testing unit is used to test the prediction effect of each candidate historical window length using a test set and a prediction model when the number of candidate historical window lengths is greater than 1.
[0182] The selection unit is used to select the candidate historical window length with the best prediction effect as the target historical window length.
[0183] Optionally, the first determining submodule is used to split the N data points at the N time points using a sliding window method based on M predetermined different historical window lengths, so as to generate M sets of historical window data and corresponding M sets of prediction data.
[0184] Optionally, the lengths of the M different history windows are determined in the following manner:
[0185] Based on the data granularity of the first time series data, the first period of the first time series data is determined;
[0186] The data length is determined based on the first period and the data granularity;
[0187] Based on the preset M multiplier values and the data length, the M different historical window lengths are determined, wherein a historical window length is equal to the product of a multiplier value and the data length.
[0188] The timing window determination device 300 provided in this application embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0189] The time-series window determination device 300 of this application embodiment acquires first time-series data, which includes N data points at N time points, where N is an integer greater than 2; based on the N data points at N time points, it determines target feature information of the first time-series data; and based on the target feature information, it determines the window length of historical time-series data used for data prediction. In this way, by analyzing the target feature information of the time-series data, the historical window length used for data prediction can be automatically and quickly determined, significantly reducing computational and time overhead compared to existing methods that iterate through and optimize the historical window length.
[0190] This application also provides an electronic device. Since the principle by which the electronic device solves the problem is similar to the timing window determination method in this application, the implementation of this electronic device can refer to the implementation of the method, and repeated details will not be elaborated further. Figure 4 As shown, the electronic device according to an embodiment of this application includes:
[0191] Processor 400 is used to read the program from memory 420 and execute the following procedures:
[0192] Obtain the first time series data, which includes N data points at N time points, where N is an integer greater than 2;
[0193] Based on the N data points at the N time points, determine the target feature information of the first time series data;
[0194] Based on the target feature information, the window length of historical time series data used for data prediction is determined.
[0195] Among them, Figure 4 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 400) and memory (memory 420). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. A bus interface provides the interface. Processor 400 is responsible for managing the bus architecture and general processing, and memory 420 can store data used by processor 400 during operation.
[0196] Optionally, the processor 400 is also used to read the program from the memory 420 and perform the following steps:
[0197] Based on N data points at N time points, M sets of historical window data and M sets of predicted data are determined; based on the M sets of historical window data and the M sets of predicted data, first feature information of the first time series data is determined; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the following: the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of the self-attention between each set of historical window data and the corresponding set of predicted data;
[0198] Based on the N data points at the N time points, the time series period of the first time series data is determined.
[0199] Optionally, the first feature information includes the correlation between each group of historical window data and the corresponding group of predicted data. The processor 400 is also used to read the program in the memory 420 and execute the following steps:
[0200] For the first historical window data and the first predicted data, calculate the distance between each data in the first historical window data and each data in the first predicted data, wherein the first historical window data is any one of the M sets of historical window data, and the first predicted data is a set of predicted data in the M sets of predicted data that corresponds to the first predicted data.
[0201] Based on the distance, the correlation between the first historical window data and the first predicted data is determined.
[0202] Optionally, the processor 400 is also used to read the program from the memory 420 and perform the following steps:
[0203] Determine the average value of the time window corresponding to each of the N data points at the N time points to obtain the second time series data composed of the N average values;
[0204] Autocorrelation is calculated on N average values in the second time series data, and L extreme points where the autocorrelation satisfies the first preset condition are determined, where L is a positive integer;
[0205] Based on the L extreme points, the average time series period is determined, wherein the average time series period is the time series period of the first time series data.
[0206] Optionally, the processor 400 is also used to read the program from the memory 420 and perform the following steps:
[0207] When the target feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, based on the correlation between each group of historical window data and the corresponding group of predicted data, the length of a group of historical window data whose correlation satisfies the second preset condition is determined as the candidate historical window length.
[0208] Alternatively, if the target feature information includes the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data, the length of a group of historical window data whose similarity satisfies the third preset condition is determined as the candidate historical window length based on the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data.
[0209] Alternatively, if the target feature information includes the time series period of the first time series data, the time series period is determined as the length of the candidate historical window based on the time series period of the first time series data.
[0210] The target historical window length is determined from the candidate historical window lengths, wherein the target historical window length is the window length of the historical time series data used for data prediction.
[0211] Optionally, the processor 400 is also used to read the program from the memory 420 and perform the following steps:
[0212] When the number of candidate historical window lengths is greater than 1, the prediction effect of each candidate historical window length is tested using a test set and a prediction model.
[0213] The candidate historical window length with the best prediction effect is selected as the target historical window length.
[0214] Optionally, the processor 400 is also used to read the program from the memory 420 and perform the following steps:
[0215] Based on M predetermined historical window lengths, the sliding window method is used to split the N data points at the N time points to generate M sets of historical window data and corresponding M sets of prediction data.
[0216] Optionally, the processor 400 is also used to read the program from the memory 420 and perform the following steps:
[0217] Based on the data granularity of the first time series data, the first period of the first time series data is determined;
[0218] The data length is determined based on the first period and the data granularity;
[0219] Based on the preset M multiplier values and the data length, the M different historical window lengths are determined, wherein a historical window length is equal to the product of a multiplier value and the data length.
[0220] The electronic device provided in this application embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, so it will not be described again here.
[0221] Furthermore, the computer-readable storage medium of this application embodiment is used to store a computer program, which can be executed by a processor to implement the above method embodiment. Its implementation principle and technical effect are similar, and will not be repeated here.
[0222] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0223] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can be physically included separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0224] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute some steps of the transmission and reception methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0225] The above description is the preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principles described in this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for determining a timing window, characterized in that, include: Obtain first time-series data, which includes N data points at N time points, where N is an integer greater than 2; the first time-series data includes time-series traffic data of the cell to be predicted. Based on the N data points at the N time points, determine the target feature information of the first time series data; Based on the target feature information, determine the window length of the historical time series data used for data prediction; Determining the target feature information of the first time-series data based on the N data points at the N time points includes at least one of the following: Based on N data points at N time points, M sets of historical window data and M sets of predicted data are determined; based on the M sets of historical window data and the M sets of predicted data, first feature information of the first time series data is determined; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the following: the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of the self-attention between each set of historical window data and the corresponding set of predicted data; Based on the N data points at the N time points, the time series period of the first time series data is determined.
2. The method according to claim 1, characterized in that, When the first feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, determining the first feature information of the first time series data based on the M groups of historical window data and the M groups of predicted data includes: For the first historical window data and the first predicted data, calculate the distance between each data in the first historical window data and each data in the first predicted data, wherein the first historical window data is any one of the M sets of historical window data, and the first predicted data is a set of predicted data in the M sets of predicted data that corresponds to the first predicted data. Based on the distance, the correlation between the first historical window data and the first predicted data is determined.
3. The method according to claim 1, characterized in that, Determining the time series period of the first time series data based on the N data points at the N time points includes: Determine the average value of the time window corresponding to each of the N data points at the N time points to obtain the second time series data composed of the N average values; Autocorrelation is calculated on N average values in the second time series data, and L extreme points where the autocorrelation satisfies the first preset condition are determined, where L is a positive integer; Based on the L extreme points, the average time series period is determined, wherein the average time series period is the time series period of the first time series data.
4. The method according to any one of claims 1 to 2, characterized in that, The step of determining the window length of historical time-series data for data prediction based on the target feature information includes: When the target feature information includes the correlation between each group of historical window data and the corresponding group of predicted data, based on the correlation between each group of historical window data and the corresponding group of predicted data, the length of a group of historical window data whose correlation satisfies the second preset condition is determined as the candidate historical window length. Alternatively, if the target feature information includes the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data, the length of a group of historical window data whose similarity satisfies the third preset condition is determined as the candidate historical window length based on the similarity of the self-attention of each group of historical window data and the corresponding group of prediction data. Alternatively, if the target feature information includes the time series period of the first time series data, the time series period is determined as the length of the candidate historical window based on the time series period of the first time series data. The target historical window length is determined from the candidate historical window lengths, wherein the target historical window length is the window length of the historical time series data used for data prediction.
5. The method according to claim 4, characterized in that, Determining the target history window length from the candidate history window lengths includes: When the number of candidate historical window lengths is greater than 1, the prediction effect of each candidate historical window length is tested using a test set and a prediction model. The candidate historical window length with the best prediction effect is selected as the target historical window length.
6. The method according to claim 1, characterized in that, The determination of M sets of historical window data and M sets of predicted data based on N data points at N time points includes: Based on M predetermined historical window lengths, the sliding window method is used to split the N data points at the N time points to generate M sets of historical window data and corresponding M sets of prediction data.
7. The method according to claim 6, characterized in that, The lengths of the M different history windows are determined in the following manner: Based on the data granularity of the first time series data, the first period of the first time series data is determined; The data length is determined based on the first period and the data granularity; Based on the preset M multiplier values and the data length, the M different historical window lengths are determined, wherein a historical window length is equal to the product of a multiplier value and the data length.
8. A timing window determination device, characterized in that, include: The acquisition module is used to acquire first time-series data, which includes N data points at N time points, where N is an integer greater than 2; the first time-series data includes time-series traffic data of the cell to be predicted. The first determining module is used to determine the target feature information of the first time series data based on the N data at the N time points; The second determining module is used to determine the window length of historical time series data for data prediction based on the target feature information. The first determining module includes at least one of the following: The first determining submodule is used to determine M sets of historical window data and M sets of predicted data based on N data points at N time points; and to determine first feature information of the first time series data based on the M sets of historical window data and the M sets of predicted data; wherein, one set of historical window data corresponds to one set of predicted data, the length of each set of historical window data is different, the M sets of historical window data and the M sets of predicted data both belong to the first time series data, and M is an integer greater than 1 and less than N; the first feature information includes at least one of the correlation between each set of historical window data and the corresponding set of predicted data, and the similarity of self-attention between each set of historical window data and the corresponding set of predicted data. The second determining submodule is used to determine the timing period of the first time series data based on the N data points at the N time points.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor; characterized in that the processor is configured to read the program from the memory to implement the steps of the timing window determination method as described in any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps in the timing window determination method as described in any one of claims 1 to 7.