A method, device, equipment and medium for predicting missing data in time series
By splitting the time series and building an evaluation data prediction model, the problem of missing data and noise effects in the time series is solved, and the prediction effect is improved.
Patent Information
- Application Number
- CN202410504696.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-24
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-04-24
AI Technical Summary
The presence of missing data and noise in the time series leads to poor prediction of missing data by machine learning models.
By splitting the target time series into multiple sub-time series, data prediction models are constructed and evaluated, and better performing models are selected for missing data prediction.
Improves the accuracy of missing data prediction and is suitable for time series with complex and changing trends.
Smart Images

Figure CN118394812B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data technology, and in particular to a method, device, equipment and medium for predicting missing data in a time series. Background Art
[0002] The commonly used missing data filling methods now predict and fill in missing data based on machine learning algorithms. Common machine learning filling methods include missing value filling algorithms based on the nearest neighbor method (KNN), recurrent neural network (RNN), random forest and matrix decomposition.
[0003] However, in addition to missing data, time series, taking financial data as an example, often contain problems such as noise and outliers due to the complex and non-uniform environment in which the data is generated. These interferences will greatly affect the prediction effect of the machine learning model. Summary of the invention
[0004] In view of this, the purpose of the present application is to provide a method, device, equipment and medium for predicting missing data in a time series, so as to solve the problem that interference in the time series causes the machine learning model to have poor prediction effect on missing data.
[0005] The present application embodiment provides a method for predicting missing data in a time series, the method comprising:
[0006] According to the missing time positions corresponding to the missing data values in the target time series, the target time series is split into at least one first sub-time series and at least one second sub-time series; wherein the target time series is a sequence formed by determining the time positions according to the time when the data values are generated and arranging them according to the time positions; and there is at least one missing data value in the target time series;
[0007] For each first sub-time series, construct a corresponding first data prediction model using the first sub-time series;
[0008] Performing model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain an evaluation index value of the first data prediction model;
[0009] Determining a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model;
[0010] For each missing time position, the data value of the missing time position is predicted based on the first data prediction model constructed based on the first sub-time series adjacent to the missing time position and the target data prediction model.
[0011] Further, according to the missing time positions corresponding to the missing data values in the target time series, the target time series is split into at least one first sub-time series and at least one second sub-time series, including:
[0012] For each missing time position, if there are no other consecutive missing time positions before and after the missing time position in the target time sequence, the missing time position is taken as a breakpoint;
[0013] If there are other consecutive missing time positions before and after the missing time position in the target time sequence, the multiple consecutive missing time positions are taken as a breakpoint;
[0014] Dividing the target time series into multiple sub-time series according to breakpoints;
[0015] According to the sequence lengths of the multiple sub-time series, each sub-time series is determined as a first sub-time series or a second sub-time series.
[0016] Further, the determining each sub-time series as a first sub-time series or a second sub-time series according to the sequence lengths of the multiple sub-time series includes:
[0017] Determine a sequence whose sequence length is greater than a preset length threshold among the multiple sub-time series as a first sub-time series;
[0018] A sequence whose sequence length is less than or equal to a preset length threshold among the multiple sub-time series is determined as a second sub-time series.
[0019] Furthermore, the determining each sub-time series as the first sub-time series or the second sub-time series according to the sequence length of the multiple sub-time series further includes:
[0020] When the sequence lengths of the multiple sub-time series are all greater than a preset length threshold, or when the sequence lengths of the multiple sub-time series are all less than or equal to the preset length threshold, comparing the sequence lengths of the multiple sub-time series;
[0021] The first M sub-time sequences with the longest sequence length among the multiple sub-time sequences are determined as first sub-time sequences, and the remaining sub-time sequences are determined as second sub-time sequences.
[0022] Furthermore, for each missing time position, predicting the data value of the missing time position based on the first data prediction model constructed by the first sub-time series adjacent to the missing time position and the target data prediction model includes:
[0023] For each missing time position, a first sub-time series located to the left of the missing time position and adjacent to the missing time position is selected from the first sub-time series, and a first data prediction model constructed by the selected first sub-time series is determined as a first candidate data prediction model;
[0024] Filter out a data prediction model whose first sub-time series of the constructed model is located to the left of the missing time position from the target data prediction model, and determine the filtered data prediction model as a second candidate data prediction model;
[0025] Merge and remove duplicates of the first candidate data prediction model and the second candidate data prediction model;
[0026] Use each data prediction model obtained after merging and deduplication to predict the data value of the missing time position, and obtain the prediction value of each data prediction model;
[0027] The average value of the prediction values of each data prediction model is determined as the data value corresponding to the missing time position.
[0028] Furthermore, the performing model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain the evaluation index value of the first data prediction model includes:
[0029] Filtering out a sub-time series located after the first sub-time series corresponding to the first data prediction model from the other sub-time series, and using it as the sub-time series to be predicted; wherein the other sub-time series is the second sub-time series, or the other sub-time series is the other first sub-time series and the second sub-time series;
[0030] Use the first data prediction model to simulate and predict each sub-time series to be predicted, and obtain an evaluation index value of each sub-time series to be predicted for the first data prediction model;
[0031] The average value of the evaluation index value of each to-be-predicted sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model.
[0032] Further, determining a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model includes:
[0033] According to the evaluation index value of each first data prediction model, the top N data prediction models with the best performance are screened out from the first data prediction models as the target data prediction models.
[0034] Furthermore, the performing model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain the evaluation index value of the first data prediction model also includes:
[0035] For each missing time position, filter out a plurality of target second sub-time sequences closest to the missing time position from the second sub-time sequence;
[0036] Use the first data prediction model to simulate and predict each target second sub-time series respectively, and obtain an evaluation index value of each target second sub-time series for the first data prediction model;
[0037] The average value of the evaluation index value of each target second sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model for the missing time position.
[0038] Furthermore, the step of determining a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model further includes:
[0039] For each missing time position, according to the evaluation index value of each first data prediction model for the missing time position, the top N first data prediction models with the best performance for the missing time position are selected as the target data prediction model to predict the data value of the missing time position.
[0040] The present application also provides a device for predicting missing data in a time series, the device comprising:
[0041] a splitting module, configured to split the target time series into at least one first sub-time series and at least one second sub-time series according to the missing time positions corresponding to the missing data values in the target time series; wherein the target time series is a sequence formed by determining the time positions according to the time when the data values are generated and arranging them according to the time positions; and there is at least one missing data value in the target time series;
[0042] A modeling module, for building a corresponding first data prediction model for each first sub-time series using the first sub-time series;
[0043] An evaluation module, used to perform model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series, to obtain an evaluation index value of the first data prediction model;
[0044] A determination module, configured to determine a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model;
[0045] The prediction module is used to predict the data value of each missing time position based on the first data prediction model constructed by the first sub-time series adjacent to the missing time position and the target data prediction model.
[0046] An embodiment of the present application also provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the steps of a method for predicting missing data in a time series as described above are performed.
[0047] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for predicting missing data in a time series as described above are performed.
[0048] The embodiments of the present application provide a method, device, equipment and medium for predicting missing data in a time series. By using a part of the sub-time series obtained by splitting to build a data prediction model, and then using another part of the sub-time series for model evaluation, a data prediction model with better performance can be screened out. Taking into account the trend of time series data, for each missing time position, a data prediction model constructed by an adjacent sub-time series is also screened out in combination with the position information. Combining these two types of data prediction models to predict missing data can improve the prediction effect and obtain more accurate prediction results.
[0049] Among them, selecting longer and more complete sub-time series to build a data prediction model can ensure the effectiveness of the constructed model; without additional data, using the split shorter sub-time series for model evaluation can make full use of the original data and ensure that the evaluation results are more targeted.
[0050] In addition, the present application also selects the data prediction model with the best prediction performance for each missing time position as the target data prediction model for subsequent data prediction for the missing time position, which can obtain more accurate prediction results and is suitable for time series with more complex and changeable trends.
[0051] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 A flowchart of a method for predicting missing data in a time series provided by an embodiment of the present application is shown;
[0054] Figure 2 A flow chart showing a method for filling missing data in a time series provided by an embodiment of the present application is shown;
[0055] Figure 3 A schematic diagram showing the structure of a device for predicting missing data in a time series provided by an embodiment of the present application is shown;
[0056] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0057] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application usually described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, each other embodiment obtained by those skilled in the art without making creative work belongs to the scope of protection of the present application.
[0058] Research has found that the commonly used missing data filling methods now predict and fill in missing data based on machine learning algorithms. Common machine learning filling methods include missing value filling algorithms based on the nearest neighbor method (KNN), recurrent neural network (RNN), random forest and matrix decomposition.
[0059] However, in addition to missing data, time series, taking financial data as an example, often contain problems such as noise and outliers due to the complex and non-uniform environment in which the data is generated. These interferences will greatly affect the prediction effect of the machine learning model.
[0060] Based on this, an embodiment of the present application provides a method for predicting missing data in a time series to solve the problem that interference in the time series causes the machine learning model to have poor prediction effect on missing data.
[0061] See also Figure 1 , Figure 1 This is a flow chart of a method for predicting missing data in a time series provided by an embodiment of the present application. Figure 1 As shown in , the prediction method provided in the embodiment of the present application includes:
[0062] S101. Split a target time series into at least one first sub-time series and at least one second sub-time series according to missing time positions corresponding to missing data values in the target time series.
[0063] Among them, time series refers to a series in which the time position of each data value of the same statistical indicator is determined in the order of their occurrence, and each data value is arranged according to the time position. However, there is at least one missing data value in the target time series of the embodiment of the present application, that is, there is at least one missing time position in the target time series.
[0064] In this step, the target time series can be split into multiple sub-time series using each missing time position as a breakpoint. In a possible implementation, step S101 may include:
[0065] For each missing time position, if there are no other continuous missing time positions before and after the missing time position in the target time sequence, then the missing time position is taken as a breakpoint; if there are other continuous missing time positions before and after the missing time position in the target time sequence, then multiple continuous missing time positions are taken as a breakpoint; the target time series is divided into multiple sub-time series according to the breakpoints; and each sub-time series is determined as the first sub-time series or the second sub-time series according to the sequence lengths of the multiple sub-time series.
[0066] Exemplarily, a target time series T with missing values is selected, T = {q1, q2, q3, q4, m1, q5, q6, m2, m3, ...}, q1 ... qj are non-missing data, m1 ... mi are missing data, i is an integer greater than 1, j is an integer greater than 1, i < <j。
[0067] Taking the missing values mi corresponding to all missing time positions in the sequence as breakpoints, the target time series T is divided into s segments, such as T1 = {q1, q2, q3, q4}, T2 = {q5, q6}, ..., s < = i + 1, and s is an integer greater than or equal to 1. At the same time, the breakpoint segmentation data information is saved for subsequent algorithm selection based on the segmentation position.
[0068] In the process of sequence segmentation, if there are no other continuous missing time positions before and after the target time sequence for the missing time position, that is, the breakpoints are not continuous in the time sequence, then each breakpoint divides the sequence into two left and right subsequence fragments, such as: {m1: [T1, T2], m2: [T2, T3], ..., mi: [Ts-1, Ts]}. If there are other continuous missing time positions before and after the target time sequence for the missing time position, that is, the breakpoints are continuous in the time sequence, then several continuous breakpoints are taken as a breakpoint, and the sequence is divided into two left and right subsequence fragments, such as: {m2: [T2, T3], m3: [T2, T3], ..., mi: [T2, T3]}.
[0069] The specific sequence segmentation is summarized as follows:
[0070]
[0071] After that, the sequence length Ls=count(Ts) of each of the s sub-time series is calculated. Here, a longer and more complete sub-time series is selected as the first sub-time series for building a data prediction model, which can ensure the effect of the built model; without additional data, the shorter sub-time series is used as the second sub-time series for model evaluation, which can make full use of the original data and ensure that the evaluation results are more targeted to the target time series.
[0072] Further, determining each sub-time series as the first sub-time series or the second sub-time series according to the sequence lengths of the multiple sub-time series may include:
[0073] Method 1: Determine a sequence whose sequence length is greater than a preset length threshold among the multiple sub-time series as a first sub-time series; and determine a sequence whose sequence length is less than or equal to the preset length threshold among the multiple sub-time series as a second sub-time series.
[0074] This method selects the sequence whose length is greater than the preset length threshold k as the first sub-time series for building the data prediction model; selects the sequence whose length is less than or equal to the preset length threshold k as the second sub-time series for forming the model test set, so as to quickly classify the sub-time series. The preset length threshold can be set according to the actual time series situation.
[0075] Method 2: When the sequence lengths of the multiple sub-time series are all greater than a preset length threshold, or when the sequence lengths of the multiple sub-time series are all less than or equal to the preset length threshold, compare the sequence lengths of the multiple sub-time series; determine the first M sub-time series with the longest sequence length among the multiple sub-time series as the first sub-time series, and determine the remaining sub-time series as the second sub-time series.
[0076] Since there are various possibilities for data sequences in business scenarios, it is difficult to meet the differentiation requirements by setting a fixed length threshold, that is, the above-mentioned method of presetting the length threshold is difficult to distinguish the first sub-time series from the second sub-time series in some cases. For example, when the sequence lengths of multiple sub-time series are all greater than the preset length threshold, or when the sequence lengths of the multiple sub-time series are all less than or equal to the preset length threshold, the embodiment of the present application determines the first M (M is a positive integer) sub-time series with the longest sequence length as the first sub-time series, and determines the remaining sub-time series as the second sub-time series by length comparison.
[0077] In addition, to ensure the effect of missing value prediction, before step S101, the prediction method also includes: determining the data missing rate of the target time series; if the data missing rate is less than the preset threshold, the prediction method is used to predict the missing data, thereby ensuring that the prediction is meaningful. Here, the preset threshold can be set as needed. Preferably, in the embodiment of the present application, it is set to 30%. This is because the present application has determined through experiments that below a data missing rate of 30%, the time series predicted and re-filled using the prediction method is closer to the data trend of the real time series, and the prediction effect is good; but after the data missing rate exceeds 30%, due to too much data missing, the time series predicted and re-filled using the prediction method is quite different from the real time series, and the filling is meaningless.
[0078] S102: For each first sub-time series, construct a corresponding first data prediction model using the first sub-time series.
[0079] Optionally, the embodiment of the present application uses the Prophet model as a data prediction model. The Prophet model considers the trend, periodicity, and seasonality of the time series data before and after, and can adaptively update the model to deal with the impact of noise and outliers, making the prediction of missing values more accurate.
[0080] In this step, p first sub-time series whose sequence length is greater than a preset length threshold k are selected to construct p first data prediction models:
[0081]
[0082] Wherein, k<=j-1, p is greater than 1 and less than s; the model can be constructed using time series using relevant methods in the prior art, and this application does not limit this.
[0083] S103: Perform model evaluation on the first data prediction model based on other second sub-time series other than the first sub-time series to obtain an evaluation index value of the first data prediction model.
[0084] In this step, for each first data prediction model constructed, a second sub-time series or a second sub-time series and other first sub-time series with a sequence length less than a preset length threshold k is selected for simulation prediction. For example, for a second sub-time series, a data value corresponding to a certain time position is selected from the second sub-time series as the value to be predicted; the first data prediction model is used to predict the data value to be predicted at the time position based on the data value before the time position in the second sub-time series. Then, the data value at the time position in the second sub-time series is taken as the true value, and the indicator value of the first data prediction model for the selected evaluation indicator is determined by comparing the true value with the predicted data value. Among them, the evaluation indicator can be set as needed, such as MAPE, MSE, etc. Taking MAPE as an example, MAPE refers to the mean absolute percentage error, which is a relative measure that uses absolute values to avoid the offset of positive and negative errors. The formula is expressed as follows:
[0085]
[0086] Where M represents the mean absolute percentage error of MAPE, n represents the number of selected data values to be predicted, and A t represents the actual data value in the second sub-time series, F t Represents the data value predicted by the first data prediction model.
[0087] In one example, step S103 may include:
[0088] A sub-time series located after the first sub-time series corresponding to the first data prediction model is selected from the other sub-time series, and used as the sub-time series to be predicted; wherein the other sub-time series is the second sub-time series, or the other sub-time series is other first sub-time series and second sub-time series; each sub-time series to be predicted is simulated and predicted using the first data prediction model to obtain an evaluation index value of each sub-time series to be predicted for the first data prediction model; and an average value of the evaluation index value of each sub-time series to be predicted for the first data prediction model is determined as the evaluation index value of the first data prediction model.
[0089] It should be noted that the data prediction model predicts future data based on historical data. For example, the data prediction model obtained by modeling the data from 1990 to 2000 can only predict data after 1990, but the model does not support predicting data before 1990. Therefore, first, each second sub-time series after the first sub-time series corresponding to the first data prediction model can be screened out and used as the sub-time series to be predicted for evaluating the first data prediction model; or, each first sub-time series and second sub-time series after the first sub-time series corresponding to the first data prediction model can be screened out and used as the sub-time series to be predicted for evaluating the first data prediction model, so as to make more effective use of the original data.
[0090] In this way, the prediction conditions of the first data prediction model for each time position in the time series can be comprehensively considered to determine the evaluation index value of the first data prediction model more comprehensively and accurately.
[0091] S104: Determine a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model.
[0092] In this step, according to the evaluation index value of each first data prediction model, the model with the best prediction performance can be screened out from the first data prediction models as the target data prediction model for subsequent use. That is, according to the evaluation index value of each first data prediction model, the top N data prediction models with the best performance are screened out from the first data prediction models as the target data prediction model.
[0093] Taking MAPE as an example, the smaller the MAPE value, the higher the model prediction accuracy and the better the performance. Therefore, the first N (N is a positive integer greater than 1) data prediction models with the smallest MAPE values should be selected as the target data prediction models.
[0094] Furthermore, step S103 may also include:
[0095] For each missing time position, multiple target second sub-time series closest to the missing time position are screened out from the second sub-time series; the first data prediction model is used to perform simulation prediction on each target second sub-time series respectively to obtain an evaluation index value of each target second sub-time series for the first data prediction model; the average value of the evaluation index value of each target second sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model for the missing time position.
[0096] That is, for each missing time position, the evaluation index value of the missing time position is determined through the prediction performance of each data prediction model for the time series near the missing time position.
[0097] Correspondingly, for step S104, for each missing time position, according to the evaluation index value of each data prediction model to be tested for the missing time position, the top N data prediction models to be tested that perform best for the missing time position can be screened out as the target data prediction models corresponding to the missing time position, so as to predict the data value of the missing time position.
[0098] This is because the present application takes into account that due to the close temporal connection of the data values in the time series, the data change trends reflected by data with similar positions are likely to be more similar, and the data change trends reflected by data with distant positions may be quite different. Therefore, when selecting the best performing model as the target data prediction model, the influence of the position can be further considered, that is, for each missing time position, the data prediction model with the best prediction performance in the adjacent sub-time series is selected for the subsequent data prediction for the missing time position.
[0099] S105. For each missing time position, predict the data value of the missing time position based on the first data prediction model constructed by the first sub-time series adjacent to the missing time position and the target data prediction model.
[0100] In this step, for each missing time position, the data value of the missing time position can be predicted based on the first data prediction model corresponding to the first sub-time series adjacent to the left side of the missing time position in the target time series, and the target data prediction model; the data value of the missing time position is determined by combining the data values predicted by each data prediction model; thereafter, the data value can be filled into the missing time position to make the target time series more complete, which is helpful for subsequent data analysis applications.
[0101] In a possible implementation, step S105 may include:
[0102] For each missing time position, a first sub-time series located on the left side of the missing time position and adjacent to the missing time position is screened out from the first sub-time series, and a first data prediction model constructed by the screened out first sub-time series is determined as a first candidate data prediction model; a data prediction model of the first sub-time series of the constructed model located on the left side of the missing time position is screened out from the target data prediction model, and the screened out data prediction model is determined as a second candidate data prediction model; the first candidate data prediction model and the second candidate data prediction model are merged and deduplicated; each data prediction model obtained after merging and deduplicating is used to predict the data value of the missing time position, respectively, to obtain a predicted value of each data prediction model; and an average value of the predicted values of each data prediction model is determined as the data value corresponding to the missing time position.
[0103] In one example, for a missing time position, a part of the target data prediction models P1, P2 and P3 whose first sub-time series of the constructed model is located on the left side of the missing time position are selected from multiple target data prediction models, and the first candidate data prediction model constructed by the first sub-time series located on the left side of the missing time position and adjacent to the missing time position is P4; these four models are not repeated, and the data value of the missing time position is predicted using these four models respectively to obtain predicted values y1, y2, y3 and y4; the average value of these four predicted values is determined as the data value y corresponding to the missing time position. The way of taking the average value can be the arithmetic mean or the weighted mean, etc., which is not limited in this application.
[0104] See also Figure 2 , Figure 2 This is a flow chart of a method for filling missing data in a time series provided by an embodiment of the present application. Figure 2 As shown in , the filling method provided by the embodiment of the present application includes:
[0105] Select a time series T with missing values; determine whether the missing rate of the time series is less than 30%. If so, start automatic filling of missing values; divide the time series T into s subsequence segments according to the missing time positions in the time series T, and calculate the sequence length Ls of each subsequence segment; determine whether Ls is greater than or equal to k: construct p Prophet-based time series models for the p subsequence segments greater than or equal to k respectively; use the subsequence segments less than k as the model test set; use the test set to test the model, evaluate the model based on the test results, and select the top three Prophet models with the smallest MAPE; when predicting, for a breakpoint corresponding to a missing time position, use a Prophet model trained with a subsequence segment that is the nearest neighbor to the left of the breakpoint, and the top three selected Prophet models for prediction, and if there are repeated models, merge them to remove duplicates; finally, use the arithmetic mean of the predicted values of the four models to fill the missing time position.
[0106] An embodiment of the present application provides a method for predicting missing data in a time series. A data prediction model is constructed using a part of the sub-time series obtained by splitting, and another part of the sub-time series is used for model evaluation, thereby screening out a data prediction model with better performance. Taking into account the trend of time series data, for each missing time position, the data prediction model constructed by the adjacent sub-time series is also screened out in combination with the position information. The missing data is predicted by combining two types of data prediction models with good performance and similar constructed data, thereby improving the prediction effect and obtaining more accurate prediction results.
[0107] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of a device for predicting missing data in a time series provided by an embodiment of the present application. Figure 3 As shown in , the prediction device 300 includes:
[0108] The splitting module 310 is used to split the target time series into at least one first sub-time series and at least one second sub-time series according to the missing time positions corresponding to the missing data values in the target time series; wherein the target time series is a sequence formed by determining the time positions according to the time when the data values are generated and arranging them according to the time positions; and there is at least one missing data value in the target time series;
[0109] A modeling module 320, for building a corresponding first data prediction model using each first sub-time series;
[0110] An evaluation module 330, configured to perform a model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series, to obtain an evaluation index value of the first data prediction model;
[0111] A determination module 340, configured to determine a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model;
[0112] The prediction module 350 is used to predict the data value of each missing time position based on the first data prediction model constructed by the first sub-time series adjacent to the missing time position and the target data prediction model.
[0113] Further, when the splitting module 310 is used to split the target time series into at least one first sub-time series and at least one second sub-time series according to the missing time positions corresponding to the missing data values in the target time series, the splitting module 310 is used to:
[0114] For each missing time position, if there are no other consecutive missing time positions before and after the missing time position in the target time sequence, the missing time position is taken as a breakpoint;
[0115] If there are other consecutive missing time positions before and after the missing time position in the target time sequence, the multiple consecutive missing time positions are taken as a breakpoint;
[0116] Dividing the target time series into multiple sub-time series according to breakpoints;
[0117] Determine a sequence whose sequence length is greater than a preset length threshold among the multiple sub-time series as a first sub-time series;
[0118] According to the sequence lengths of the multiple sub-time series, each sub-time series is determined as a first sub-time series or a second sub-time series.
[0119] Further, when the splitting module 310 is used to determine each sub-time series as the first sub-time series or the second sub-time series according to the sequence length of the multiple sub-time series, the splitting module 310 is used to:
[0120] Determine a sequence whose sequence length is greater than a preset length threshold among the multiple sub-time series as a first sub-time series;
[0121] A sequence whose sequence length is less than or equal to a preset length threshold among the multiple sub-time series is determined as a second sub-time series.
[0122] Furthermore, when the splitting module 310 is used to determine each sub-time series as the first sub-time series or the second sub-time series according to the sequence length of the multiple sub-time series, the splitting module 310 is also used to:
[0123] When the sequence lengths of the multiple sub-time series are all greater than a preset length threshold, or when the sequence lengths of the multiple sub-time series are all less than or equal to the preset length threshold, comparing the sequence lengths of the multiple sub-time series;
[0124] The first M sub-time sequences with the longest sequence length among the multiple sub-time sequences are determined as first sub-time sequences, and the remaining sub-time sequences are determined as second sub-time sequences.
[0125] Further, when the prediction module 350 is used to predict the data value of each missing time position based on the first data prediction model constructed by the first sub-time series adjacent to the missing time position and the target data prediction model, the prediction module 350 is used to:
[0126] For each missing time position, a first sub-time series located to the left of the missing time position and adjacent to the missing time position is selected from the first sub-time series, and a first data prediction model constructed by the selected first sub-time series is determined as a first candidate data prediction model;
[0127] Filter out a data prediction model whose first sub-time series of the constructed model is located to the left of the missing time position from the target data prediction model, and determine the filtered data prediction model as a second candidate data prediction model;
[0128] Merge and remove duplicates of the first candidate data prediction model and the second candidate data prediction model;
[0129] Use each data prediction model obtained after merging and deduplication to predict the data value of the missing time position, and obtain the prediction value of each data prediction model;
[0130] The average value of the prediction values of each data prediction model is determined as the data value corresponding to the missing time position.
[0131] Further, when the evaluation module 330 is used to perform model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain the evaluation index value of the first data prediction model, the evaluation module 330 is used to:
[0132] Filtering out a sub-time series located after the first sub-time series corresponding to the first data prediction model from the other sub-time series, and using it as the sub-time series to be predicted; wherein the other sub-time series is the second sub-time series, or the other sub-time series is the other first sub-time series and the second sub-time series;
[0133] Use the first data prediction model to simulate and predict each sub-time series to be predicted, and obtain an evaluation index value of each sub-time series to be predicted for the first data prediction model;
[0134] The average value of the evaluation index value of each to-be-predicted sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model.
[0135] Further, when the determination module 340 is used to determine the target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model, the determination module 340 is used to:
[0136] According to the evaluation index value of each first data prediction model, the top N data prediction models with the best performance are screened out from the first data prediction models as the target data prediction models.
[0137] Furthermore, when the evaluation module 330 is used to perform model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain the evaluation index value of the first data prediction model, the evaluation module 330 is also used to:
[0138] For each missing time position, filter out a plurality of target second sub-time sequences closest to the missing time position from the second sub-time sequence;
[0139] Use the first data prediction model to simulate and predict each target second sub-time series respectively, and obtain an evaluation index value of each target second sub-time series for the first data prediction model;
[0140] The average value of the evaluation index value of each target second sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model for the missing time position.
[0141] Further, when the determination module 340 is used to determine the target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model, the determination module is used to:
[0142] For each missing time position, according to the evaluation index value of each first data prediction model for the missing time position, the top N first data prediction models with the best performance for the missing time position are selected as the target data prediction model to predict the data value of the missing time position.
[0143] See also Figure 4 , Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown in , the electronic device 400 includes a processor 410 , a memory 420 and a bus 430 .
[0144] The memory 420 stores machine-readable instructions executable by the processor 410. When the electronic device 400 is running, the processor 410 communicates with the memory 420 via the bus 430. When the machine-readable instructions are executed by the processor 410, the above-mentioned Figure 1 as well as Figure 2 The steps of a method for predicting missing data in a time series in the method embodiment shown are specifically implemented in accordance with the method embodiment and will not be described in detail here.
[0145] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the computer program can execute the above-mentioned Figure 1 as well as Figure 2 The steps of a method for predicting missing data in a time series in the method embodiment shown are specifically implemented in accordance with the method embodiment and will not be described in detail here.
[0146] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0147] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0148] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0149] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0150] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or in other words, the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0151] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for predicting missing data in a time series, characterized in that: The prediction method comprises: According to the missing time positions corresponding to the missing data values in the target time series, the target time series is split into at least one first sub-time series and at least one second sub-time series; wherein the target time series is a sequence formed by determining the time positions according to the time when the data values are generated and arranging them according to the time positions; and there is at least one missing data value in the target time series; For each first sub-time series, construct a corresponding first data prediction model using the first sub-time series; Performing model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain an evaluation index value of the first data prediction model; Determining a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model; For each missing time position, the data value of the missing time position is predicted based on the first data prediction model constructed based on the first sub-time series adjacent to the missing time position and the target data prediction model.
2. The prediction method according to claim 1, characterized in that: Splitting the target time series into at least one first sub-time series and at least one second sub-time series according to missing time positions corresponding to missing data values in the target time series, including: For each missing time position, if there are no other consecutive missing time positions before and after the missing time position in the target time sequence, the missing time position is taken as a breakpoint; If there are other consecutive missing time positions before and after the missing time position in the target time sequence, the multiple consecutive missing time positions are taken as a breakpoint; Dividing the target time series into multiple sub-time series according to breakpoints; According to the sequence lengths of the multiple sub-time series, each sub-time series is determined as a first sub-time series or a second sub-time series.
3. The prediction method according to claim 2, characterized in that: The step of determining each sub-time series as a first sub-time series or a second sub-time series according to the sequence lengths of the multiple sub-time series comprises: Determine a sequence whose sequence length is greater than a preset length threshold among the multiple sub-time series as a first sub-time series; A sequence whose sequence length is less than or equal to a preset length threshold among the multiple sub-time series is determined as a second sub-time series.
4. The prediction method according to claim 3, characterized in that: The step of determining each sub-time series as a first sub-time series or a second sub-time series according to the sequence lengths of the multiple sub-time series further includes: When the sequence lengths of the multiple sub-time series are all greater than a preset length threshold, or when the sequence lengths of the multiple sub-time series are all less than or equal to the preset length threshold, comparing the sequence lengths of the multiple sub-time series; The first M sub-time sequences with the longest sequence length among the multiple sub-time sequences are determined as first sub-time sequences, and the remaining sub-time sequences are determined as second sub-time sequences.
5. The prediction method according to claim 1, characterized in that: The step of predicting the data value of each missing time position based on the first data prediction model constructed from the first sub-time series adjacent to the missing time position and the target data prediction model comprises: For each missing time position, a first sub-time series located to the left of the missing time position and adjacent to the missing time position is selected from the first sub-time series, and a first data prediction model constructed by the selected first sub-time series is determined as a first candidate data prediction model; Filter out a data prediction model whose first sub-time series of the constructed model is located to the left of the missing time position from the target data prediction model, and determine the filtered data prediction model as a second candidate data prediction model; Merge and remove duplicates of the first candidate data prediction model and the second candidate data prediction model; Use each data prediction model obtained after merging and deduplication to predict the data value of the missing time position, and obtain the prediction value of each data prediction model; The average value of the prediction values of each data prediction model is determined as the data value corresponding to the missing time position.
6. The prediction method according to claim 1, characterized in that: The performing model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain an evaluation index value of the first data prediction model includes: Filtering out a sub-time series located after the first sub-time series corresponding to the first data prediction model from the other sub-time series, and using it as the sub-time series to be predicted; wherein the other sub-time series is the second sub-time series, or the other sub-time series is the other first sub-time series and the second sub-time series; Use the first data prediction model to simulate and predict each sub-time series to be predicted, and obtain an evaluation index value of each sub-time series to be predicted for the first data prediction model; The average value of the evaluation index value of each to-be-predicted sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model.
7. The prediction method according to claim 1, characterized in that: The step of determining a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model includes: According to the evaluation index value of each first data prediction model, the top N data prediction models with the best performance are screened out from the first data prediction models as the target data prediction models.
8. The prediction method according to claim 6, characterized in that: The step of performing model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series to obtain an evaluation index value of the first data prediction model further includes: For each missing time position, filter out a plurality of target second sub-time sequences closest to the missing time position from the second sub-time sequence; Use the first data prediction model to simulate and predict each target second sub-time series respectively, and obtain an evaluation index value of each target second sub-time series for the first data prediction model; The average value of the evaluation index value of each target second sub-time series for the first data prediction model is determined as the evaluation index value of the first data prediction model for the missing time position.
9. The prediction method according to claim 8, characterized in that: The step of determining a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model further includes: For each missing time position, according to the evaluation index value of each first data prediction model for the missing time position, the top N first data prediction models with the best performance for the missing time position are selected as the target data prediction model to predict the data value of the missing time position.
10. A prediction device for missing data in a time series, characterized in that: The prediction device comprises: a splitting module, configured to split the target time series into at least one first sub-time series and at least one second sub-time series according to the missing time positions corresponding to the missing data values in the target time series; wherein the target time series is a sequence formed by determining the time positions according to the time when the data values are generated and arranging them according to the time positions; and there is at least one missing data value in the target time series; A modeling module, for building a corresponding first data prediction model for each first sub-time series using the first sub-time series; An evaluation module, used to perform model evaluation on the first data prediction model based on other sub-time series other than the first sub-time series, to obtain an evaluation index value of the first data prediction model; A determination module, configured to determine a target data prediction model from the first data prediction models according to the evaluation index value of each first data prediction model; The prediction module is used to predict the data value of each missing time position based on the first data prediction model constructed by the first sub-time series adjacent to the missing time position and the target data prediction model.
11. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of a method for predicting missing data in a time series as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for predicting missing data in a time series as claimed in any one of claims 1 to 9 are executed.
Citation Information
Patent Citations
Data missing repairing method and device
CN106156260A
Time sequence processing system and method and computer readable storage medium
CN116470485A