Probability interval prediction method and device
By combining the Monte Carlo method and Bayesian method to determine and calculate the prediction interval of the time series, the problems of inflexible and inaccurate prediction interval generation in the prior art are solved, and more efficient and accurate prediction interval generation is achieved.
Patent Information
- Application Number
- CN202411902479.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-08
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing probability interval prediction methods are difficult to generate accurate and flexible prediction intervals when processing complex and uncertain real-world data, especially in time series prediction. Traditional methods often cannot effectively adapt to local changes.
Combining the Monte Carlo method and the Bayesian method, the lower and upper bound positions of the confidence interval are determined by the Monte Carlo method, and these uncertainties are considered as normal distributions by the Bayesian method, thereby calculating a more accurate prediction interval.
It realizes more flexible and accurate prediction interval generation, can better adapt to local changes in the time series, comprehensively consider the uncertainty of model prediction, and improve prediction accuracy and coverage.
Smart Images

Figure CN119782937A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of probability interval prediction, and in particular to a probability interval prediction method and device. Background Art
[0002] Deep neural networks (NNs) are powerful forecasting tools that have achieved impressive performance in terms of aggregate accuracy indicators. However, in the decision-making process, when faced with a complex, uncertain and changing real world (such as manufacturing, finance, transportation, etc.), uncertainty in forecasting behavior is inevitable. However, the existence of forecast uncertainty can provide some additional information to help us make better decisions. The prediction interval can express the uncertainty of future estimates by directly providing the upper and lower limits of the forecast value. Under a certain probability (usually 95%), the predicted data is within the prediction interval. A good prediction interval not only needs to meet the expected coverage probability, but also should meet the standard of as narrow a prediction interval as possible.
[0003] In the context of sequence prediction, the ultimate goal is to obtain a future quantity or probability distribution of interest at a time. However, most methods only focus on a specified quantity that affects the distribution, i.e., the mean value. For example, the mean reversion model has the advantage of being easy to understand and predict, but it often presents an incomplete analysis when all influencing factors cannot be collected or when the influencing factors are uncertain in the future. In order to address the shortcomings of the mean reversion model, the solution of switching from mean reversion to probability reversion came into being.
[0004] Probability interval prediction is actually the variance in quantitative prediction. At present, the use of Bayesian probability theory is more popular, but the success of the Bayesian model depends largely on the choice of prior distribution and requires a lot of computational cost. Another commonly used method is the Monte Carlo method, which is used to sample from the posterior distribution to obtain a large number of samples, and then use these samples to estimate the prediction interval. This allows the Monte Carlo method to be flexibly applied to various types of models and is not restricted by the form of the model. However, it also has certain disadvantages, such as the need to generate a large number of samples to obtain accurate estimates, and the sampling efficiency may become very low, which requires the use of advanced sampling techniques to improve the efficiency in the prediction interval generation framework. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a probability interval prediction method and device, which fully utilizes the uncertainty modeling capability of the Bayesian method and the sampling flexibility of the Monte Carlo method to make the generation of prediction intervals more flexible and accurate.
[0006] The present invention provides the following technical solutions:
[0007] A probability interval prediction method, the method comprising:
[0008] S1: Determine the lower and upper limits of the confidence interval using the Monte Carlo method;
[0009] S2: Through the Bayesian method, the uncertainty of the lower and upper limits of the confidence interval is considered as a normal distribution, and the positions of the lower and upper limits of the prediction interval are obtained.
[0010] Furthermore, the S1 includes:
[0011] S11: Sort the samples at each position along the sample axis;
[0012] S12: Generate a large number of random samples by using the Monte Carlo method to generate random numbers that conform to a specific distribution using the cumulative distribution function;
[0013] S13: Setting a confidence level, and calculating the positions of the lower limit and the upper limit of the confidence interval according to the confidence level.
[0014] Further, the cumulative distribution function is obtained by calculating percentiles of the sorted samples;
[0015] The percentile is calculated by the following formula:
[0016]
[0017] in, is the percentile, is the percentage of the percentile, is a data set consisting of sorted samples, =1,2,…,N, where N is the size of the data set, for The index of the integer part, for The decimal part of .
[0018] Further, the S13 includes:
[0019] Set the confidence level to , the upper bound index is determined by the confidence level and lower bound index ;
[0020] .
[0021] .
[0022] Where M is the number of samples, Indicates rounding up. Indicates rounding down;
[0023] Using percentiles to set the upper limit of the confidence interval and lower limit ;
[0024]
[0025] .
[0026] Furthermore, the lower limit of the prediction interval and upper limit Calculated by the following formula:
[0027]
[0028]
[0029] Among them, loc represents the mean of the normal distribution, scale represents the standard deviation of the normal distribution, and the function ppf represents the percentage point function.
[0030] Furthermore, the loss function of the neural network model used in the Monte Carlo method is The expression is as follows:
[0031]
[0032] in, is the mean square error loss, is the average interval coverage loss, is the penalty function, is the adaptive coefficient set, For Huber's loss.
[0033] A probability interval prediction device, the device comprising:
[0034] A confidence interval determination module, used to determine the positions of the lower limit and the upper limit of the confidence interval by using the Monte Carlo method;
[0035] The prediction interval determination module is used to consider the uncertainty of the lower limit and upper limit of the confidence interval as a normal distribution through the Bayesian method to obtain the position of the lower limit and upper limit of the prediction interval.
[0036] Furthermore, the confidence interval determination module includes:
[0037] A sorting unit, used to sort the samples at each position along the sample axis;
[0038] A cumulative distribution function unit is used to generate a large number of random samples by using a Monte Carlo method to generate random numbers that conform to a specific distribution using a cumulative distribution function;
[0039] The confidence interval determination unit is used to set a confidence level and calculate the positions of the lower limit and the upper limit of the confidence interval according to the confidence level.
[0040] Further, the cumulative distribution function is obtained by calculating percentiles of the sorted samples;
[0041] The percentile is calculated by the following formula:
[0042]
[0043] in, is the percentile, is the percentage of the percentile, is a data set consisting of sorted samples, =1,2,…,N, where N is the size of the data set, for The index of the integer part, for The decimal part of .
[0044] Furthermore, the confidence interval determination unit includes:
[0045] The confidence level setting subunit is used to set the confidence level , the upper bound index is determined by the confidence level and lower bound index ;
[0046] .
[0047] .
[0048] Where M is the number of samples, Indicates rounding up. Indicates rounding down;
[0049] The confidence interval upper and lower limit setting subunit is used to set the upper limit of the confidence interval using percentiles and lower limit ;
[0050]
[0051] .
[0052] Furthermore, the lower limit of the prediction interval and upper limit Calculated by the following formula:
[0053]
[0054]
[0055] Among them, loc represents the mean of the normal distribution, scale represents the standard deviation of the normal distribution, and the function ppf represents the percentage point function.
[0056] Furthermore, the loss function of the neural network model used in the Monte Carlo method is The expression is as follows:
[0057]
[0058] in, is the mean square error loss, is the average interval coverage loss, is the penalty function, is the adaptive coefficient set, For Huber's loss.
[0059] The present invention has the following beneficial effects:
[0060] The present invention first determines the position of the prediction interval by sorting samples and calculating the cumulative distribution function in the Monte Carlo method. Then, the Bayesian method is introduced, the uncertainty of the upper and lower bounds is considered as a normal distribution, and the modeling of the prediction interval is realized by calculating the parameters of the normal distribution. The present invention combines the Monte Carlo method with the Bayesian method, making full use of the uncertainty modeling ability of the Bayesian method and the sampling flexibility of the Monte Carlo method, avoiding the defects of the traditional regression model, making the generation of the prediction interval more flexible and accurate, and can better adapt to the local changes of the time series. The method of the present invention is characterized by comprehensively considering the uncertainty of the model prediction, so that the generated prediction interval is more flexible and adaptable, which can not only more accurately describe the uncertainty of the model prediction, ensure the coverage while improving the prediction accuracy, but also maintain its universality in complex data models. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 is a flow chart of the probability interval prediction method of the present invention;
[0062] Figure 2 Schematic diagram of a probability interval prediction device of the present invention. DETAILED DESCRIPTION
[0063] In order to make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention generally 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 invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present invention.
[0064] Embodiment 1:
[0065] The embodiment of the present invention provides a probability interval prediction method, such as Figure 1 As shown, the method includes:
[0066] S1: Determine the location of the lower and upper limits of the confidence interval using the Monte Carlo method.
[0067] As an example, this step includes:
[0068] S11: Sort the samples at each position along the sample axis.
[0069] For samples Sorting along the sample axis gives the sequence: .
[0070] S12: Generate a large number of random samples by using the Monte Carlo method and the cumulative distribution function (CDF) to generate random numbers that conform to a specific distribution.
[0071] In the Monte Carlo method, the cumulative distribution function , which can be obtained by calculating the percentiles of the sorted samples.
[0072] For the sorted samples , the percentile is calculated by the following formula:
[0073]
[0074] in, is the percentile, which is used to calculate the sample quantile under a given percentile; The percentage of percentiles, usually an array, represents multiple percentiles to be calculated; is a data set consisting of sorted samples, =1,2,…,N, where N is the size of the data set, for The index of the integer part, for The formula actually does a linear interpolation between the two closest data points to estimate the data point at a given percentile.
[0075] S13: Set the confidence level and calculate the lower and upper limits of the confidence interval using the confidence level.
[0076] Specific implementation methods include:
[0077] Set the confidence level to , the upper bound index is determined by the confidence level and lower bound index .
[0078] .
[0079] .
[0080] Where M is the number of samples, Indicates rounding up. Denotes flooring and determines the location of the lower and upper bounds used to calculate the confidence interval.
[0081] Using percentiles to set the upper limit of the confidence interval and lower limit .
[0082]
[0083] .
[0084] S2: Through the Bayesian method, the uncertainty of the lower and upper limits of the confidence interval is considered as a normal distribution, and the positions of the lower and upper limits of the prediction interval are obtained.
[0085] Specifically, the lower limit of the prediction interval and upper limit Calculated by the following formula:
[0086]
[0087]
[0088] Among them, loc represents the mean of the normal distribution, scale represents the standard deviation of the normal distribution, and the function ppf represents the percent point function, which is the inverse function of the normal distribution.
[0089] The present invention first determines the position of the prediction interval by sorting samples and calculating the cumulative distribution function in the Monte Carlo method. Then, the Bayesian method is introduced, the uncertainty of the upper and lower bounds is considered as a normal distribution, and the modeling of the prediction interval is realized by calculating the parameters of the normal distribution. The present invention combines the Monte Carlo method with the Bayesian method, making full use of the uncertainty modeling ability of the Bayesian method and the sampling flexibility of the Monte Carlo method, avoiding the defects of the traditional regression model, making the generation of the prediction interval more flexible and accurate, and can better adapt to the local changes of the time series. The method of the present invention is characterized by comprehensively considering the uncertainty of the model prediction, so that the generated prediction interval is more flexible and adaptable, which can not only more accurately describe the uncertainty of the model prediction, ensure the coverage while improving the prediction accuracy, but also maintain its universality in complex data models.
[0090] As an improvement of an embodiment of the present invention, in order to solve the challenge of predicting future values in regression tasks, the present invention chooses to use a neural network to quantify the uncertainty of the model. In this field, models such as feedforward neural networks and Bayesian networks are widely used in prediction networks to effectively quantify the uncertainty in regression tasks. The loss function plays a key role in neural network training and is the main indicator for optimizing the model. In interval prediction tasks, special attention should be paid to the selection of the loss function, because different loss functions will affect the training performance of the model. The design of the loss function should balance the compactness and coverage of the interval to ensure that the model generates a prediction interval that is both compact and accurate, and has good interval coverage.
[0091] At present, the loss function mainly focuses on the optimization objectives of three standards, namely, the average prediction interval width, the mean square error, and whether the prediction interval covers the true value. However, simply balancing these three indicators cannot guarantee the maximum coverage of the true value. By improving the loss function, more prediction points can be covered while ensuring the integrity of the prediction interval. The present invention closely associates the prediction point with the prediction interval by introducing a penalty function combining an error factor and a constraint term. And by optimizing the mean square error, the difference between the true value and the predicted value is converted into the mean of the true value and the upper and lower bounds of the prediction interval (i.e., the midline position of the prediction interval), so that the predicted value is closer to the midline position of the prediction interval, thereby improving the quality of the prediction interval.
[0092] Specifically, the loss function of the neural network model used in the Monte Carlo method of the present invention is The expression is as follows:
[0093]
[0094] in, is the mean square error loss, is the average interval coverage loss, is the penalty function, is the adaptive coefficient set, For Huber's loss.
[0095] Assume time series have training batch of samples, where each instance sample Both The feature vectors are used to describe its different feature attributes, namely According to the conventional optimization equation, the minimum value of MSE is obtained, and the predicted value is , the true value is , Represents the absolute difference between the predicted value and the true value.
[0096] When at least one satisfy , the error factor is expressed as:
[0097]
[0098] When at least one satisfy , the error factor is expressed as:
[0099]
[0100] Here, the constraint items can be analyzed by error analysis between the predicted value and the true value. Expressed as the upper bound of the interval With the true value The absolute error between:
[0101]
[0102] Constraint Represents the true value and the lower limit of the interval The absolute error between
[0103]
[0104] Based on this, the present invention designs an additional penalty function, which can ensure that the prediction interval covers more prediction points to the greatest extent while ensuring the integrity of the prediction interval. By combining the error factor and the constraint term, the penalty function can be defined as:
[0105]
[0106] In order to adjust the difference between the median position of the prediction interval and the true value, so that the prediction target is at the midline position of the prediction interval to the greatest extent, the interval coverage of the prediction interval can be guaranteed to a greater extent, and the width of the prediction interval can be adjusted to a certain extent. The present invention uses the mean square error of the true value and the upper and lower boundaries of the prediction interval as the adjustment target:
[0107]
[0108] In order to ensure that the predicted value is contained between the upper and lower intervals of the prediction interval as much as possible, the present invention introduces interval coverage loss. The interval coverage loss mainly consists of two parts, which respectively calculate the sign of the difference between the true value and the upper and lower bounds. If the true value is greater than the upper bound, the sign is positive; if the true value is less than the lower bound, the sign is negative. The purpose of this step is to obtain a binary value indicating the coverage situation, that is, whether the true value is between the upper and lower bounds.
[0109] The comparison between the true value and the upper limit of the prediction interval is as follows:
[0110]
[0111] The comparison between the true value and the lower limit of the prediction interval is as follows:
[0112]
[0113] Then calculate the absolute difference between the two symbols above, that is, whether the true value is between the upper and lower bounds at the same time. If the true value is between the two bounds at the same time, the result is 0; otherwise, the result is 1. Finally, by calculating the mean of the absolute differences of all samples, the average interval coverage loss of the entire data set is obtained:
[0114]
[0115] The average interval coverage loss is used to evaluate whether the model's prediction results can correctly cover the interval of the true value. If the upper and lower bounds of the model overlap better with the interval of the true value, the lower the value, the better the performance of the model.
[0116] In addition, a loss function Huber loss is introduced for regression problems. It has the characteristics of square loss and absolute loss. The setting can balance between square loss and absolute loss. When the error is less than When , the loss function uses square loss, otherwise it uses absolute loss. The best value is obtained through cross-validation, which is more robust to outliers. The settings follow the following standards:
[0117]
[0118] The Huber loss between the upper limit of the prediction interval and the true value is expressed as follows:
[0119]
[0120] The Huber loss between the lower bound of the prediction interval and the true value is expressed as follows:
[0121]
[0122] Combining formula (11) and formula (12), we can get:
[0123]
[0124] set up As an adaptive coefficient, it is used to balance the proportion of the loss function participant Constraints in the total loss function. Through automatic adjustment during the entire learning process, the reduction ratio of the prediction interval coverage and the prediction interval width can be effectively controlled. On this basis, the present invention provides an adaptive robust covariance constraint loss function as follows:
[0125]
[0126] In order to construct a prediction interval suitable for sequence data, this paper proposes a new loss function based on adaptive robust covariance constraint loss with weighted adaptive allocation For the interval prediction task, we pay special attention to the loss function. By introducing the penalty function and improving the mean square error calculation, and combining the error factor and constraint terms, we make the correlation between the prediction point and the prediction interval closer. By balancing the compactness and coverage of the interval, the model can generate a prediction interval that is both compact and accurate, thus improving the quality of the prediction interval.
[0127] The Monte Carlo method of the present invention is used in combination with the Bayesian method, and a new loss function is used. The comprehensive application of the two makes the model perform better in dealing with uncertainty and local changes.
[0128] Embodiment 2:
[0129] The embodiment of the present invention provides a probability interval prediction device, such as Figure 2 As shown, the device comprises:
[0130] The confidence interval determination module 1 is used to determine the positions of the lower limit and the upper limit of the confidence interval by using the Monte Carlo method.
[0131] The prediction interval determination module 2 is used to consider the uncertainty of the lower limit and the upper limit of the confidence interval as a normal distribution through the Bayesian method to obtain the position of the lower limit and the upper limit of the prediction interval.
[0132] As an example, the confidence interval determination module includes:
[0133] The sorting unit is used to sort the samples at each position along the sample axis.
[0134] The cumulative distribution function unit is used to generate random numbers that conform to a specific distribution using a cumulative distribution function through a Monte Carlo method, thereby generating a large number of random samples.
[0135] The confidence interval determination unit is used to set the confidence level and calculate the positions of the lower and upper limits of the confidence interval using the confidence level.
[0136] Specifically, the cumulative distribution function can be obtained by calculating the percentiles of the sorted samples;
[0137] The percentile is calculated using the following formula:
[0138]
[0139] in, is the percentile, is the percentage of the percentile, is a data set consisting of sorted samples, =1,2,…,N, where N is the size of the data set, for The index of the integer part, for The decimal part of .
[0140] Accordingly, the confidence interval determination unit includes:
[0141] The confidence level setting subunit is used to set the confidence level , the upper bound index is determined by the confidence level and lower bound index .
[0142] .
[0143] .
[0144] Where M is the number of samples, Indicates rounding up. Indicates rounding down.
[0145] The confidence interval upper and lower limit setting subunit is used to set the upper limit of the confidence interval using percentiles and lower limit .
[0146] .
[0147] .
[0148] In the prediction interval determination module, the lower limit of the prediction interval and upper limit Calculated by the following formula:
[0149]
[0150]
[0151] Among them, loc represents the mean of the normal distribution, scale represents the standard deviation of the normal distribution, and the function ppf represents the percentage point function.
[0152] As an improvement of the embodiment of the present invention, the loss function of the neural network model used in the Monte Carlo method is The expression is as follows:
[0153]
[0154] in, is the mean square error loss, is the average interval coverage loss, is the penalty function, is the adaptive coefficient set, For Huber's loss.
[0155] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those in the aforementioned method embodiment 1. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment 1. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the devices and units described above can all refer to the corresponding processes in the aforementioned method embodiment 1, and will not be repeated here.
[0156] The above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or perform equivalent replacements on some of the technical features thereof; 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 invention. They should all be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A probability interval prediction method, characterized in that: The method comprises: S1: Determine the lower and upper limits of the confidence interval using the Monte Carlo method; S2: Through the Bayesian method, the uncertainty of the lower and upper limits of the confidence interval is considered as a normal distribution, and the positions of the lower and upper limits of the prediction interval are obtained.
2. The probability interval prediction method according to claim 1, characterized in that: The S1 includes: S11: Sort the samples at each position along the sample axis; S12: Generate a large number of random samples by using the Monte Carlo method to generate random numbers that conform to a specific distribution using the cumulative distribution function; S13: Setting a confidence level, and calculating the positions of the lower limit and the upper limit of the confidence interval according to the confidence level.
3. The probability interval prediction method according to claim 2, characterized in that: The cumulative distribution function is obtained by calculating percentiles for the sorted samples; The percentile is calculated by the following formula: in, is the percentile, is the percentage of the percentile, is a data set consisting of sorted samples, =1,2,…,N, where N is the size of the data set, for The index of the integer part, for The decimal part of .
4. The probability interval prediction method according to claim 3, characterized in that: The S13 includes: Set the confidence level to , the upper bound index is determined by the confidence level and lower bound index ; Where M is the number of samples, Indicates rounding up. Indicates rounding down; Using percentiles to set the upper limit of the confidence interval and lower limit ; 。 5. The probability interval prediction method according to claim 4, characterized in that: The lower limit of the prediction interval and upper limit Calculated by the following formula: Among them, loc represents the mean of the normal distribution, scale represents the standard deviation of the normal distribution, and the function ppf represents the percentage point function.
6. The probability interval prediction method according to claim 5, characterized in that: The loss function of the neural network model used in the Monte Carlo method is The expression is as follows: in, is the mean square error loss, is the average interval coverage loss, is the penalty function, is the adaptive coefficient set, For Huber's loss.
7. A probability interval prediction device, characterized in that: The device comprises: A confidence interval determination module, used to determine the positions of the lower limit and the upper limit of the confidence interval by using the Monte Carlo method; The prediction interval determination module is used to consider the uncertainty of the lower limit and upper limit of the confidence interval as a normal distribution through the Bayesian method to obtain the position of the lower limit and upper limit of the prediction interval.
8. The probability interval prediction device according to claim 7, characterized in that: The confidence interval determination module comprises: A sorting unit, used to sort the samples at each position along the sample axis; A cumulative distribution function unit is used to generate a large number of random samples by using a Monte Carlo method to generate random numbers that conform to a specific distribution using a cumulative distribution function; The confidence interval determination unit is used to set a confidence level and calculate the positions of the lower limit and the upper limit of the confidence interval according to the confidence level.
9. The probability interval prediction device according to claim 8, characterized in that: The cumulative distribution function is obtained by calculating percentiles for the sorted samples; The percentile is calculated by the following formula: in, is the percentile, is the percentage of the percentile, is a data set consisting of sorted samples, =1,2,…,N, where N is the size of the data set, for The index of the integer part, for The decimal part of .
10. The probability interval prediction device according to claim 9, characterized in that: The confidence interval determination unit comprises: The confidence level setting subunit is used to set the confidence level , the upper bound index is determined by the confidence level and lower bound index ; Where M is the number of samples, Indicates rounding up. Indicates rounding down; The confidence interval upper and lower limit setting subunit is used to set the upper limit of the confidence interval using percentiles and lower limit ; 。
Citation Information
Cited By
River network water project scheduling method and device, computer equipment and storage medium
CN121961166A