Carbon emissions prediction method and system based on ISWO-LSTM model
The hyperparameter optimization of the LSTM model through the improved Spider Bee optimization algorithm ISWO solves the problem of difficulty in hyperparameter optimization of the LSTM model in carbon emission prediction, improves the prediction accuracy and efficiency, and achieves more accurate carbon emission prediction.
Patent Information
- Application Number
- CN202410772254.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-06-17
AI Technical Summary
Among existing carbon emission prediction methods, the LSTM model has problems with low computational efficiency, slow convergence speed, and easy falling into local optimality in hyperparameter optimization, resulting in low accuracy of prediction results.
The improved spider bee optimization algorithm ISWO is introduced, population initialization is performed through Tent chaos mapping, adaptive inertia weight is introduced, Cauchy mutation strategy is adopted, and the hyperparameters of the LSTM model are optimized to improve prediction accuracy.
It improves the prediction accuracy and efficiency of the LSTM model, avoids the local optimal trap, and improves the prediction accuracy of carbon emissions and the robustness of the model.
Smart Images

Figure CN118350513B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of carbon emission prediction and relates to a carbon emission prediction method and system based on an ISWO-LSTM model. Background Art
[0002] The rapid development of the global economy has led to a large amount of fossil energy consumption, resulting in a substantial increase in carbon emissions. In order to achieve carbon reduction goals, people are paying more and more attention to carbon emission control, and various methods have been explored to mitigate climate change and reduce carbon emissions.
[0003] Therefore, it is very important to be able to accurately predict future carbon emissions and understand their potential consequences. Driven by the urgent need to popularize climate change and its related challenges, carbon emission forecasting has become the subject of extensive research.
[0004] Currently, common carbon emissions prediction methods include scenario analysis, grey system theory, and machine learning algorithms.
[0005] Scenario analysis is a quantitative forecasting method that can be used to predict the development trend of the target. Its advantage is that it can predict the change of the target, but the forecast results of scenario analysis are affected by the subjective judgment of the forecaster, and there may be a certain creative bias. Different forecasters have different degrees of prediction of the actual situation, so the conclusions drawn will also be different.
[0006] In the grey system theory, the grey prediction model has the advantages of fewer variables, simple model construction, and higher prediction accuracy. However, compared with machine learning algorithms, the grey prediction model has weaker fitting ability for nonlinear sequences.
[0007] In recent years, many researchers have applied machine learning algorithms to carbon emission prediction research.
[0008] Neural network models no longer rely on traditional classical logic calculations and can better handle prediction problems. Although neural network methods have high prediction accuracy, they require a large amount of training data and are prone to overfitting.
[0009] On this basis, the combination of neural networks and swarm intelligence optimization algorithms has become the mainstream carbon emission prediction method.
[0010] In carbon emission prediction, it is of great significance to select the corresponding optimization algorithm to optimize the neural network hyperparameters, and then apply the precise prediction method to the prediction of carbon emissions to obtain more accurate carbon emission prediction results.
[0011] Long Short Term Memory (LSTM) is often used in carbon emission prediction models because it can capture and utilize long-term dependencies in data. However, LSTM has many parameters and hyperparameters and requires manual parameter adjustment.
[0012] The current intelligent optimization algorithms still face difficulties in hyperparameter optimization, such as low computational efficiency, slow convergence speed, and easy to fall into local optimality, which leads to unsatisfactory model parameter optimization results and low prediction accuracy. Summary of the invention
[0013] The purpose of the present invention is to propose a carbon emissions prediction method based on the ISWO-LSTM model. The method uses a long short-term memory network LSTM to predict carbon emissions, introduces an improved spider bee algorithm ISWO, and uses ISWO to optimize the hyperparameters of the LSTM model, which is beneficial to improve the accuracy of the model in predicting carbon emissions.
[0014] In order to achieve the above object, the present invention adopts the following technical scheme:
[0015] A carbon emissions prediction method based on the ISWO-LSTM model includes the following steps:
[0016] Step 1. Preprocess carbon emission data;
[0017] Step 2. Build a carbon emission prediction model based on the LSTM model, and optimize the hyperparameters of the LSTM model based on the improved spider bee optimization algorithm ISWO to obtain the LSTM model with the optimal hyperparameters;
[0018] Step 3. Use the preprocessed carbon emission data to train the LSTM model with the optimal hyperparameters to obtain a trained carbon emission prediction model, and use the trained carbon emission prediction model to predict carbon emissions.
[0019] In addition, based on the above-mentioned carbon emission prediction method based on the ISWO-LSTM model, the present invention also proposes a corresponding carbon emission prediction system based on the ISWO-LSTM model, which adopts the following technical solutions:
[0020] A carbon emission prediction system based on ISWO-LSTM model includes the following modules:
[0021] A preprocessing module, used to preprocess carbon emission data;
[0022] The model building module is used to build a carbon emission prediction model based on the LSTM model. At the same time, the hyperparameters of the LSTM model are optimized based on the improved spider bee optimization algorithm ISWO to obtain the LSTM model with the optimal hyperparameters.
[0023] and a prediction module, which is used to train an LSTM model with optimal hyperparameters using the preprocessed carbon emission data to obtain a trained carbon emission prediction model, and predict carbon emissions using the trained carbon emission prediction model.
[0024] The present invention has the following advantages:
[0025] As described above, the present invention discloses a carbon emission prediction method based on an ISWO-LSTM model, which predicts carbon emissions by using a long short-term memory network (LSTM), and introduces a spider wasp optimizer (SWO) algorithm. In order to better optimize the LSTM model and achieve accurate prediction of carbon emissions, the SWO algorithm is improved by introducing a tent chaotic map to initialize the population, thereby improving the balance and exploration of the initial distribution of the solution and enriching the population diversity. Secondly, an adaptive inertia weight is introduced to balance the global search capability and local development capability of the algorithm, thereby improving the convergence speed and convergence accuracy of the algorithm. Finally, a Cauchy mutation strategy is adopted to perform mutation processing on the position information of the spider wasp in the global search stage, thereby avoiding the algorithm from falling into the local optimum and obtaining an improved spider wasp optimizer algorithm. ISWO), the ISWO algorithm has better convergence accuracy, convergence speed and strong robustness. Based on the ISWO algorithm, the hyperparameters of the LSTM model are optimized to obtain the ISWO-LSTM model, which is conducive to improving the accuracy of predicting carbon emissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a flow chart of a carbon emission prediction method based on an ISWO-LSTM model in an embodiment of the present invention;
[0027] Figure 2 : is a comparison diagram of the Tent chaotic map and the Logistic chaotic map used in the embodiment of the present invention; wherein Figure 2 (a) in the figure is the Tent chaotic map. Figure 2 (b) is a schematic diagram of Logistic chaotic mapping;
[0028] Figure 3is a curve diagram showing changes in the adaptive inertia weight and the traditional inertia weight in an embodiment of the present invention;
[0029] Figure 4 A comparison diagram of the standard Cauchy distribution and the standard Gaussian distribution in an embodiment of the present invention;
[0030] Figure 5 It is an algorithm flow chart of the improved spider bee optimization algorithm ISWO in an embodiment of the present invention;
[0031] Figure 6 This is a flow chart of the ISWO-LSTM network model in an embodiment of the present invention;
[0032] Figure 7 This is a schematic diagram of the ISWO optimization process for LSTM hyperparameters in an embodiment of the present invention;
[0033] in Figure 7 (a) is the process diagram of optimizing the number of neurons in the first layer; Figure 7 (b) is the process diagram of optimizing the number of neurons in the second layer; Figure 7 (c) in the figure is the learning rate optimization process diagram; Figure 7 (d) in the figure is the fitness curve;
[0034] Figure 8 This is a diagram of the prediction results of the ISWO-LSTM model in an embodiment of the present invention;
[0035] Fig. 9 This is a curve diagram of the prediction error of the ISWO-LSTM model in an embodiment of the present invention;
[0036] Fig.10 The prediction result diagram of the LSTM model optimized by the method of the present invention and the traditional optimization algorithm;
[0037] Fig.11 This is a graph showing the prediction error of the LSTM model optimized by the method of the present invention and the traditional optimization algorithm. DETAILED DESCRIPTION
[0038] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0039] Example 1
[0040] In view of the difficulties in optimizing model hyperparameters when currently using machine learning methods to predict carbon emissions and the problem that using swarm optimization algorithms to optimize neural networks is prone to falling into local optimality, this embodiment proposes a carbon emissions prediction method based on the ISWO-LSTM model. This method uses the LSTM model to predict carbon emissions, and at the same time introduces and improves the spider bee algorithm ISWO to optimize the hyperparameters of the LSTM model, which is beneficial to improving model performance and achieving the purpose of improving the accurate prediction of carbon emissions.
[0041] like Figure 1 As shown, the carbon emission prediction method based on the ISWO-LSTM model in this embodiment includes the following steps:
[0042] Step 1. Preprocess carbon emission data.
[0043] Specifically, the original data, i.e., carbon emission data, is first processed with missing values and normalized. Then, the Pearson correlation coefficient analysis method is used to perform correlation analysis on the time series composed of the original multidimensional input variables. The influencing factors with high correlation with the carbon emission data are selected as the input feature variables of the prediction model to achieve dimensionality reduction and optimization of the original data.
[0044] Carbon emissions prediction is based on historical carbon emissions data, but the original data set will inevitably have problems such as data distortion during the collection process, and the changes in carbon emissions data are affected by many factors. Most carbon emission prediction models only use carbon emissions data during training, and do not consider other influencing factors of carbon emissions. Therefore, whether the data processing and the selection of influencing factors are appropriate is directly related to whether the prediction results are accurate. In order to more accurately predict carbon emissions, this invention mainly introduces methods for dealing with situations such as missing data, and how to use correlation analysis to determine the influencing factors of carbon emissions.
[0045] The data selected in the present invention are my country's daily carbon emission data from January 1, 2019 to September 30, 2023 as experimental data. The data are all derived from the China Carbon Accounting Database, with a total of 1,734 observation data.
[0046] When raw data is collected, missing data often occurs. The present invention uses the cubic spline interpolation method in the filling method to process missing values. The principle of the filling method is to fill the missing values with other appropriate values through a certain rule or algorithm to maintain the integrity and accuracy of the data set. The filling method has a wide range of applicability and can preserve the integrity and accuracy of the data set.
[0047] Since there is an obvious correlation between the attributes in the data set, the interpolation method is selected when cleaning the original data set.
[0048] The cubic spline interpolation method divides the interpolation interval into several small segments and fits a cubic polynomial on each small segment. These cubic polynomials require the function value, first-order derivative and second-order derivative to be continuous at adjacent data points to ensure the smoothness and continuity of the interpolation curve.
[0049] The dimensional differences between different factors in the data set and the large data difference will affect the training speed and prediction effect of the subsequent prediction model. Therefore, before model training and prediction, the data set needs to be normalized, which can effectively improve the convergence speed of the model.
[0050] Since Min-Max standardization has wide applicability, its calculation method is simple and intuitive, and it can retain the distribution information of the original data, the present invention chooses to use Min-Max standardization for data processing.
[0051] Min-Max Normalization, also known as minimum-maximum scaling, is a method for data normalization that aims to linearly scale data to a specified range, usually [0,1], which helps eliminate dimensional differences between different features and ensures that they retain the order relationship of the original data on the same scale.
[0052] The formula for Min-Max normalization is as follows:
[0053] ;
[0054] in, is the normalized data point, which is in the range [0,1]; X is the original data point; is the minimum value in the data set; is the maximum value in the data set.
[0055] In addition, the present invention analyzes the changing trend of carbon emissions in detail from three scales: year, month, and day.
[0056] Since the influencing factors of carbon emissions prediction are complex, the Pearson correlation coefficient method is used to analyze the correlation between carbon emissions and its influencing factors, and the influencing factors with high correlation are obtained as the input of the prediction model to achieve the purpose of dimensionality reduction and optimization.
[0057] At present, most carbon emission prediction models are based on the characteristics of time series, but in real life, factors such as industrialization level, electricity, and residents' consumption will have a greater impact on carbon emissions.
[0058] In order to better predict carbon emissions, the present invention selects domestic aviation, traffic flow, industry, electricity and residents' consumption as influencing factors. After the normality test of the original data is carried out by the QQ graph test method, the Pearson correlation coefficient analysis is carried out on the influencing factors that obey the normal distribution. By drawing scatter plots and heat maps, the correlation between the influencing factors of carbon emissions and carbon emissions can be accurately reflected, and then the main influencing factors can be screened out to achieve dimensionality reduction and optimization of the data.
[0059] Pearson correlation coefficient analysis is a statistical method used to measure the linear correlation between two variables. It is usually used to analyze the relationship between two continuous variables and gives a value between -1 and 1 to indicate the correlation between the two variables. The formula is as follows. Suppose there are n data pairs ( , ), i=1,2,3,…,n.
[0060] ;
[0061] Among them, R p is the correlation coefficient, and its value range is between [-1,1]; and Represents the mean values of variables X and Y respectively. p >0, it is positively correlated. p When R p =1 is a perfect positive correlation. p =-1 is a completely negative correlation. The larger the absolute value of the correlation coefficient, the stronger the correlation. The specific definition is as follows:
[0062] 0<|R p |<0.19, the two are very weakly correlated; 0.2<|R p |<0.39, the two are weakly correlated; 0.4<|R p |<0.59, the two are moderately correlated; 0.6<|R p |<0.79, the two are strongly correlated; 0.8<|R p |<1.0, the two are strongly correlated.
[0063] The premise of using Pearson correlation coefficient analysis method is that the data obeys normal distribution. Therefore, before conducting Pearson correlation coefficient analysis on carbon emissions and their influencing factors, it is necessary to conduct a normality test on the data.
[0064] Since the QQ graph is not sensitive enough to small sample data, it is impossible to accurately assess whether the data conforms to the normal distribution based solely on whether the data points in the QQ graph approximately fall on a straight line. This may even lead to wrong conclusions. It is necessary to combine the Kolmogorov-Smirnov test to accurately determine whether the carbon emissions and influencing factor data conform to the normal distribution.
[0065] Therefore, the present invention uses QQ graph and Kolmogorov-Smirnov test to perform normality test on carbon emissions and influencing factors. If the data satisfies normal distribution or approximately satisfies normal distribution, these parametric statistical methods can be used directly: if the data does not satisfy normal distribution, consider converting the data to satisfy normal distribution before using parametric test methods; or do not use parametric statistical methods, and choose non-parametric test methods that do not require data to satisfy normal distribution.
[0066] In the Kolmogorov-Smirnov test, it is necessary to calculate the P value of the current data sample and compare the P value with the set significance level (set to 0.05) to determine whether the data conforms to the normal distribution.
[0067] When the P value is greater than 0.05, it can be said that the data conforms to the normal distribution, otherwise, it does not conform to the normal distribution. The P values of carbon emissions and influencing factors are shown in Table 1 below.
[0068] Table 1 P values of data samples
[0069]
[0070] As can be seen from Table 1, carbon emissions are basically close to a straight line and its P value is greater than 0.05, which is in line with the normal distribution. Among the factors affecting carbon emissions, the P values of industry, electricity, domestic aviation, traffic flow and residents' consumption are greater than 0.05, which is in line with the normal distribution.
[0071] The Pearson correlation coefficient method was used to analyze the correlation between carbon emissions and domestic aviation, residential consumption, industry, electricity, and traffic flow, and the main influencing factors were screened out. By drawing a scatter plot of carbon emissions and five influencing factors and fitting them using the polyfit function in Matlab, the strength and direction of the correlation between the two variables can be roughly determined.
[0072] Through analysis, it is known that carbon emissions are positively correlated with five influencing factors: domestic aviation, consumer spending, industry, electricity, and traffic flow. In addition, in order to more accurately evaluate the strength and direction of the correlation between variables, it is necessary to further calculate the Pearson correlation coefficient between carbon emissions and its influencing factors. By drawing a heat map, the heat map can more intuitively observe the strength of the correlation between carbon emissions and domestic aviation, consumer spending, industry, electricity, and traffic flow.
[0073] The heat map of the Pearson correlation coefficient shows that the strength of the correlation between carbon emissions and the five influencing factors is ranked in order of strength of the correlation, namely electricity, traffic flow, industry, residents' consumption and domestic aviation. Therefore, the present invention ultimately determines electricity, traffic flow, industry, residents' consumption and historical carbon emissions values as the input feature variables of the prediction model.
[0074] Step 2. Build a carbon emissions prediction model based on the LSTM model, and optimize the hyperparameters of the LSTM model based on the improved spider bee optimization algorithm ISWO to obtain the LSTM model with optimal hyperparameters.
[0075] Before introducing the improved spider bee optimization algorithm ISWO, the processing process of the SWO algorithm is given first:
[0076] (1) Exploration phase:
[0077] This phase reflects the female spider bee's search for the best spider to lay eggs. The female spider bee randomly searches for spiders for her offspring. The female spider bee explores by updating its position at a constant rate in each generation, as shown in formula (1):
[0078] (1)
[0079] in, and is the current position of the female bee and the position of the female bee at the next moment.
[0080] a and b are two random indices from the population that are used to determine the exploration direction of the female spider wasp. represents the position of individual a in the population at time t, represents the position of individual b in the population at time t.
[0081] μ1 is determined by the formula for continuous motion in the current direction, as shown in (2):
[0082] (2)
[0083] in, is a random number between 0 and 1; is a random number generated by a normal distribution.
[0084] If a spider is lost from the sphere, the female spider wasp will seek out nearby spiders.
[0085] SWO uses a second-order equation that features different exploration strategies and uses smaller step sizes to explore the area around the transferred spider. In each generation, the equation updates the current female bee position in constant motion based on the position of a randomly selected female bee representing the dropped spider, as shown in formulas (3), (4), and (5):
[0086] (3)
[0087] (4)
[0088] (5)
[0089] where c is the population random index and l is an integer between 1 and -2.
[0090] represents the lower limit of the initial parameters, represents an N-dimensional randomly initialized vector between 0 and 1, represents the upper limit of the initial parameters, Represents the position of individual c in the current population at time t.
[0091] Finally, the next position of the female spider bee is randomly selected between formulas (1) and (3), as shown in formula (6):
[0092] (6)
[0093] in, and is a random number in [0,1].
[0094] (2) Follow and escape phase:
[0095] After the female spider wasp captures a spider in its web, it will paralyze the fallen spider and drag it to its nest, but they sometimes fall to the ground. If the spider falls too quickly, the female spider wasp must catch it as it escapes.
[0096] This behavior captures two trends: the female spider wasp uses Equation (7) to adjust its position and chase the prey to prey on spiders. It also avoids other spider wasps by increasing the distance in each iteration, allowing the prey to hide.
[0097] The first trend represented by equation (7) is the female spider bee chasing model. The initial distance between the prey and the female spider bee is small and changes according to their speed. This formula includes two cases:
[0098] (1) The speed of the female spider wasp is faster than that of the prey by C>0.5;
[0099] (2) the speed of the prey is faster than that of the female spider wasp C < 0.5;
[0100] Where C controls the speed of the female spider bee, starting from 2 and decreasing linearly to zero. When the speed of the female spider bee exceeds 0.5, the distance between it and the prey increases, simulating escape.
[0101] If the female spider bee's speed is below 0.5, its position changes very little, affecting its ability to reach its prey.
[0102] (7)
[0103] (8)
[0104] Among them, a is a randomly generated population index, and is the current number of iterations and the maximum number of iterations, is a vector of random values in [0,1], is a random number. As the female spider wasp escapes from the female wasp, the distance between them becomes larger and larger. Exploration has just begun. As the journey distance increases, exploitation turns into exploration. Formula (9) illustrates this process:
[0105] (9)
[0106] in is a normally distributed vector between k and -k.
[0107] The value of k is calculated according to formula (10) to gradually increase the distance between the female spider wasp and the spider.
[0108] (10)
[0109] The following equation shows how these two tendencies are randomly weighed:
[0110] (11)
[0111] (3) Nesting stage:
[0112] Female spider wasps build nests in the soil, construct mud nests in a variety of materials, or use existing nests or burrows as nests and carry paralyzed spiders into the nests.
[0113] Given these different nesting methods, SWO employed two equations to model these behaviors.
[0114] The first equation, shown in (12), will guide the female spider wasp to find the best location, that is, the best place to build a nest to accommodate the paralyzed spider and lay eggs in its abdomen. The second equation, shown in (13), builds the nest based on the location of a female spider randomly selected from the population. To prevent multiple nests from forming in the same location, the step size is increased.
[0115] (12)
[0116] in, Represents the best known solution.
[0117] (13)
[0118] in, is a random number between [0,1], is a number randomly generated by Levy flight. a, b, and c are the indices of three randomly selected population solutions.
[0119] Binary Vector , calculated according to formula (14), determines the step length to prevent two nests from forming in the same location.
[0120] (14)
[0121] In the formula and is a random vector between 0 and 1. Use the formula to randomly swap (12) and (13):
[0122] (15)
[0123] (4) Mating behavior:
[0124] Each female spider bee represents a possible solution for the current generation, while the spider bee egg represents a new potential solution for that generation. New spider bee eggs are generated according to the following equation:
[0125] (16)
[0126] in, Indicates that and The uniform crossover operator applied between them has a probability called the crossover rate CR; and are two vectors representing male and female spider bees respectively.
[0127] In the field of carbon emission prediction, neural network models have problems with hyperparameter diversity and structural complexity, and often require combining experts' prior knowledge and conducting multiple rounds of experiments to determine the optimal configuration.
[0128] In response to the above problems, the spider bee optimization algorithm is favored by scholars because of its recent proposal, advancedness, efficient calculation, fast convergence speed, and superior performance compared with other optimization algorithms. However, in practical problems, the spider bee optimization algorithm and other intelligent algorithms have the problems of being prone to falling into local optimality and insufficient convergence accuracy.
[0129] In view of the above problems, in order to better optimize the neural network model and achieve accurate prediction of carbon emissions, the present invention will focus on improving the spider bee optimization algorithm and propose an improved spider bee optimization algorithm ISWO.
[0130] The specific improvements are as follows: first, by introducing the Tent chaotic map to initialize the population, the balance and exploratory nature of the initial distribution of the solution are improved, and the population diversity is enriched; second, by introducing the adaptive inertia weight to balance the global search ability and local development ability of the algorithm, the convergence speed and convergence accuracy of the algorithm are improved; finally, the Cauchy mutation strategy is adopted to mutate the position information of the spider bee in the global search stage to avoid the algorithm falling into the local optimum.
[0131] Population initialization plays a vital role in optimization algorithms, which directly affects the convergence speed and search quality of the algorithm. Since the SWO algorithm uses random initialization for population distribution, the algorithm will face problems such as local optimal solution, low search efficiency, unstable results, difficult parameter selection and poor local search ability. In view of the above problems, because chaotic mapping has the characteristics of randomness and ergodicity, using chaotic mapping as a random initialization method can effectively solve the above problems.
[0132] When the optimization algorithm initializes the population, the chaos map is usually used to provide a highly random random number sequence to help the algorithm jump out of the local optimal solution and accelerate the global search. Chaotic maps are often used to generate random seeds or as part of random initialization to increase the diversity and global search capabilities of the algorithm. Commonly used chaos maps include Logistic chaos map and Tent chaos map. Tent chaos map has the advantages of being simpler, more intuitive and easier to calculate than Logistic chaos map.
[0133] The comparison between Logistic chaos map and Tent chaos map is shown in the figure below. Figure 2 shown.
[0134] Depend on Figure 2 As can be seen from (a) in the figure, the Tent chaotic mapping has a stronger chaotic property and can provide higher randomness. The random number sequence it generates is evenly distributed, which reduces repetitiveness, improves the diversity of the algorithm and the global search capability, helps the algorithm to jump out of the local optimal solution and accelerates the global search.
[0135] Depend on Figure 2 From (b) in the figure, we can see that the chaotic properties of the Logistic chaotic mapping are not as strong as those of the Tent chaotic mapping. The generated random number sequence lacks sufficient randomness and uniformity, and the coverage of the solution space is not comprehensive. The Tent chaotic mapping is more uniformly distributed than the Logistic chaotic mapping, and covers the solution space more comprehensively.
[0136] Therefore, the present invention uses Tent chaotic mapping to initialize the population of the SWO algorithm.
[0137] First, the high randomness of Tent chaotic mapping can significantly expand the coverage and diversity of the search space, which can help the algorithm jump out of the local optimal solution and improve the global search ability, thereby accelerating the convergence to the global optimal solution. Secondly, the introduction of Tent chaotic mapping can increase the stability of the algorithm, making the results produced by the algorithm in different runs more reliable and consistent. In addition, Tent chaotic mapping has fewer parameters and is easy to adjust, which can simplify the implementation and parameter setting process of the algorithm and improve the applicability and practicality of the algorithm. Therefore, using Tent chaotic mapping as a random initialization method can improve the shortcomings of random initialization, improve the global search ability and efficiency, stability and ease of use of the algorithm, and its function is shown in formula (17).
[0138] (17)
[0139] in, , Take 0.5, represents the value of the next iteration number, A value representing the current iteration number.
[0140] In the standard SWO algorithm, due to the insufficient global exploration and local development capabilities of the algorithm, it is impossible to fully utilize population information for search, resulting in a slow convergence speed and low convergence accuracy of the algorithm. In view of the above problems, the present invention introduces adaptive inertia weights in the follow and escape stages of the SWO algorithm, which can be dynamically adjusted according to the algorithm search state to improve the adaptability and search capabilities of the algorithm at different stages, so that the algorithm can better overcome the local optimal solution, improve the global search capability, balance the global exploration capability and local development capability of the algorithm, and improve the convergence speed and accuracy of the algorithm. The adaptive inertia weight can adjust the inertia weight parameters of the global search and local development capabilities of the algorithm, and the formula is shown in formula (18).
[0141] (18)
[0142] in, Represents the maximum weight value; Represents the minimum weight value; Represents the maximum number of iterations; Represents the current iteration number. In addition, in order to verify the invention, the adaptive inertia weight is adopted The effectiveness of the adaptive inertia weight Compare with linear adaptive inertia weight and traditional adaptive inertia weight.
[0143] The formulas for linear adaptive inertia weight and traditional adaptive inertia weight are:
[0144] (19)
[0145] (20)
[0146] in, is the nonlinear adjustment coefficient. The three adaptive inertia weights are simulated as follows: Figure 3 shown.
[0147] from Figure 3 It can be seen that the adaptive inertia weight adopted by the present invention decreases slowly in the early stage, which can increase the global search capability and prevent the algorithm from falling into the local optimum; the adaptive inertia weight decreases quickly in the later stage, thereby improving the local search, speeding up the algorithm optimization speed, and more effectively balancing the local search and global search capabilities.
[0148] In summary, the present invention uses formula (18) to improve formula (11) in the SWO algorithm, and the improved formula is shown in formula (21):
[0149] (twenty one)
[0150] Since the standard SWO algorithm is prone to fall into the local optimal solution of the search space, the global search ability of the algorithm is weak, and more iterations are required to converge to a better solution. The present invention introduces the Cauchy mutation strategy. Its basic idea is to generate a set of random numbers according to the Cauchy distribution, and use these random numbers to adjust the individual solutions of the optimization algorithm, so as to achieve a wide search of the solution space, and use the characteristics of the Cauchy distribution with a small peak at the origin and a long distribution at both ends to perform mutation disturbance on the optimal individual. The Cauchy distribution value with a long extension at both ends can produce a larger variation range, which helps the algorithm to jump out of the local optimal solution and improve the global search ability of the algorithm. The small peak value of the Cauchy distribution is conducive to speeding up the algorithm solution speed and accelerating the search for the global optimal solution.
[0151] The Cauchy mutation update formula for the optimal individual is shown in formula (22):
[0152] (twenty two)
[0153] in, is the optimal individual value of the current iteration; is the optimal individual value after Cauchy mutation, is the Cauchy variation distribution, Is a constant used to control the variable step length.
[0154] Compared with Gaussian mutation, Cauchy mutation has better search ability because the Cauchy density function has a long tail. The long tail of the Cauchy density function distribution can increase the probability of individuals escaping from the local optimum, and the small peak in the center indicates that the Cauchy mutation can save a lot of time searching the neighborhood space. Therefore, the Cauchy mutation has a stronger regulatory function.
[0155] To intuitively show the difference between Cauchy and Gaussian distributions, the probability density functions of the two are as follows Figure 4 As shown. Figure 4 It can be seen that the peak value of the Cauchy distribution at the origin is smaller than that of the Gaussian distribution, and the speed at which the left and right sides of the curve approach 0 is slower. In addition, the shapes of the two ends of the Cauchy distribution are long and flat, and the process of approaching 0 is relatively gentle, and the speed is slower than that of the Gaussian distribution, reflecting that the Cauchy distribution has a stronger perturbation ability. Therefore, introducing the Cauchy mutation into the target position update method can give play to the perturbation ability of the Cauchy operator, and perform mutation perturbation on the optimal solution individual in the later stage of iteration, so that the global optimization performance of the algorithm is improved.
[0156] In summary, the present invention proposes an ISWO algorithm by using Tent chaotic mapping, adaptive inertia weight and Cauchy mutation to solve the problems that the SWO algorithm is prone to fall into local optimum and has insufficient optimization accuracy.
[0157] The flowchart of the improved ISWO algorithm is as follows: Figure 5 The ISWO algorithm steps are as follows:
[0158] Step A1. Initialization. Set the population size N and the maximum number of iterations and the trade-off rate TR.
[0159] Step A2. Initialize the position of the spider bee population by using the Tent chaotic map shown in formula (17).
[0160] Step A3. Calculate the fitness value function of each spider bee individual, find and retain the spider bee information with the current optimal fitness value.
[0161] Step A4. Judgment and the size of TR.
[0162] like <TR then hunt and build nests, if >TR then engages in mating behavior.
[0163] Step A5. During hunting and nesting behavior, if , then according to formula (6) and formula (21), the population is updated and the fitness value is calculated to find and save the optimal value. Otherwise, according to formula (12) and formula (13), the population is updated and the fitness value is calculated to find and report the optimal value. In mating behavior, it is updated according to formula (16).
[0164] Step A6. Use formula (22) to perform Cauchy mutation on the optimal value obtained in each iteration, calculate the optimal individual fitness value after mutation, compare the optimal fitness value of each iteration and retain the best one;
[0165] Step A7. Determine whether the algorithm has reached the maximum number of iterations.
[0166] If the maximum number of iterations has not been reached, the iteration continues; if it is, the iteration ends and the algorithm outputs the optimal value .
[0167] In addition, in order to test the optimization effect of the improved spider bee optimization algorithm ISWO proposed in the present invention, the present invention selects multiple benchmark test functions to conduct comparative tests on four optimization algorithms including PSO, SSA, SWO and ISWO.
[0168] In the convergence accuracy analysis, for the single-peak test function in the benchmark test function, compared with the PSO algorithm, SSA algorithm and SWO algorithm, the optimal value of the ISWO algorithm is 0, indicating that the ISWO algorithm has the strongest optimization ability. Thanks to the tent mapping initialization and adaptive inertia weight factor adopted by the ISWO algorithm, the algorithm can quickly obtain a good initial value during the iteration process. Therefore, the ISWO algorithm has the strongest convergence accuracy and the strongest optimization ability among the four algorithms. In the multi-peak test function, the optimal value of the ISWO algorithm is also 0. In some multi-peak test functions, the ISWO algorithm has found the optimal solution and the convergence accuracy of the ISWO algorithm is significantly higher than that of the other two algorithms. In some multi-peak test functions, ISWO did not reach the theoretical optimal value, but compared with the SSA algorithm and PSO algorithm, the ISWO algorithm still has a good optimization ability.
[0169] In summary, in the 9 benchmark function tests, the ISWO algorithm has better convergence accuracy and higher versatility than the other three optimization algorithms. Therefore, it is more suitable for some complex optimization problems and is the fastest in approaching the optimal solution.
[0170] In addition, the ISWO algorithm runs independently multiple times in the test function and its standard deviation is 0, which shows that the ISWO algorithm can stably approach the optimal solution. Compared with the other three optimization algorithms, the ISWO algorithm can better maintain the correlation between the test data points.
[0171] In summary, the ISWO algorithm has better convergence speed, convergence accuracy and strong robustness in the test function experiment of the present invention. Through simulation verification under different benchmark test functions and analysis of the experimental results, the ISWO algorithm proposed in the present invention shows excellent performance, whether it is a single-peak test function, a multi-peak test function or a fixed-dimensional multi-peak test function, the ISWO algorithm shows good optimization ability.
[0172] Compared with the PSO algorithm, SSA algorithm and SWO algorithm, the ISWO algorithm can find the theoretical optimal value with fewer iterations, and its convergence accuracy is significantly better than the comparison algorithms, and its standard deviation is the smallest, indicating that the ISWO algorithm has better robustness.
[0173] The LSTM model has a total of 4 layers, namely 1 input layer, 2 hidden layers, and 1 fully connected output layer. The ISWO algorithm is used to optimize the three hyperparameters of the hidden layer of the LSTM structure, including the number of neurons in the first layer, the number of neurons in the second layer, and the learning rate.
[0174] like Figure 6 As shown in the figure, the process of optimizing the hyperparameters of the LSTM model using ISWO is as follows:
[0175] Step 2.1. Initialize the LSTM network parameters, determine the value range of the hyperparameters, preprocess the data and input the data.
[0176] Step 2.2. Determine the trade-off rate TR, crossover rate CR, population number and maximum number of iterations of the ISWO algorithm, and initialize the ISWO population using the Tent chaotic map shown in formula (17).
[0177] Step 2.3. Perform model training, use MAE as the fitness function to evaluate the performance under the current hyperparameter configuration, and compare individual fitness to find the best position based on the value of the fitness function.
[0178] Step 2.4. Based on equations (21), (6), (12) and (13), update the position of the spider bee individual, calculate the fitness of the updated individual, and determine whether it is smaller than the historical optimal fitness.
[0179] If so, update the global optimal individual and optimal fitness value; otherwise, keep it unchanged.
[0180] Specifically, when i is less than N*k, the size of P and K is determined. When P is less than K, the individual position of the spider bee is updated using formula (6); otherwise, the individual position of the spider bee is updated using formula (21).
[0181] When i is greater than N*k, then judge r 3 and r 4 The size of r 3 Less than r 4 When , the individual position of the spider bee is updated using formula (12); otherwise, the individual position of the spider bee is updated using formula (13).
[0182] i is the position of the i-th individual in the current population; N is the number of populations; P is a random number between [0,1].
[0183] Step 2.5. Use the Cauchy mutation formula in formula (22) to perform Cauchy mutation on the optimal value obtained in each iterative optimization, calculate the optimal individual fitness value after mutation, compare the optimal fitness value of each iteration and retain the best one.
[0184] Step 2.6. When the maximum number of iterations is reached, end the iteration, obtain the global optimal individual, and output the optimal hyperparameters; otherwise, if the current number of iterations has not reached the maximum number of iterations, return to step 2.4 to search for the global optimal individual.
[0185] Output the optimal hyperparameter configuration parameters and return the LSTM model. Use the optimal hyperparameter configuration to train the LSTM model and evaluate it on the test set to verify its performance and generalization ability, and record the prediction results.
[0186] The search space settings of LSTM hyperparameters are shown in Table 2.
[0187] Table 2 LSTM hyperparameter search space
[0188]
[0189] ISWO is used to optimize the number of neurons and learning rate of the two hidden layers of LSTM in Table 2 above. The optimization process and results are as follows: Figure 7 And as shown in Table 3.
[0190] Table 3 LSTM hyperparameter optimization results
[0191]
[0192] The update changes of various parameters are mainly concentrated in the 5th and 6th iterations. The number of neurons in the first layer of the hidden layer is finally updated to 59, and the number of neurons in the second layer of the hidden layer is finally updated to 43. The learning rate is updated and converges to 0.0063. In the entire optimization process, the smaller MAE is used as the fitness function target, and the fitness finally converges to 0.0198.
[0193] The ISWO algorithm optimizes the hyperparameters obtained by the LSTM model and establishes the ISWO-LSTM model. Figure 6 The process in the above example is used to predict carbon emissions. The prediction results of the ISWO-LSTM model are shown in the figure below. Figure 8 shown.
[0194] Depend on Figure 8 It can be seen that the prediction results of the ISWO-LSTM model can not only accurately capture the trend and law of the change of the true value, but also predict the target value with high precision, and its predicted value is basically consistent with the actual value.
[0195] The ISWO model prediction error curve can more intuitively compare the difference between the model prediction value and the true value, such as Fig. 9 As shown by Fig. 9 It can be seen that the prediction error curve of the ISWO-LSTM model has a small fluctuation range, and its prediction error curve is basically close to 0, and the prediction errors are concentrated around -0.2Mt and 0.3Mt.
[0196] It can be seen that the ISWO algorithm can effectively escape the local optimum and improve the prediction accuracy of the LSTM model.
[0197] Step 3. Use the preprocessed carbon emission data to train the LSTM model with the optimal hyperparameters to obtain a trained carbon emission prediction model, and use the trained carbon emission prediction model to predict carbon emissions.
[0198] In addition, in order to verify the accuracy of the ISWO-LSTM model proposed in the present invention in predicting carbon emissions, LSTM, PSO-LSTM, GWO-LSTM and SWO-LSTM are also provided as comparison algorithms of the method (ISWO-LSTM) of the present invention.
[0199] In order to more intuitively compare the prediction effects of different models, the actual value and the predicted value of the ISWO-LSTM model are compared with the predicted values of the above four different comparison models in the same coordinates, as shown in the following figure: Fig.10 As shown in Figure 2, the prediction error curve of the ISWO-LSTM model is compared with the prediction error curves of the above four different models in the same coordinate, as shown in Figure 2. Fig.11 shown.
[0200] Depend on Fig.10 and Fig.11 It can be seen that the carbon emission prediction values of the LSTM model optimized by the above-mentioned swarm intelligence optimization algorithms can well predict the changing trend of the true value, and its prediction error is relatively concentrated between -2Mt and 2Mt. However, in some cases where the true value changes too fast and in peak and trough sections, the prediction accuracy of some models is poor, and there is a large gap with the true value.
[0201] Compared with SWO-LSTM, the predicted value of ISWO-LSTM is closer to the true value. Its prediction error curve shows that its prediction error basically does not fluctuate greatly. Compared with SWO-LSTM, the predicted value of ISWO-LSTM is closer to the true value, and its prediction error curve is below the prediction error curve of SWO-LSTM, indicating that its prediction error is smaller than the prediction error of SWO-LSTM. The predicted value of the ISWO-LSTM model basically coincides with the true value of carbon emissions, and its error curve also has the least volatility, fluctuating close to 0. Only by comparing the true value change curve with the prediction curve, it is impossible to accurately evaluate the quality of the model, nor can it intuitively evaluate the overall effect of the model, and may even lead to wrong conclusions. Therefore, Table 4 further lists the RMSE, MAE, MAPE and R of the ISWO-LSTM model and the comparison models such as PSO-LSTM, SSA-LSTM, and SWO-LSTM. 2 The value of .
[0202] Table 4 Evaluation indicators of four optimization models
[0203]
[0204] From the data comparison in Table 4, it is not difficult to find that the RMSE, MAE, MAPE and R 2 The values are better than those of other comparison models. Compared with SWO-LSTM, the RMSE, MAE and MAPE of ISWO-LSTM of the present invention are reduced by 82.34%, 82.75% and 60.57% respectively. 2 The highest value is 99.92%, which shows that the ISWO algorithm has obvious advantages over the SWO algorithm. Its optimized neural network for carbon emissions prediction can accurately predict the true value of carbon emissions.
[0205] Therefore, the ISWO algorithm proposed in the present invention is superior to the SWO algorithm and several other swarm intelligence optimization algorithms. The ISWO algorithm has the highest convergence accuracy, the strongest global search capability, and the optimized model has good generalization ability.
[0206] In summary, the ISWO algorithm proposed in the present invention has better adaptability, convergence, global search capability and generalization ability, so it has better effect in optimizing complex problems such as deep learning models. In addition, based on the ISWO algorithm proposed in the present invention, the ISWO-LSTM model further proposed has better prediction performance and the prediction effect is optimal.
[0207] Example 2
[0208] This embodiment 2 describes a carbon emission prediction system based on the ISWO-LSTM model, which is based on the same inventive concept as the carbon emission prediction method based on the ISWO-LSTM model in embodiment 1.
[0209] The carbon emission prediction system based on the ISWO-LSTM model includes the following modules:
[0210] A preprocessing module, used to preprocess carbon emission data;
[0211] The model building module is used to build a carbon emission prediction model based on the LSTM model. At the same time, the hyperparameters of the LSTM model are optimized based on the improved spider bee optimization algorithm ISWO to obtain the LSTM model with the optimal hyperparameters.
[0212] and a prediction module, which is used to train an LSTM model with optimal hyperparameters using the preprocessed carbon emission data to obtain a trained carbon emission prediction model, and predict carbon emissions using the trained carbon emission prediction model.
[0213] It should be noted that, in the carbon emission prediction system based on the ISWO-LSTM model, the implementation process of the functions and effects of each functional module is specifically described in the implementation process of the corresponding steps in the method in Example 1, and will not be repeated here.
[0214] Example 3
[0215] This embodiment 3 describes a computer device, which includes a memory and one or more processors. An executable code is stored in the memory, and when the processor executes the executable code, it is used to implement the steps of the carbon emission prediction method based on the ISWO-LSTM model in the above embodiment 1.
[0216] In this embodiment, the computer device is any device or apparatus with data processing capability, which will not be described in detail here.
[0217] Example 4
[0218] This embodiment 4 describes a computer-readable storage medium on which a program is stored. When the program is executed by a processor, it is used to implement the steps of the carbon emission prediction method based on the ISWO-LSTM model in embodiment 1.
[0219] The computer-readable storage medium may be an internal storage unit of any device or apparatus with data processing capabilities, such as a hard disk or memory, or an external storage device of any device with data processing capabilities, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc., equipped on the device.
[0220] Of course, the above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiments. It should be noted that all equivalent substitutions and obvious deformation forms made by any technician familiar with the field under the guidance of this specification fall within the essential scope of this specification and should be protected by the present invention.
Claims
1. A carbon emissions prediction method based on ISWO-LSTM model, It is characterized in that The steps include: Step 1. Preprocess the carbon emission data and determine the power data, traffic flow data, industrial data, residential consumption data and historical carbon emission values as input feature variables of the prediction model; Step 2. Build a carbon emission prediction model based on the LSTM model, and optimize the hyperparameters of the LSTM model based on the improved spider bee optimization algorithm ISWO to obtain the LSTM model with the optimal hyperparameters; Step 3. Use the preprocessed carbon emission data to train the LSTM model with the optimal hyperparameters to obtain a trained carbon emission prediction model, and use the trained carbon emission prediction model to predict carbon emissions; In step 2, the ISWO algorithm is obtained by improving the traditional spider bee optimization algorithm as follows: Firstly, the population is initialized by introducing Tent chaotic mapping to improve the balance and exploration of the initial distribution of solutions and enrich the population diversity; secondly, the adaptive inertia weight is introduced to balance the global search ability and local development ability of the algorithm, thereby improving the convergence speed and convergence accuracy of the algorithm; finally, the Cauchy mutation strategy is adopted to mutate the position information of the spider bee in the global search stage to avoid the algorithm from falling into the local optimum; In step 2, the process of optimizing the hyperparameters of the LSTM model using ISWO is as follows: Step 2.
1. Initialize the LSTM network parameters, determine the value range of the hyperparameters, preprocess the data and input the data; Step 2.
2. Determine the trade-off rate TR, crossover rate CR, population number and maximum number of iterations of the improved spider bee optimization algorithm ISWO algorithm, and use the Tent chaotic map to initialize the ISWO population; Step 2.
3. Perform model training, use MAE as the fitness function to evaluate the performance under the current hyperparameter configuration, and compare individual fitness to find the best position based on the value of the fitness function; Step 2.
4. Introduce adaptive inertia weights in the algorithm following and escaping stages, update the position of the spider bee individual based on the adaptive inertia weights, calculate the fitness of the updated individual, and determine whether it is smaller than the historical optimal fitness; If yes, update the global optimal individual and optimal fitness value; otherwise, keep it unchanged; Step 2.
5. Use the Cauchy mutation formula to perform Cauchy mutation on the optimal value obtained in each iterative optimization, calculate the optimal individual fitness value after mutation, compare the optimal fitness value of each iteration and retain the best one; Step 2.
6. When the maximum number of iterations is reached, the iteration ends, the global optimal individual is obtained, and the optimal hyperparameters are output; otherwise, if the current number of iterations does not reach the maximum number of iterations, return to step 2.4 to search for the global optimal individual; In step 2.5, the Cauchy mutation update formula for the optimal individual is as follows: x newbest =x best ×(1+η×Cauchy(0,1)); Among them, x best is the optimal individual value of the current iteration; x newbest is the optimal individual value after Cauchy mutation, Cauchy(0,1) is the Cauchy mutation distribution, and η is a constant used to control the step length.
2. According to the carbon emission prediction method based on the ISWO-LSTM model according to claim 1, It is characterized in that In step 2.2, the function expression of the Tent chaos map is as follows: Among them, a∈(0,1), x n+1 Indicates the next iteration value, x n Indicates iterating over the current value.
3. According to the carbon emission prediction method based on ISWO-LSTM model according to claim 1, It is characterized in that In step 2.4, the expression of the adaptive inertia weight is as follows: Where w represents the adaptive inertia weight, w 1 Represents the maximum weight value, w 2 represents the minimum weight value, t max represents the maximum number of iterations, and t represents the current number of iterations; According to the number of iterations, the individual positions are updated as follows: in, Indicates the position of the female bee at the next moment, represents the current position of the female bee, a is the population random index, represents the position of individual a in the population at time t, represents a random value vector in [0,1], r 3 、r 4 represents a random number in [0,1]; is a normally distributed vector between k and -k; The value of k is calculated according to the following formula to gradually increase the distance between the female spider wasp and the spider: where r 6 Represents a random number.
4. According to the carbon emission prediction method based on ISWO-LSTM model according to claim 1, It is characterized in that In the step 2, the hyperparameters of the LSTM model to be optimized include the number of neurons in the first and second layers of the hidden layer of the LSTM model and the learning rate, and the hyperparameters of the LSTM model are optimized using the improved spider bee optimization algorithm ISWO.
5. According to the carbon emission prediction method based on ISWO-LSTM model according to claim 1, It is characterized in that In step 1, the process of preprocessing the carbon emission data is as follows: Firstly, the original data, namely carbon emission data, is processed with missing values and normalized. Then, the Pearson correlation coefficient analysis method is used to perform correlation analysis on the time series composed of the original multidimensional input variables. The influencing factors related to the carbon emission data are selected as the input characteristic variables of the prediction model to achieve dimensionality reduction and optimization of the original data.
6. A carbon emission prediction system based on an ISWO-LSTM model for implementing the carbon emission prediction method based on an ISWO-LSTM model as claimed in claim 1, It is characterized in that The carbon emission prediction system based on the ISWO-LSTM model includes the following modules: A preprocessing module, used to preprocess carbon emission data; The model building module is used to build a carbon emission prediction model based on the LSTM model. At the same time, the hyperparameters of the LSTM model are optimized based on the improved spider bee optimization algorithm ISWO to obtain the LSTM model with the optimal hyperparameters. and a prediction module, which is used to train an LSTM model with optimal hyperparameters using the preprocessed carbon emission data to obtain a trained carbon emission prediction model, and predict carbon emissions using the trained carbon emission prediction model.
