A time series forecasting method

By introducing the hybrid regression loss function CDHloss and multi-objective Bayesian optimization into the neural network, the problem of insufficient trend direction prediction of neural networks in time series prediction is solved, and the prediction accuracy is improved. It is suitable for greenhouse environment management, especially temperature prediction in solar greenhouses.

CN117131903BActive Publication Date: 2025-09-26SOUTH CHINA UNIV OF TECH +2
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311209470.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-18
Publication Date
2025-09-26
Estimated Expiration
2043-09-18

AI Technical Summary

Technical Problem

Existing time series prediction methods based on neural networks have shortcomings in trend direction prediction, and the loss function design is not suitable for different tasks, resulting in insufficient or inaccurate prediction results.

Method used

The hybrid regression loss function CDHloss is adopted, combined with mean square error and cross entropy loss, and parameters are adjusted through multi-objective Bayesian optimization to construct a neural network model considering direction for temperature prediction in solar greenhouse.

Benefits of technology

It improves the training effect and prediction accuracy of neural networks, especially in greenhouse environment management, provides more accurate temperature trend predictions, and supports the optimized management of crop growth environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117131903B_ABST
    Figure CN117131903B_ABST
Patent Text Reader

Abstract

The present invention provides a time series prediction method. When training a neural network, the loss function of the neural network adopts a hybrid regression loss function CDHloss that takes direction into consideration. When the predicted result is inconsistent with the actual result, the loss function can produce a stronger gradient, thereby prompting the neural network model to better converge to a solution space with consistent symbols. The mean square loss and entropy loss can be integrated in the regression problem to maximize the advantages of the loss function and improve the training effect. Moreover, because the CDHloss loss function retains the advantages of the original regression problem loss function while adding the constraint of the classification problem on directional consistency, and also integrates the advantages of the mean square loss and entropy loss, the prediction result is more accurate than the previous method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data analysis, and in particular to a time series prediction method. Background Art

[0002] Time series forecasting, a method that uses historical data to predict future data, has widespread application and significant value across various fields. For example, in finance, time series forecasting can help investors analyze market trends and develop sound investment strategies; in meteorology, it can help meteorologists predict weather changes and provide accurate weather services; and in medicine, it can help doctors monitor patients' physiological indicators, detect anomalies promptly, and provide effective treatment plans. Therefore, research on time series forecasting is crucial for improving social efficiency, improving the quality of human life, and promoting scientific and technological progress. Neural networks, with their advantages of self-learning, self-adaptation, self-organization, and fault tolerance, can extract implicit features and patterns from large amounts of historical data to predict future data.

[0003] However, current research on time series prediction based on neural networks still has some shortcomings. Time series prediction is mainly divided into two categories of tasks: one is regression prediction of values ​​at a certain time or within a certain interval in the future; the other is classification prediction of the trend direction at a certain time or within a certain interval in the future. However, numerical regression predictions usually do not have specific constraints on trends and ignore the prediction of direction, which is more important for user decision-making. If trend direction prediction is treated as a binary classification problem, the prediction results may not provide sufficient information. In addition, in neural network research, for different tasks, it is necessary to design or select loss functions that are suitable for them to better converge the network and improve network generalization performance. Summary of the Invention

[0004] The present invention aims to solve at least one of the technical problems raised in the above-mentioned background technology and provide a time series prediction method that can improve the training effect of neural network and thus improve the accuracy of time series prediction.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is:

[0006] A time series forecasting method comprises the following steps:

[0007] Acquire historical time series data of a temperature prediction task in a solar greenhouse; the historical time series data of the temperature prediction task in the solar greenhouse refers to historical data within several time periods closest to future data of a time period to be predicted;

[0008] Establishing a neural network: The neural network includes an initialization layer, a stochastic differential equation layer, and a prediction layer. The stochastic differential equation layer is provided with a stochastic differential equation. The initialization layer is used to extract an initialization feature map of historical time series data. The stochastic differential equation layer is used to obtain mean and variance features of historical series data using a stochastic differential equation whose initial value is the initialization feature map. The mean feature is the solution of the stochastic differential equation, and the variance feature is the diffusion coefficient corresponding to the stochastic differential equation and the solution. The prediction layer is used to predict the mean and variance of future data based on the mean and variance features.

[0009] The neural network is trained using a training data set for a temperature prediction task in a solar greenhouse to obtain a trained neural network. When the neural network is trained using the training data set for the task, the loss function of the neural network adopts a hybrid regression loss function that considers direction, and the construction method thereof includes:

[0010] Formula (1) is used to amplify the difference when the signs are inconsistent:

[0011]

[0012] in, is the predicted value of the test set, y i is the true value of the test set; a is the amplification factor when the signs are inconsistent; M i For a single y i and its corresponding The calculation results of

[0013] Use formula (2) to calculate the average value N for a batch of M data:

[0014]

[0015] Furthermore, in order to better mix the advantages of various loss functions, the regression problem is converted into a classification problem, so that the regression problem loss can also be integrated with the entropy loss, and the rise and fall direction in the regression problem is converted into a rise and fall direction binary classification problem, which is:

[0016]

[0017] Among them, p i With q i y i and Classification label of

[0018] Calculate p i With q i The cross entropy B is:

[0019]

[0020] Where M is the number of data in a batch;

[0021] The regression loss function and classification loss function that consider the symbol are weighted averaged to obtain the hybrid regression loss function CDHloss that considers the direction:

[0022] CDHloss=b×N+(1-b)×B (6)

[0023] Where b is a coefficient, b∈[0,1], and the optimal parameters of a and b are obtained by multi-objective Bayesian optimization;

[0024] The historical time series data of the temperature prediction task in the solar greenhouse is input into the trained neural network, and the mean and variance of the future data are obtained through the neural network;

[0025] A prediction interval of the future data is obtained based on the mean and variance of the future data, wherein the future data is task data corresponding to the temperature prediction task in the solar greenhouse within the time period to be predicted; the prediction interval represents the value range of the task data, and the task data is used for task decision-making.

[0026] Furthermore, the multi-objective Bayesian optimization step includes:

[0027] During the experiment, when performing multi-objective Bayesian parameter tuning, it is necessary to find the Pareto optimality based on the evaluation index. The conventional mean square error (MSE) and directional accuracy (DA) are selected as evaluation indicators. The specific expression is as follows:

[0028]

[0029] Among them, m is the total number of test set samples, y i is the true value of the test set, is the predicted value of the test set; MSE is used to measure the deviation between the true value and the predicted value, and its value range is [0, +∞]. The closer it is to 0, the better the model prediction performance; DA is used to measure the accuracy of the prediction direction proposed in this paper, and its value range is [0, 1]. The closer it is to 1, the better the model prediction effect;

[0030] Multi-objective Bayesian optimization problems can be solved using Indicates that is the search space, n is the dimension, Is an m-dimensional real-valued vector function of Ω, as follows:

[0031] is the objective space, n is determined by composition, which are design variables; solving the multi-objective Bayesian optimization problem requires finding a set of values It is called a Pareto set, whose elements satisfy the following conditions:

[0032]

[0033] Using MSE and DA as evaluation indicators, we aim to find the optimal parameters of coefficients a and b. The objective function is specifically expressed as:

[0034]

[0035] The Galuzio algorithm is used to solve this multi-objective optimization function to obtain the optimal parameter values ​​of coefficients a and b.

[0036] Furthermore, the training data set of the temperature prediction task in the greenhouse is divided into a training set and a test set in a ratio of 8:2 to train the neural network.

[0037] Furthermore, after obtaining the historical time series data of the temperature prediction task in the solar greenhouse, the obtained historical time series data are also standardized to map the data in [-1, 1]. Specifically, for a set of data {x1, x2, ..., x g}, g is the total number of data contained in the data set, which is standardized by the following formula:

[0038]

[0039] Among them, x i is the original data, x′ i is the standardized data, max(|x1|,|x2|,...,|x g |) is the data with the largest absolute value.

[0040] Due to the adoption of the above technical solution, the present invention has the following beneficial effects:

[0041] In the above-mentioned time series prediction method, when training the neural network, the loss function of the neural network adopts a hybrid regression loss function that takes direction into consideration. This loss function can produce a stronger gradient when the predicted result is inconsistent with the actual result, thereby prompting the neural network model to better converge to a solution space with consistent symbols, and can integrate the mean square loss and entropy loss on the regression problem, maximize the advantages of the loss function, and improve the training effect; and because the CDHloss loss function retains the advantages of the original regression problem loss function while adding the constraints on directional consistency of the classification problem, and also integrates the advantages of the mean square loss and entropy loss, the prediction results are more accurate than previous methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 A flowchart of a time series prediction method according to a preferred embodiment of the present invention;

[0043] Figure 2 A flowchart for constructing a loss function of a neural network in a time series prediction method according to a preferred embodiment of the present invention;

[0044] Figure 3 Schematic diagram of the sliding window operation process. DETAILED DESCRIPTION

[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0046] It should be noted that when a component is referred to as being "fixed to" another component, it may be directly on the other component or there may also be a central component. When a component is considered to be "connected to" another component, it may be directly connected to the other component or there may also be a central component. When a component is considered to be "set on" another component, it may be directly set on the other component or there may also be a central component. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.

[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this invention pertains. The terms used in this specification of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0048] Please also see Figures 1 to 2 A preferred embodiment of the present invention provides a time series prediction method, comprising the following steps:

[0049] S1, obtaining historical time series data of a temperature prediction task in a solar greenhouse; the historical time series data of the temperature prediction task in the solar greenhouse refers to historical data in several time periods closest to future data of a time period to be predicted.

[0050] In this embodiment, after obtaining the historical time series data of the temperature prediction task in the solar greenhouse, the obtained historical time series data is also standardized to map the data in [-1, 1]. Specifically, for a set of data {x1, x2, ..., x g}, g is the total number of data contained in the data set, which is standardized by the following formula:

[0051]

[0052] Among them, x i is the original data, x′ i is the standardized data, max(|x1|,|x2|,...,|x g |) is the data with the largest absolute value.

[0053] S2, establishing a neural network; the neural network includes an initialization layer, a stochastic differential equation layer and a prediction layer, wherein the stochastic differential equation layer is provided with a stochastic differential equation; the initialization layer is used to extract an initialization feature map of historical time series data; the stochastic differential equation layer is used to obtain the mean feature and variance feature of the historical series data using a stochastic differential equation whose initial value is the initialization feature map, wherein the mean feature is the solution of the stochastic differential equation, and the variance feature is the diffusion coefficient corresponding to the stochastic differential equation and the solution; the prediction layer is used to predict the mean and variance of future data based on the mean feature and variance feature.

[0054] For details of step S2 of this embodiment, reference may be made to step S102 in Chinese invention patent CN112699998B, a method, device, electronic device, and readable storage medium for time series prediction, which will not be described here for the sake of brevity.

[0055] S3, using a training data set for a temperature prediction task in a solar greenhouse to train the neural network to obtain a trained neural network; when training the neural network using the training data set for the task, a loss function of the neural network adopts a hybrid regression loss function of considering direction (CDHloss for short), and a construction method thereof includes:

[0056] Formula (1) is used to amplify the difference when the signs are inconsistent:

[0057]

[0058] in, is the predicted value of the test set, y iis the true value of the test set; a is the amplification factor when the signs are inconsistent; M i For a single y i and its corresponding The calculation results of .

[0059] Sign inconsistency refers to situations where the prediction of the direction of increase or decrease is inaccurate, including situations where the predicted result is an increase and the actual value is a decrease; or the predicted result is a decrease and the actual value is an increase.

[0060] Use formula (2) to calculate the average value N for a batch of M data:

[0061]

[0062] In order to better mix the advantages of various loss functions, the regression problem is converted into a classification problem, so that the regression problem loss can also be integrated with the entropy loss, and the rise and fall direction in the regression problem is converted into a rise and fall direction binary classification problem:

[0063]

[0064] Among them, pi and qi are y i and The classification label of .

[0065] Calculate the cross entropy B between pi and qi, we have:

[0066]

[0067] Where M is the number of data in a batch;

[0068] The regression loss function and classification loss function that consider the symbol are weighted averaged to obtain the hybrid regression loss function CDHloss that considers the direction:

[0069] DL=b×N+(1-b)×B (6)

[0070] Where b is a coefficient, b∈[0,1], and the optimal parameters of a and b are obtained by multi-objective Bayesian optimization.

[0071] In this embodiment, the multi-objective Bayesian optimization step includes:

[0072] During the experiment, when performing multi-objective Bayesian parameter tuning, it is necessary to find the Pareto optimality based on the evaluation indicators. The conventional mean square error (MSE) and direction accuracy (DA) are selected as evaluation indicators. The specific expression is as follows:

[0073]

[0074] Among them, m is the total number of test set samples, y i is the true value of the test set, is the predicted value of the test set; MSE is used to measure the deviation between the true value and the predicted value, and its value range is [0, +∞]. The closer it is to 0, the better the model prediction performance; DA is used to measure the accuracy of the prediction direction proposed in this paper, and its value range is [0, 1]. The closer it is to 1, the better the model prediction effect;

[0075] Multi-objective Bayesian optimization problems can be solved using Indicates that is the search space, n is the dimension, Is an m-dimensional real-valued vector function of Ω, as follows:

[0076] is the objective space, n is determined by composition, which are design variables; solving the multi-objective Bayesian optimization problem requires finding a set of values It is called a Pareto set, whose elements satisfy the following conditions:

[0077]

[0078] Using MSE and DA as evaluation indicators, we aim to find the optimal parameters of coefficients a and b. The objective function is specifically expressed as:

[0079]

[0080] The Galuzio algorithm is used to solve the multi-objective optimization function to obtain the optimal parameter values ​​of coefficients a and b. The specific method of using the Galuzio algorithm to solve the multi-objective optimization function to obtain the coefficients a and b belongs to the prior art and will not be described here for the sake of space.

[0081] Preferably, the training data set for the temperature prediction task in the greenhouse is divided into a training set and a test set in a ratio of 8:2 to train the neural network.

[0082] The specific implementation of the remaining steps of step S3 of this embodiment, for example, how to train a neural network, belongs to the prior art. For example, reference can be made to step S103 in Chinese invention patent CN112699998B, a time series prediction method, device, electronic device, and readable storage medium. To omit space, they are not described here.

[0083] S4, inputs the historical time series data of the temperature prediction task in the solar greenhouse into the trained neural network, and obtains the mean and variance of future data through the neural network.

[0084] S5. Obtain a prediction interval of the future data based on the mean and variance of the future data, wherein the future data is task data corresponding to the temperature prediction task in the solar greenhouse within the time period to be predicted; the prediction interval represents the value range of the task data, and the task data is used for task decision-making.

[0085] Steps S4-S5 of this embodiment belong to the prior art. For example, refer to steps S104-S105 in Chinese invention patent CN112699998B, a time series prediction method, device, electronic device, and readable storage medium. To omit space, they are not repeated here.

[0086] The time series prediction method according to the embodiment of the present invention is described below with reference to a specific embodiment.

[0087] With global climate change and population growth, agricultural production faces enormous challenges. To improve agricultural production efficiency, more and more farmers are turning to greenhouses to grow crops. Greenhouses provide an ideal growing environment for crops, but they also require meticulous management. To better manage greenhouses, predicting the internal greenhouse environment is crucial. Both regression and directional prediction are crucial in this regard. Regression prediction can help us predict specific parameters such as temperature and humidity within the greenhouse, which are crucial for crop growth. Directional prediction, on the other hand, can help us predict the changing trends of these parameters, allowing us to adjust the greenhouse environment in a timely manner to prevent crop damage. By combining these two types of prediction, we can better manage greenhouses and provide an optimal growing environment for crops. Therefore, the hybrid regression loss function CDHloss, a time series prediction neural network that considers direction, is well-suited for this purpose. By combining regression and directional prediction, it provides more accurate and comprehensive forecasts.

[0088] This embodiment takes the solar greenhouse for cherry cultivation in Dalian as the implementation object, selects the neural network in a time series prediction method of Chinese invention patent CN112699998B, and uses the mixed regression loss function CDHloss considering the direction of this embodiment to train the neural network. The trained neural network is used to predict the time series changes of the temperature in the greenhouse. During the experiment, an RS485 agricultural serial port sensor was used to collect information such as soil temperature, soil moisture, air temperature, air humidity, and light intensity. The data set includes data from December 1, 2020 to June 1, 2021, collected every 30 minutes, covering the entire cherry growth cycle, and the collected data is divided into a training set and a test set in a ratio of 8:2.

[0089] Because environmental parameters have different dimensions, data comparability is low. To eliminate dimensional and scale differences in the data, improve data comparability and stability, and enhance the model's convergence speed and accuracy, this embodiment uses the formula in step S1 to normalize the collected data. This standardization method is simple and easy to implement, does not require knowledge of the data's distribution, and does not change the relative size or order of the data.

[0090] In the process of inputting the historical time series data of the temperature prediction task in the solar greenhouse into the trained neural network, the following methods can be used: Figure 3 The sliding window shown in the figure is used for data input. This reduces the complexity of the problem and is more conducive to neural network input. Setting a window length of 50 and a rolling window of 1 means that the temperature for the next 30 minutes will be predicted based on the previous 1500 minutes of data. Using a sliding window for data input is a prior art method and will not be detailed here for the sake of space.

[0091] Experiments show that a neural network model using CDHloss as the loss function achieves good results in predicting both the value and direction of temperature in a solar greenhouse for cherry cultivation in Dalian. This result provides an effective tool for better greenhouse management and providing a superior growing environment for cherry cultivation.

[0092] When training a neural network, the aforementioned time series prediction method uses a time series prediction neural network hybrid regression loss function that takes direction into account. This loss function produces a stronger gradient when the predicted result is inconsistent with the actual result, thereby promoting the neural network model to better converge to a solution space with consistent signs. It also integrates mean square loss and entropy loss for regression problems, maximizing the advantages of the loss function and improving training results. Furthermore, because the CDHloss loss function retains the advantages of the original regression loss function while adding directional consistency constraints for classification problems, and also combines the advantages of mean square loss and entropy loss, the prediction results are more accurate than previous methods.

[0093] The above description is a detailed description of the preferred embodiments of the present invention, but the embodiments are not intended to limit the scope of the patent application of the present invention. Any equivalent changes or modifications completed under the technical spirit suggested by the present invention should fall within the patent scope covered by the present invention.

Claims

1. A time series prediction method, characterized in that: The following steps are involved: Acquire historical time series data of a temperature prediction task in a solar greenhouse; the historical time series data of the temperature prediction task in the solar greenhouse refers to historical data within several time periods closest to future data of a time period to be predicted; Establishing a neural network: The neural network includes an initialization layer, a stochastic differential equation layer, and a prediction layer. The stochastic differential equation layer is provided with a stochastic differential equation. The initialization layer is used to extract an initialization feature map of historical time series data. The stochastic differential equation layer is used to obtain mean and variance features of historical series data using a stochastic differential equation whose initial value is the initialization feature map. The mean feature is the solution of the stochastic differential equation, and the variance feature is the diffusion coefficient corresponding to the stochastic differential equation and the solution. The prediction layer is used to predict the mean and variance of future data based on the mean and variance features. Using a training data set for a temperature prediction task in a solar greenhouse, the neural network is trained to obtain a trained neural network; When training the neural network using the training data set of the task, the loss function of the neural network adopts a hybrid regression loss function that considers direction, and its construction method includes: Formula (1) is used to amplify the difference when the signs are inconsistent: in, is the predicted value of the test set, y i is the true value of the test set; a is the amplification factor when the signs are inconsistent; M i For a single y i and its corresponding The calculation results of Use formula (2) to calculate the average value N for a batch of M data: Convert the rising and falling direction in the regression problem into a rising and falling direction binary classification problem: Among them, p i With q i y i and Classification label of Calculate p i With q i The cross entropy B is: Where M is the number of data in a batch; The regression loss function and classification loss function that consider the symbol are weighted averaged to obtain the hybrid regression loss function CDHloss that considers the direction: CDHloss=b×N+(1-b)×B (6); Where b is a coefficient, b∈[0,1], and the optimal parameters of a and b are obtained by multi-objective Bayesian optimization; The historical time series data of the temperature prediction task in the solar greenhouse is input into the trained neural network, and the mean and variance of the future data are obtained through the neural network; A prediction interval of the future data is obtained based on the mean and variance of the future data, wherein the future data is task data corresponding to the temperature prediction task in the solar greenhouse within the time period to be predicted; the prediction interval represents the value range of the task data, and the task data is used for task decision-making.

2. The time series prediction method according to claim 1, wherein: The multi-objective Bayesian optimization step includes: When performing multi-objective Bayesian parameter tuning, it is necessary to find the Pareto optimality based on the evaluation index. The conventional mean square error (MSE) and direction accuracy (DA) are used as evaluation indicators. The specific expression is as follows: Among them, m is the total number of test set samples, y i is the true value of the test set, is the predicted value of the test set; MSE is used to measure the deviation between the true value and the predicted value, and its value range is [0, +∞]. The closer it is to 0, the better the model prediction performance; DA is used to measure the accuracy of the prediction direction proposed in this paper, and its value range is [0, 1]. The closer it is to 1, the better the model prediction effect; Multi-objective Bayesian optimization problems can be solved using Indicates that is the search space, n is the dimension, Is an m-dimensional real-valued vector function of Ω, as follows: is the objective space, n is determined by composition, which are design variables; solving the multi-objective Bayesian optimization problem requires finding a set of values It is called a Pareto set, whose elements satisfy the following conditions: Using MSE and DA as evaluation indicators, we aim to find the optimal parameters of coefficients a and b. The objective function is specifically expressed as: The Galuzio algorithm is used to solve this multi-objective optimization function to obtain the optimal parameter values ​​of coefficients a and b.

3. The time series prediction method according to claim 1, wherein: The training data set of the greenhouse temperature prediction task is divided into a training set and a test set in a ratio of 8:2 to train the neural network.

4. The time series prediction method according to claim 1, wherein: After obtaining the historical time series data of the temperature prediction task in the solar greenhouse, the obtained historical time series data are also normalized to map the data in [-1, 1]. Specifically, for a set of data {x1, x2, ..., x g }, g is the total number of data contained in the data set, which is standardized by the following formula: Among them, x i is the original data, x' i is the standardized data, max(|x1|,|x2|,...,|x g |) is the data with the largest absolute value.

Citation Information

Patent Citations

  • A time series forecasting method, apparatus, electronic device, and readable storage medium

    CN112699998B

  • Formation pressure prediction method based on neural network time sequence

    CN116644844A

  • Spatio-temporal graph neural network for time series prediction

    US20230252285A1