A Method and System for Filling Missing Values in Time Series Based on Diffusion Model

By introducing an adaptive noise weight optimization strategy into the diffusion model, the problem of lack of flexibility in the existing noise weight algorithm is solved, and the model's adaptability and filling effect of different temporal data sets are improved.

CN119537816BActive Publication Date: 2025-06-10NORTHWEST UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510104203.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-06-10
Estimated Expiration
2045-01-23

AI Technical Summary

Technical Problem

The existing noise weight algorithms lack flexibility and are difficult to adapt to different data sets, resulting in poor effectiveness of diffusion models when filling multivariable time series data.

Method used

Through the adaptive noise weight optimization strategy, the model can independently learn the weights of different noise levels, thereby adapting to different timing data sets. The specific methods include evaluating the difficulty of noise learning through the verification set during the training process and dynamically adjusting the weight of the noise level.

Benefits of technology

The model's filling effect on different data sets is improved, the applicability and universality of the model is enhanced, the learning effect of different levels of noise is balanced, and the overall filling performance is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537816B_ABST
    Figure CN119537816B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of filling missing values in multivariate time series data, and discloses a method and system for filling missing values in time series based on a diffusion model. The method includes: Step 1, dividing the time series data set into a training set, a validation set, and a test set, and performing data processing on each time series data to obtain a 01 mask matrix of each time series data, as well as the target to be filled and the observable time series data; Step 2, the training process to obtain a trained denoising network; Step 3, inputting the result of the forward noise addition process corresponding to the test set into the trained denoising network obtained in Step 2, and outputting the result of reverse denoising as the filled time series data. The present invention realizes the flexibility of noise weight setting and enhances the applicability and generality of the model to different time series data sets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of filling missing values in multivariate time series data, and specifically relates to a method and system for filling missing values in time series based on a diffusion model. Background Art

[0002] Multivariate time series data widely exists in various practical fields such as finance, healthcare, and transportation. However, due to human errors or signal transmission problems, time series data usually contains missing values. These missing values will have an adverse impact on downstream tasks such as time series prediction. Therefore, how to use observable data to fill in the missing values has become an important research direction.

[0003] With the continuous development of deep learning technology, people use deep learning models such as Recurrent Neural Network (RNN) and Generative Adversarial Network (GAN) to fill in the missing data. However, when faced with complex and non-stationary multivariate time series data, the filling performance of these models is relatively poor. As an emerging probability-based deep learning generative model, the diffusion model can better handle non-stationary and noisy time series data. The diffusion model continuously adds different levels of noise to the data during the forward process, and then gradually removes the added noise during the reverse process to learn the distribution of the data. However, the diffusion model usually adds hundreds of different levels of noise to the data, and the optimization directions of different levels of noise are different and their impacts on the model filling effect are also different. Therefore, if the same learning weight is assigned to all noises during the model learning process, the final effect of the model will not be the best. Existing noise weight algorithms all manually set fixed noise weights. These algorithms lack flexibility, require high expert knowledge to adjust the weights, and are difficult to adapt to different data sets. Summary of the Invention

[0004] The purpose of the present invention is to provide a method and system for filling missing values in time series based on a diffusion model to solve the problems that existing noise weight algorithms lack flexibility and are difficult to adapt to different data sets. The present invention enables the model to autonomously learn the weights of different noise levels, thereby adapting to different time series data sets.

[0005] To achieve the above purpose, the present invention is implemented by adopting the following technical solutions:

[0006] On the one hand, the present invention provides a method for filling missing values in time series based on a diffusion model, specifically including the following steps:

[0007] Step 1, data processing: divide the time series data set into training set, validation set and test set, process each time series data in each part, and obtain the 01 mask matrix corresponding to each time series data , and the target to be filled and observable time series data .

[0008] Step 1 specifically includes the following sub-steps:

[0009] Step 11, given a time series dataset, Represents one of the time series data, where K and L represent the time series data respectively The number and length of channels. Divide the time series data set into three parts: training set, validation set and test set according to a certain ratio;

[0010] Step 12: For each time series data in each part X , construct the time series data according to the location of the missing value X 01 mask matrix of the same shape ,01 mask matrix 0 in the value indicates that the position is missing, and 1 indicates that the value at the position can be observed. Represents time series data The observable values ​​in ;

[0011] Step 13: To facilitate model training and evaluation, according to the 01 mask matrix , using the preset missing pattern and missing rate, in the time series data Add new missing values ​​and record the position of the missing values ​​as 01 mask matrix ;

[0012] Step 14: and Respectively with time series data Perform matrix Hadamard product operation to obtain the target to be filled and observable time series data .

[0013] Step 2, the training process, obtains the trained denoising network, including the following sub-steps:

[0014] Step 21, forward noise addition:

[0015] To observable time series data Add T steps of noise in sequence, with different noise levels added in each step, to construct a noise-added sequence , expressed as , where is the time series data obtained after adding noise in the t th step. When the number of steps T for adding noise approaches infinity, will approach Gaussian white noise. Although increasing the value of T can bring certain performance improvement during training, the model training time and computational cost will also increase. To balance the benefits and costs, T is set to 50 in this embodiment.

[0016] Step 22, Reverse Denoising:

[0017] In the reverse denoising stage, starting from the time series data obtained in Step 21, gradually remove the noise added during the forward noise addition process to obtain the time series data after removing noise at each step. The entire reverse denoising process is , where represents the time series data obtained after denoising in the t-th step, and finally output the time series data , as the filled time series data. Among them, the specific operation of is: input the time series data obtained by denoising in the t-th step, the conditional information Cond, and the current denoising step t into the denoising network to obtain the noise prediction result (abbreviated as ), where t ∈ 1~T; then calculate .

[0018] By iteratively training the loss function value between the optimized noise prediction result in the t-th step and the actually added noise , a trained denoising network is obtained after the training ends.

[0019] Specifically, the loss function to be optimized during training is as follows:

[0020]

[0021] Among them:

[0022] —Loss function.

[0023] —Mathematical expectation.

[0024] —Time series data conforms to data distribution;

[0025] —Data distribution of the time series data during the noise addition process;

[0026] — The actually added noise Meet the data distribution;

[0027] — The weight matrix of the noise at the t-th step, with an initial value of 1.

[0028] As a preferred embodiment of the present invention, during the denoising process, there are T steps of noises with different levels, and the impacts of these noises on the filling performance are different. In the present invention, the loss function regards the learning of T different levels of noises as T optimization tasks, and by assigning different weights to these optimization tasks, the model pays more attention to learning the noises that have a greater impact on the filling effect. The adaptive noise weight optimization strategy is as follows:

[0029] Introduce the adaptive noise weight optimization strategy during the model training process. Specifically, the denoising network is allowed to assign weights by itself according to the difficulty of noise learning. The more difficult the noise is to learn, the more important it is considered and a higher weight needs to be assigned. Since the validation set can initially evaluate the performance of the network model on the unknown data set, the learning effect of the denoising network on the validation set is used to evaluate the learning difficulty of the noise. Specifically, during the model training process, the following first formula is used to set the learning difficulty at the t-th time step in the i-th epoch, and the following second formula is used to set the weight at the t-th time step in the i-th epoch:

[0030]

[0031]

[0032] Where:

[0033] — The loss function value at the t-th time step in the (i - 1)-th epoch of the denoising network on the validation set; t of the denoising network on the validation set;

[0034] — The loss function value at the t-th time step in the (i - 2)-th epoch of the denoising network on the validation set; t of the denoising network on the validation set;

[0035] The weight at the t-th time step in the i-th epoch. During the training process on the training set, it is updated every k epochs using In this embodiment, k = 4. In the calculation of the loss function on the validation set, is always 1. is always 1.

[0036] — The ratio of the loss function values at the t-th time step for two consecutive epochs in the validation set. If the ratio shows a downward trend, it indicates that the loss at the t-th time step decreases rapidly and learning is relatively easy, so a smaller weight should be assigned. Conversely, if it shows an upward trend, it indicates that learning is relatively difficult and a larger weight needs to be assigned;

[0037] — A tuning parameter used to adjust the differences in noise learning at different time steps, The larger it is, the more uniform the weight distribution among different noise tasks will be. When is large enough, the weights of all time step noises will be equal. In the present invention is set to 1.5;

[0038] — A weight normalization parameter to ensure that the sum of the weights of all noise learning tasks is equal to , because T is set to 50 in the present invention, so there are 50 noise learning tasks, and the weight of each noise task is 1 initially, so is set to 50.

[0039] Step 3, the model sampling process.

[0040] Gradually remove the noise added during the forward denoising process from the results of the forward denoising process corresponding to the test set to obtain the time series data after removing the noise at each step; specifically, the specific operation at each step is: input the time series data obtained by denoising at the current step, the conditional information Cond, and the current denoising step number into the trained denoising network obtained in Step 2 to obtain the noise prediction result corresponding to the current step, subtract the noise prediction result corresponding to the current step from the time series data obtained by denoising at the current step to obtain the time series data obtained by denoising at the next step, and the finally obtained result is used as the filled time series data.

[0041] In the second aspect, the present invention provides a time series missing value filling system based on a diffusion model, specifically including the following modules:

[0042] A data processing module for dividing the time series data set into a training set, a validation set, and a test set, and performing data processing on each time series data in each part to obtain the 01 mask matrix corresponding to each time series data , as well as the target to be filled and the observable time series data ;

[0043] A training module for obtaining a trained denoising network, which is implemented using the following operation process:

[0044] Forward denoising:

[0045] Add noise to the observable time series data step by step, with different noise levels added at each step, to construct a noise-added sequence , denoted as , where is the time series data obtained after the t -th step of noise addition;

[0046] Reverse denoising:

[0047] In the reverse denoising stage, starting from the time series data obtained from forward denoising , gradually remove the noise added during the forward noise addition process to obtain the time series data after removing the noise at each step; the entire reverse denoising process is denoted as , where represents the time series data obtained after the t-th step of denoising, and finally output the time series data , as the filled time series data; where, the specific operation of is: input the time series data obtained after the t-th step of denoising, the conditional information Cond, and the current denoising step t into the denoising network to obtain the noise prediction result (abbreviated as ), where t ∈ 1~T; then calculate ;

[0048] By iteratively training the loss function value between the noise prediction result of the t-th step and the actually added noise , a trained denoising network is obtained after the training ends; the loss function to be optimized during the training process is as follows:

[0049]

[0050] where:

[0051] —Loss function;

[0052] —Mathematical expectation;

[0053] —Data distribution of the time series data during the noise addition process;

[0054] —The time series data conforms to the data distribution;

[0055] —The actually added noise Conform to data distribution;

[0056] — The weight matrix of the noise at the t-th step, with an initial value of 1.

[0057] The missing value filling module is used to gradually remove the noise added during the forward denoising process from the result of the forward denoising process corresponding to the test set, and obtain the time series data after removing the noise at each step. Specifically, the operation at each step is as follows: input the time series data obtained by denoising at the current step, the conditional information Cond, and the current denoising step number into the trained denoising network obtained in step 2 to obtain the noise prediction result corresponding to the current step, subtract the noise prediction result corresponding to the current step from the time series data obtained by denoising at the current step to obtain the time series data obtained by denoising at the next step, and the finally obtained result is used as the filled time series data.

[0058] In a third aspect, the present invention provides a computer-readable storage medium storing a computer program, which when executed by a processor, implements the above-mentioned time series missing value filling method based on a diffusion model.

[0059] In a fourth aspect, the present invention provides a computer program product including a computer program / instructions, which when executed by a processor, implements the above-mentioned time series missing value filling method based on a diffusion model.

[0060] Compared with the prior art, the present invention has the following technical effects:

[0061] (1) Different from the traditional fixed noise weight method, the present invention provides an adaptive noise weight method and system based on a diffusion model. When the model runs on different data sets, the present invention can adaptively adjust different weights according to different noise levels, enabling the model to focus on learning the noise levels that have a greater impact on the filling effect. In this way, the learning effects of different levels of noise are balanced, and the overall filling effect of the model is enhanced. Through the adaptive learning method, the flexibility of noise weight setting is achieved, and the applicability and generality of the model to different time series data sets are enhanced.

[0062] (2) Through comparative experiments, multiple fixed weight algorithms and multiple different models are selected as references, and through qualitative and quantitative analysis, it is proved that the algorithm has good effects on time series data sets in multiple different fields, demonstrating the specificity and generality of the adaptive noise weight algorithm in the present invention. Description of the Drawings

[0063] This application can be better understood by referring to the description given below in conjunction with the accompanying drawings, which are included in and form a part of this specification together with the following detailed description.

[0064] Figure 1 It is the structural diagram of the denoising network in the present invention;

[0065] Figure 2 It is the comparison chart of the filling effects of the present invention and the benchmark model CSDI method on the AQI-36 dataset. Detailed implementation manners

[0066] Exemplary embodiments of the present application will be described below in conjunction with the accompanying drawings. For clarity and conciseness, not all features of the actual embodiments are described in the specification. However, it should be understood that many specific decisions specific to the embodiments can be made during the development of any such actual embodiment to achieve the specific goals of the developer, and these decisions may vary with different embodiments.

[0067] Here, it should also be noted that in order to avoid obscuring the present application with unnecessary details, only the device structures closely related to the solution of the present application are shown in the drawings, and other details less related to the present application are omitted.

[0068] It should be understood that the present application is not limited to the described embodiments only due to the following description with reference to the accompanying drawings. In the present application, where feasible, the embodiments can be combined with each other, features can be replaced or borrowed between different embodiments, and one or more features can be omitted in one embodiment.

[0069] The following further elaborates on the specific content of the present invention in conjunction with examples.

[0070] Embodiment 1:

[0071] This embodiment provides a method and system for filling missing values in time series based on a diffusion model. Specifically, it includes the following steps:

[0072] Step 1, data processing. It includes the following sub-steps:

[0073] Step 11, the input time series data is a two-dimensional matrix with a shape size of L*K, representing the length and the number of channels in a time series data respectively.

[0074] Step 12, for each time series data in each part X , a 01 mask matrix of the same size as the input data is obtained according to the position where the missing value is located , in the 01 mask matrix, 0 indicates that the value at this position is a missing value, and 1 indicates that the value at this position can be observed.

[0075] Step 13, based on the 01 mask matrix , according to the pre-set missing patterns and missing rates, randomly set the values of some positions to missing in each channel of the input data according to different missing patterns. Specifically, the missing patterns are random missing or time-continuous missing. Random missing means randomly setting each position in the channel to missing, and time-continuous missing means setting a continuous segment of data in a channel to missing. The missing rate is determined according to experience as needed. Record the positions that are artificially set to missing, so as to obtain the 01 mask matrix .

[0076] Step 14, perform matrix Hadamard product operations on and respectively with the time series data to obtain the target to be filled and the time series data that can be observed after artificially adding missing values.

[0077] Step 2, the model training process.

[0078] Step 21 Forward noise addition:

[0079] Perform noise addition on the observable time series data T times to obtain the noise-added data .

[0080] Specifically, the formulas for forward noise addition are shown as the following two formulas (the second formula is the probability distribution expression form of the first formula)

[0081]

[0082]

[0083] where:

[0084] The joint probability distribution when given the time series data ; The data distribution when given the time series data

[0085] ; The data distribution of the time series data during the noise addition process;

[0086] —The data distribution of the time series data during the noise addition process;

[0087] — Gaussian distribution;

[0088] — Manually set noise intensity table, .

[0089] — Identity matrix, having the same shape as the time series data, with a shape of .

[0090] When T approaches infinity, the final noisy time series data will approach a normal Gaussian distribution.

[0091] Step 22, reverse denoising:

[0092] During the reverse denoising process, starting from the time series data obtained in step 21 gradually remove the noise. . Taking as an example, the denoising process will be introduced in detail.

[0093] We introduce the conditional information , specifically, the conditional information Cond consists of a 01 mask matrix , diffusion time encoding, time position encoding, and feature encoding, where the latter three pieces of information are known information. Input the time series data t after adding noise in the step, the conditional information and the diffusion time step t into the denoising network.

[0094] Specifically, the structure of the denoising network is as Figure 1 shown, including a first module, a second module, a third module, a fourth module, and s residual layers. In the present invention, s is set to 4.

[0095] The first module includes a fully connected layer, a SiLu activation function, a fully connected layer, and a ReLu activation function connected in sequence; the second module includes a 1x1 convolution and a ReLu module connected; the third module includes a 1x1 convolution and a ReLu module connected; the fourth module includes a 1x1 convolution and a ReLu module and a subsequent 1x1 convolution connected; each residual layer includes a time attention module, a channel attention module, a gated activation unit, and a plurality of 1x1 convolution blocks.

[0096] The diffusion time encoding is input into the first module, and the time series data after adding noise (input data) is input into the second module, and is masked by the matrix , the information composed of time position encoding and feature encoding is input into the third module. The output of the first module is convolved by a 1x1 convolution in the current residual layer and then added to the output of the second module. Then, it enters the time attention module in the current residual layer to perform feature extraction in the length dimension, and then enters the channel attention module to perform feature extraction in the channel dimension. After that, it passes through a 1x1 convolution and is added to the output of the third module again. Then, it enters the gated activation unit to screen the feature information to obtain the output features. The output features pass through a 1x1 convolution and are connected to the output of the second module as a residual connection and then output to the next residual layer for processing; in addition, the output features of the current residual layer are also added by skip connection with the output features of each residual layer, and then enter the fourth module for processing. The result obtained is used as the output result of the denoising network: the noise level prediction result 。

[0097] By optimizing the noise level prediction result and the actually added noise the MSE loss between them is used to train the model. The process definition formula for the entire reverse denoising process is:

[0098]

[0099] Where:

[0100] —The distribution of the inverse process with learnable parameters .

[0101] Given the time series data and the conditional information when the joint probability distribution of.

[0102] Given the time series data and the conditional information when the data distribution of.

[0103] The objective function for optimizing the entire noise network is defined as:

[0104]

[0105] Where:

[0106] —Loss function;

[0107] —Mathematical expectation;

[0108] —During the noise addition process, the time series data Data distribution;

[0109] — Time - series data Conform to Data distribution;

[0110] — True added noise Conform to Data distribution;

[0111] — Weight matrix of noise at the t - th step, with an initial value of 1.

[0112] After obtaining the noise prediction result at the t - th step Subtract the noise at the current step to get the result of the previous step. That is .

[0113] During the process of optimizing the objective function of the denoising network, a method of adaptive noise weight optimization is introduced. The adaptive noise weight optimization strategy is as follows:

[0114] Adaptive weight assignment is performed according to the learning difficulty of the model on the validation set. The specific method is: train on the training set, initially set the weights of all noise levels to 1, and evaluate on the validation set every k epochs to readjust the weights of each noise level. Specifically: calculate the ratio of the validation set losses for two consecutive times on the validation set as a measure of learning difficulty, and then obtain the weights of each noise step level finally through the softmax function. Then update W in the loss function during the training process ( t ). The specific formula is as follows:

[0115]

[0116]

[0117] Where:

[0118] — Loss function value of the denoising network at the t -th time step of the (i - 1)-th epoch on the validation set;

[0119] — Loss function value of the denoising network at the t -th time step of the (i - 2)-th epoch on the validation set;

[0120] The weight at the t - th time step in the i - th epoch. During the training process on the training set, update once every k epochs using ​, k = 4; In the calculation of the loss function for the validation set, is always 1;

[0121] — The ratio of the loss function values at the t-th time step for two consecutive epochs in the validation set;

[0122] — The adjustment parameter, used to adjust the difference in noise learning at different time steps, is set to 1.5;

[0123] — The weight normalization parameter, is set to 50.

[0124] The difference between different noise levels can be adjusted by adjusting K in the second formula. When K is large enough, the weights between different noises will tend to be equal.

[0125] Step 3: The model sampling process.

[0126] In this process, the results of the forward denoising process corresponding to the test set are gradually removed of the noises added during the forward denoising process to obtain the time series data after removing the noise at each step. Among them, the specific operation at each step is: input the time series data obtained by denoising at the current step, the conditional information Cond, and the current denoising step number into the trained denoising network obtained in Step 2 to obtain the noise prediction result corresponding to the current step. Subtract the noise prediction result corresponding to the current step from the time series data obtained by denoising at the current step to obtain the time series data obtained by denoising at the next step. The finally obtained result is used as the filled time series data.

[0127] To analyze the effectiveness of the method of the present invention, in this example, the filling effects of the method of the present invention under different datasets and different missing patterns are verified. Three time series datasets in different fields are respectively used for verification, which are: the AQI-36 air quality dataset, the PhysioNet electrocardiogram dataset, and the METR-LA traffic dataset. Then, two evaluation metrics, MAE and RMSE, are used to evaluate the filling effect. Each group of experiments is repeated 5 times. Table 1 shows the filling experiment results of the method of the present invention and other methods on the above three datasets under different missing patterns. Figure 2 It is a comparison of the filling effects of the method of the present invention and the baseline model CSDI on the AQI-36 dataset.

[0128] Table 1 Filling experiment results of the present invention on three datasets under different missing patterns

[0129]

[0130] As can be seen from Table 1, compared with the baseline model and other fixed noise weight strategy methods, the filling accuracy of the present invention has been improved to varying degrees in different datasets and different missing patterns, and it can effectively handle datasets and missing patterns in various situations in the real world.

[0131] Figure 2 The results of filling generation for the method proposed in the present invention and the baseline model CSDI are shown. Three channels are selected for visual analysis. Among them, the red cross indicates the observable value, the green solid line indicates the filling value generated by the method of the present invention, the blue circle indicates the true value, and the green shaded area indicates the quantile range from 0.05 to 0.95. It can be seen from the figure that the method of the present invention is closer to the true value in terms of filling effect and has a better generation effect than the baseline model.

[0132] Example 2:

[0133] This example provides a time series missing value filling system based on a diffusion model, which specifically includes the following modules:

[0134] The data processing module is used to divide the time series dataset into a training set, a validation set, and a test set, and perform data processing on each time series data in each part to obtain the corresponding 01 mask matrix for each time series data , as well as the target to be filled and the observable time series data ;

[0135] The training module is used to obtain a trained denoising network and is implemented using the following operation process:

[0136] Forward noise addition:

[0137] Add T steps of noise to the observable time series data in sequence, and the noise level added at each step is different to construct a noise-added sequence , denoted as , where is the time series data obtained after the t -th step of noise addition;

[0138] Backward denoising:

[0139] In the backward denoising stage, starting from the time series data obtained from the forward noise addition, gradually remove the noise added corresponding in the forward noise addition process to obtain the time series data after removing the noise at each step; the entire backward denoising process is expressed as , where represents the time series data obtained after the t-th step of denoising, and finally outputs the time series data , as the filled time series data; among them, The specific operation of is: input the time series data denoised in the t-th step, the conditional information Cond, and the current denoising step t into the denoising network to obtain the noise prediction result of the t-th step (abbreviated as ), where t ∈ 1~T; then calculate

[0140] By iteratively training the loss function value between the noise prediction result of the t-th step and the actually added noise , a trained denoising network is obtained after the training ends; the loss function to be optimized during the training is as follows:

[0141]

[0142] Among them:

[0143] —Loss function;

[0144] —Mathematical expectation;

[0145] —Time series data conforms to data distribution;

[0146] —During the noise addition process, the time series data data distribution;

[0147] —Actually added noise conforms to data distribution;

[0148] —The weight matrix of the noise at the t-th step, with an initial value of 1;

[0149] The missing value filling module is used to gradually remove the noise added during the forward noise addition process from the result of the forward noise addition process corresponding to the test set to obtain the time series data after removing the noise at each step; among them, the specific operation of each step is: input the time series data denoised in the current step, the conditional information Cond, and the current denoising step into the trained denoising network obtained in step 2 to obtain the noise prediction result corresponding to the current step, subtract the noise prediction result corresponding to the current step from the time series data denoised in the current step to obtain the time series data denoised in the next step, and the finally obtained result is used as the filled time series data.

[0150] Example 3

[0151] This embodiment provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method for filling missing values in time series based on the diffusion model of the present invention.

[0152] Embodiment 4

[0153] This embodiment provides a computer program product including computer programs / instructions, which, when executed by a processor, implement the method for filling missing values in time series based on the diffusion model of the present invention.

[0154] As described above, the above are only various embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed in the present application can easily think of changes or substitutions, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A method for filling missing values ​​in time series based on diffusion model, characterized in that: The specific steps include: Step 1, data processing: divide the time series data set into training set, validation set and test set, process each time series data in each part, and obtain the 01 mask matrix corresponding to each time series data , and the target to be filled and observable time series data ; Step 2, the training process, obtains the trained denoising network, including the following sub-steps: Step 21, forward noise addition: To observable time series data Add T steps of noise in sequence, with different noise levels added in each step, to construct a noise-added sequence , expressed as ,in For the t The time series data obtained after step noise addition; the result of forward noise addition is the time series data ; Step 22, reverse denoising: In the reverse denoising stage, the time series data obtained from step 21 Starting from the beginning, the noise added in the forward denoising process is gradually removed to obtain the time series data after each step of noise removal; the entire reverse denoising process is expressed as ,in Represents the time series data obtained after denoising in step t, and finally outputs the time series data , as the filled time series data; where, The specific operation is: the time series data obtained by denoising in step t , the condition information Cond and the current denoising step number t are input into the denoising network together to obtain the noise prediction result of the tth step , abbreviated as , where t∈1~T; then calculate ; By taking the noise prediction result of step t With real noise added The loss function value between is used for iterative training, and the denoising network is obtained after the training. The loss function that needs to be optimized during the training process is as follows: in: — loss function; — mathematical expectation; —Time series data conform to Data distribution; —Time series data during noise addition Data distribution; —Realistic added noise conform to Data distribution; —The weight matrix of the noise at step t, with an initial value of 1; In the above iterative training process, the first formula below is used to set the difficulty of learning at the t-th time step in the i-th epoch, and the second formula below is used to set the weight of the t-th time step in the i-th epoch: in: —The denoising network is in the validation set at epoch i-1. t The loss function value at time steps; —The denoising network is in the validation set at epoch i-2. t The loss function value at time steps; The weight of the t-th time step at the i-th epoch. During the training of the training set, the weight is used every k epochs. Update once , k=4; in the loss function calculation of the validation set, Always 1; —The ratio of the loss function values ​​of the t-th time step of two consecutive epochs in the validation set; —Adjustment parameters, used to adjust the difference of noise learning at different time steps, Set to 1.5; —weight normalization parameter, Set to 50; Step 3, gradually remove the noise added in the forward denoising process from the result of the forward denoising process corresponding to the test set, and obtain the time series data after denoising at each step; wherein the specific operation of each step is: input the denoising time series data obtained by the current step, the condition information Cond and the number of current denoising steps into the trained denoising network obtained in step 2, obtain the noise prediction result corresponding to the current step, subtract the noise prediction result corresponding to the current step from the denoising time series data obtained by the current step, obtain the denoising time series data for the next step, and the final result is used as the filled time series data.

2. The method for filling missing values ​​in a time series based on a diffusion model according to claim 1, characterized in that: Step 1 specifically includes the following sub-steps: Step 11, given a time series dataset, Represents one of the time series data, where K and L represent the time series data respectively The number and length of channels; divide the time series data set into three parts: training set, validation set and test set according to a certain ratio; Step 12: For each time series data in each part X , construct the time series data according to the location of the missing value X 01 mask matrix of the same shape ,01 mask matrix 0 in the value indicates that the position is missing, and 1 indicates that the value at the position can be observed. Represents time series data The observable values ​​in ; Step 13, according to the 01 mask matrix , using the preset missing pattern and missing rate, in the time series data Add new missing values ​​and record the position of the missing values ​​as 01 mask matrix ; Step 14: and Respectively with time series data Perform matrix Hadamard product operation to obtain the target to be filled and observable time series data .

3. The method for filling missing values ​​in a time series based on a diffusion model according to claim 1, characterized in that: In step 21, T is set to 50.

4. The method for filling missing values ​​in a time series based on a diffusion model according to claim 1, characterized in that: In step 22, the condition information Cond is composed of a 01 mask matrix , diffusion time coding, time position coding and feature coding.

5. A time series missing value filling system based on diffusion model, characterized in that: Specifically includes the following modules: The data processing module is used to divide the time series data set into training set, validation set and test set, and process each time series data in each part to obtain the 01 mask matrix corresponding to each time series data. , and the target to be filled and observable time series data ; The training module is used to obtain a trained denoising network, which is implemented using the following operation process: Forward noise addition: To observable time series data Add T steps of noise in sequence, with different noise levels added in each step, to construct a noise-added sequence , expressed as ,in For the t The time series data obtained after adding noise; Inverse denoising: In the reverse denoising stage, the time series data obtained from the forward denoising Starting from the beginning, the noise added in the forward denoising process is gradually removed to obtain the time series data after each step of noise removal; the entire reverse denoising process is expressed as ,in Represents the time series data obtained after denoising in step t, and finally outputs the time series data , as the filled time series data; where, The specific operation is: the time series data obtained by denoising in step t , the condition information Cond and the current denoising step number t are input into the denoising network together to obtain the noise prediction result of the tth step , abbreviated as , where t∈1~T; then calculate ; By taking the noise prediction result of step t With real noise added The loss function value between is used for iterative training, and the denoising network is obtained after the training. The loss function that needs to be optimized during the training process is as follows: in: — loss function; — mathematical expectation; —Time series data conform to Data distribution; —Time series data during noise addition Data distribution; —Realistic added noise conform to Data distribution; —The weight matrix of the noise at step t, with an initial value of 1; In the above iterative training process, the first formula below is used to set the difficulty of learning at the t-th time step in the i-th epoch, and the second formula below is used to set the weight of the t-th time step in the i-th epoch: in: —The denoising network is in the validation set at epoch i-1. t The loss function value at time steps; —The denoising network is in the validation set at epoch i-2. t The loss function value at time steps; The weight of the t-th time step at the i-th epoch. During the training of the training set, the weight is used every k epochs. Update once , k=4; in the loss function calculation of the validation set, Always 1; —The ratio of the loss function values ​​of the t-th time step of two consecutive epochs in the validation set; —Adjustment parameters, used to adjust the difference of noise learning at different time steps, Set to 1.5; —weight normalization parameter, Set to 50; The missing value filling module is used to gradually remove the noise added in the forward denoising process from the result of the forward denoising process corresponding to the test set, and obtain the time series data after each step of denoising; wherein the specific operation of each step is: input the denoising time series data, condition information Cond and the number of steps of the current denoising into the trained denoising network obtained in step 2, and obtain the noise prediction result corresponding to the current step; subtract the noise prediction result corresponding to the current step from the denoising time series data, and obtain the denoising time series data for the next step; the final result is used as the filled time series data.

6. 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 method for filling missing values ​​of a time series based on a diffusion model as described in any one of claims 1 to 4 is implemented.

7. A computer program product, characterized in that It includes a computer program / instruction, and when the computer program / instruction is executed by a processor, it implements the method for filling missing values ​​of a time series based on a diffusion model as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Knowledge embedding and filling soft measurement method based on conditional score diffusion

    CN117370771A

  • Time series data missing value filling method based on diffusion model

    CN119202555A