A rooftop photovoltaic power prediction method based on K-means-AROA-LSTM
Preprocessed data was analyzed through K-means clustering and Pearson correlation, and AROA-LSTM combination model was constructed to optimize the hyperparameters of LSTM neural network, solving the problem of insufficient prediction accuracy of roof photovoltaic data, and improving prediction accuracy and user feedback effect.
Patent Information
- Application Number
- CN202411837151.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-04
AI Technical Summary
There are a few anomalies in the roof photovoltaic data, and meteorological and environmental factors require correlation analysis. The results of the existing prediction methods are insufficiently accurate, and a new photovoltaic power prediction method is needed.
The K-means clustering algorithm is used to preprocess historical data, and the weather influencing factors are selected through Pearson correlation analysis, and the AROA-LSTM combination model is constructed. The LSTM neural network hyperparameters are optimized through the AROA algorithm, and the model is trained to improve the prediction accuracy.
By optimizing the model training effect, the accuracy of power prediction of residential roof photovoltaic equipment is improved, and better user feedback effect is provided.
Smart Images

Figure CN119765302A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of household photovoltaic technology, and in particular relates to a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM Background Art
[0002] As the trend of small-scale photovoltaic power generation by residential users becomes increasingly popular, the demand for reliable data is also gradually increasing, so it is necessary to predict and analyze the photovoltaic power of residential rooftops.
[0003] In the process of implementing the technical method of the embodiment of the present invention, the inventor of this patent found at least the following technical problems in the prior art:
[0004] There are a few anomalies in the rooftop photovoltaic data, which need to be preliminarily screened by appropriate methods; the meteorological environmental factors of residential users need to be correlated; the selected prediction method may make the results less accurate; therefore, a new photovoltaic power prediction method is needed to solve this problem. Summary of the invention
[0005] In view of the above problems, the present invention proposes a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM, which aims to improve the effect of model training by using a more effective algorithm, thereby improving the accuracy of power prediction of residential rooftop photovoltaic equipment.
[0006] In a first aspect, the present invention provides a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM, which is characterized by comprising:
[0007] Obtain rooftop photovoltaic historical data and use K-means for preprocessing;
[0008] Performing Pearson correlation analysis on meteorological influencing factors, and selecting meteorological influencing factors and the preprocessed data as a data set according to the correlation coefficient;
[0009] The AROA algorithm is used to optimize the hyperparameters of LSTM and build an AROA-LSTM combination model;
[0010] The data set is used to train the AROA-LSTM combined model, and the prediction results are obtained through training and verification.
[0011] Further preferably, after obtaining the historical data of rooftop photovoltaic power generation, K-means is used for preprocessing, specifically: K initial centroids are randomly selected, each of which corresponds to a cluster; for each data point x in the data set i, calculate its distance to each centroid, and assign each data point to the cluster corresponding to the centroid closest to it; after completing the data point assignment, recalculate the centroid of each cluster; repeat the assignment and update steps until the predetermined maximum number of iterations is reached.
[0012] Further preferably, the method of performing Pearson correlation analysis on meteorological influencing factors also includes: processing the collected relevant data using a maximum-minimum normalization method.
[0013] Further optimization is performed by using the AROA algorithm to optimize the hyperparameters of LSTM, including:
[0014] It mimics the related balance of attraction-repulsion phenomena that occur in nature, where candidate solutions move in the search space according to the quality of solutions in their neighborhood and the best candidate solution. The position of the candidate solution is updated according to the fitness information achieved by other members of the group, and the solutions are guided to converge toward the optimal solution by dynamically adjusting the attraction and repulsion between each solution. The initial value of n individuals X is generated first, and then the value of X is updated by calculating the fitness level of adjacent individuals, and then based on the movement from the i-th individual to X and d i,j ∈D to update the attraction-repulsion operator, then apply attraction to the best solution, and finally determine the optimal solution based on the three local search operators and the new and old values;
[0015] Then the new optimal solution is determined by three local search operators and the old value.
[0016] Further preferably, the constructing of the AROA-LSTM combined model further includes:
[0017] Initialize the LSTM neural network structure and hyperparameters, the population size, number of iterations, spatial dimension and hidden layer nodes of the AROA particle swarm, the learning rate and the particle position corresponding to the number of network iterations; calculate the fitness of each particle; update the individual optimal solution of the particle, the global optimal solution and the particle position; repeat the above steps until the optimal position is found or the maximum number of iterations is reached; output parameters for training and prediction until they are less than the error threshold and then output.
[0018] In a second aspect, the present invention provides a rooftop photovoltaic power prediction device based on K-means-AROA-LSTM, comprising:
[0019] A construction module is configured to obtain rooftop photovoltaic historical data and pre-process the data using K-means;
[0020] A computing module configured to process photovoltaic historical data using a K-means algorithm;
[0021] The method is configured to perform a Pearson correlation analysis on the meteorological influencing factors, and select the meteorological influencing factors and the pre-processed data as a data set according to the correlation coefficient;
[0022] The processing module is configured to use the AROA algorithm to optimize the hyperparameters of the LSTM and build an AROA-LSTM combination model; use the data set to train the model, and obtain the prediction results through training and verification; use the root mean square error (RMSE), mean absolute error (MAE), and mean relative percentage error (MAPE) as evaluation indicators.
[0023] In a third aspect, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the steps of the rooftop photovoltaic power prediction method of the K-means-AROA-LSTM of any embodiment of the present invention.
[0024] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the program is executed by a processor to perform the steps of the rooftop photovoltaic power prediction method of the K-means-AROA-LSTM of any embodiment of the present invention.
[0025] The K-means-AROA-LSTM rooftop photovoltaic power prediction method of the present application studies the use of K-means clustering algorithm to preprocess historical data, uses Pearson correlation analysis to calculate meteorological influencing factors, studies the establishment of an AROA-LSTM combined model, studies the optimization of LSTM neural network hyperparameters through the AROA optimization algorithm, studies the use of the AROA-LSTM algorithm to train data sets, studies the use of model evaluation indicators to compare and calculate prediction results, optimizes the effect of model training, improves the accuracy of power prediction for residents' rooftop photovoltaic equipment, and provides better feedback to users. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 A flowchart of a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM provided in one embodiment of the present invention;
[0028] Figure 2A comparison diagram of prediction results of different models of a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM provided in one embodiment of the present invention;
[0029] Figure 3 A structural block diagram of a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM provided in one embodiment of the present invention.
[0030] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.
[0032] See also Figure 1 , which shows a flowchart of a rooftop photovoltaic power prediction method based on K-means-AROA-LSTM of the present application.
[0033] like Figure 1 As shown in the figure, the rooftop photovoltaic power prediction method based on K-means-AROA-LSTM specifically includes the following steps:
[0034] Step S101, using K-means clustering algorithm to pre-process photovoltaic historical data, and then calculating the Pearson correlation coefficient to obtain strongly correlated meteorological influencing factors, and both are input as a data set.
[0035] In this step, K-means is used to preprocess the photovoltaic historical data, and K initial centroids are randomly selected, each of which corresponds to a cluster; for each data point x in the data set i , calculate its distance to each centroid, and assign each data point to the cluster corresponding to the centroid closest to it; after completing the data point assignment, recalculate the centroid of each cluster; repeat the assignment and update steps until the predetermined maximum number of iterations is reached.
[0036]
[0037] In the formula, x i is the ith data point, μ k is the centroid of the kth cluster, ||·|| represents the Euclidean distance, C i is the i-th cluster, |Ck | represents the number of data points in the kth cluster, K is the number of clusters, and J is the sum of the squares of the distances between each data point and the centroid of its cluster.
[0038] The meteorological influencing factors are subjected to Pearson correlation analysis, and the meteorological influencing factors and the pre-processed data are selected as a data set according to the correlation coefficient. The Pearson correlation coefficient calculation formula is as follows:
[0039]
[0040] In the formula, n is the total number of samples, x is i is the ith meteorological influencing factor, is the average value of meteorological factors, y i is the ith photovoltaic output power, is the average value of photovoltaic output power, ρ xy is the correlation coefficient.
[0041] In a specific example, the correlation coefficients of various meteorological influencing factors are calculated by Pearson correlation coefficient, as shown in Table 1.
[0042] Table 1 Correlation coefficients between input variables and photovoltaic power
[0043]
[0044] Step S102, optimizing the hyperparameters of the LSTM neural network according to the AROA algorithm after initializing the model parameters, and outputting the parameters for training after finding the optimal solution or reaching the maximum number of iterations.
[0045] In this step, the collected relevant data are processed using the maximum-minimum normalization method. The calculation formula of the normalization method is as follows:
[0046]
[0047] In the formula, is the normalized value, X i is the normalized initial value, X max is the maximum value, X min is the minimum value.
[0048] The processed data set is then randomly divided into 70% training set and 30% test set.
[0049] AROA is a correlation balance that mimics the attraction-repulsion phenomenon that occurs in nature, in which candidate solutions move in the search space according to the quality of solutions in their neighborhood and the best candidate solution. The position of the candidate solution is updated according to the fitness information achieved by other members of the group, and the solutions are guided to converge toward the optimal solution by dynamically adjusting the attraction and repulsion between each solution. The initial value of n individuals X is generated first, and then the value of X is updated by calculating the fitness level of adjacent individuals, and then based on the movement from the i-th individual to X and d i,j ∈D to update the attraction-repulsion operator, then apply attraction to the best solution, and finally determine the optimal solution based on the three local search operators and the new and old values. The relevant calculation formula is as follows:
[0050] X i =rand⊙(X up -X low )+X low
[0051]
[0052]
[0053]
[0054]
[0055]
[0056] Where, X i is the value of the ith individual, X j is the value of the jth individual, is an individual x i The coordinate value in the kth dimension, is an individual x j The coordinate value in the kth dimension, k is the current dimension index number, rand is a random vector, X up and X low are the upper and lower bounds of the search space, respectively, and D is the distance matrix, where d i,j is the distance between the i-th and j-th individuals, i,j∈{1,2,...,n}, dim is the i The dimension of , c is the step size, d i,max is the distance between the ith individual and the farthest member of the population, s is a function that determines the direction of change based on the fitness value, and f i is the fitness value of the ith individual, f j is the fitness value of the jth individual, n i is the attraction and repulsion operator, t is the current iteration number, t max is the maximum number of iterations.
[0057] Then, the new optimal solution is determined by three local search operators and the old value. The relevant calculation formula is as follows:
[0058]
[0059]
[0060] X i (t) = X i (t-1)+n i +b i +r i
[0061]
[0062]
[0063]
[0064] r R =u3⊙(2·a3-o)⊙(X up -X low )
[0065]
[0066]
[0067]
[0068] Where, X best is the optimal solution, a1 is a random vector, parameter r1∈[0,1] is a random number, p1 is the probability threshold, m is a parameter used to simulate the impact of the optimal solution, b i is the attraction operator; r B is an operator that represents Brownian motion by updating the standard deviation according to the search domain boundary, u1 is a binary vector; N is a random vector generated value following a normal distribution, and f r1 is the contact value; r tri is a candidate solution based on trigonometric functions and roulette wheel selection, f r2 is the multiplier, u2 is a binary vector, r4 and r5 are random numbers between 0 and 1, a2 is a random vector, X w is a randomly selected solution from X; u3 is a binary vector, a3 is a vector of randomly selected values, o is the identity matrix; r7 is a random integer variable from 0 to 1, e f is the probability cutoff, u4 is the use of 1-e f The binary vector obtained by the threshold value, a4 is a vector composed of random numbers, r8 and r9 are parameters randomly selected from X, and c fis the updated parameter, X i (t) represents X i The value of the tth iteration, f(X i (t)) represents X i The fitness value of the tth iteration, X i (t-1) represents X i The value of the t-1th iteration, f(X i (t-1)) represents X i The fitness value at the t-1th iteration.
[0069] LSTM is a special recurrent neural network used to process and predict time series data. The LSTM unit consists of three gate units: input gate, forget gate, and output gate. These gate units provide continuous read, write, and reset operations for the storage unit, enabling it to dynamically adjust between different gates. The forget gate manages the impact of the cell state c(t-1) at the previous moment on the cell state c(t) at the current moment, and decides which information to retain and which information to forget. In contrast, the input gate plays a role in assimilating the input x(t) at the current moment into the cell state c(t), thereby determining the inclusion of new information. The output gate monitors the impact of the cell state c(t) on the current output h(t) in the LSTM network, and regulates the degree to which the cell state is transmitted to the output. The relevant calculation formula is as follows:
[0070] i t =σ(W xi x t +W hi h t-1 +W ci c t-1 +b i )
[0071] f t =σ(W xf x t +W hf h t-1 +W cf c t-1 +b f )
[0072] c t =f t c t-1 +i t tanh(W xc x t +W hc h t-1 +b c )
[0073] o t =σ(W xo x t +Who h t-1 +W co c t-1 +b o )
[0074] h t =o t tanh(c t )
[0075] Where: i t is the output of the input gate at time step t, f t is the output of the forget gate at time step t, o t is the output of the output gate at time step t, c t is the output of the memory cell state at time step t, h t is the output of the hidden state at time step t, x t is the input vector at the current time step t, h t-1 The hidden state vector at the previous time step t-1, c t-1 is the state vector of the memory unit at the previous time step t-1; σ is the sigmoid activation function, whose output range is between 0 and 1, which is used to control the passage of information, tanh is the hyperbolic tangent activation function, whose output range is between -1 and 1, which is used to introduce nonlinearity, W is the weight matrix, b is the bias vector, corresponding to the weight matrix, used for the calculation of each gate; the subscripts represent different gating and gates, such as x represents the input vector, h represents the hidden state, c represents the memory unit state, i represents the input gate, f represents the forget gate, and o represents the output gate.
[0076] Initialize the LSTM neural network structure and hyperparameters, the population size, number of iterations, spatial dimension and hidden layer nodes of the AROA particle swarm, the learning rate and the particle position corresponding to the number of network iterations; calculate the fitness of each particle; update the individual optimal solution of the particle, the global optimal solution and the particle position; repeat the above steps until the optimal position is found or the maximum number of iterations is reached; output parameters for training and prediction until they are less than the error threshold and then output.
[0077] In a specific embodiment, three different algorithms are compared as shown in Table 2, and Matlab numerical simulation is used to train the proposed mathematical algorithm to obtain parameters.
[0078] Table 2 Experimental parameter settings
[0079]
[0080] Step S103, judging whether the photovoltaic power data predicted by the data set and the validation set meet the error range, obtaining the prediction results and comparing them using the model error evaluation index.
[0081] In this step, based on the LSTM neural network, different algorithms are used to optimize its parameters and train it. The prediction results obtained by each prediction model are compared using the model error evaluation index. The root mean square error RMSE, mean absolute error MAE and mean absolute percentage error MAPE are used as evaluation indicators. The smaller the value, the higher the prediction accuracy. The relevant calculation formula is as follows:
[0082]
[0083]
[0084]
[0085] Where N is the number of samples, T i is the measured value, t i is the predicted value.
[0086] In a specific embodiment, three different algorithms are compared as shown in Table 3, and Matlab numerical simulation is used to verify the proposed mathematical algorithm.
[0087] Table 3 Comparison of evaluation indicators of various prediction models
[0088]
[0089]
[0090] From the calculation results in Table 3, it can be seen that the prediction accuracy of the LSTM neural network improved by AROA is greatly improved compared with the traditional LSTM model. At the same time, compared with the LSTM neural network improved by PSO, the root mean square error, mean absolute error and mean relative percentage error are all reduced. Therefore, the designed prediction method further improves the prediction accuracy based on the traditional algorithm.
[0091] Depend on Figure 2 From the comparison results, we can see that by comparing the prediction results of the three models with the true values, the prediction results of the AROA-LSTM model have the smallest deviation from the true values and the highest accuracy.
[0092] In summary, the method of the present application, first, studies the use of K-means clustering algorithm to preprocess historical data, uses Pearson correlation analysis to calculate meteorological influencing factors, studies the establishment of an AROA-LSTM combined model, studies the optimization of LSTM neural network hyperparameters through the AROA optimization algorithm, studies the use of the AROA-LSTM algorithm to train data sets, studies the use of model evaluation indicators to compare and calculate prediction results, optimizes the effect of model training, improves the accuracy of power prediction of residential rooftop photovoltaic equipment, and provides better feedback to users.
[0093] See also Figure 3 , which shows a structural block diagram of a rooftop photovoltaic power prediction system based on K-means-AROA-LSTM in the present application.
[0094] like Figure 3 As shown, the rooftop photovoltaic power prediction system 200 based on K-means-AROA-LSTM includes a construction module 210, a calculation module 220 and a processing module 230.
[0095] Wherein, the construction module 210 is configured to obtain rooftop photovoltaic historical data and pre-process the data using K-means;
[0096] A calculation module 220 is configured to process the photovoltaic historical data using a K-means algorithm;
[0097] The method is configured to perform a Pearson correlation analysis on the meteorological influencing factors, and select the meteorological influencing factors and the pre-processed data as a data set according to the correlation coefficient;
[0098] The processing module 230 is configured to use the AROA algorithm to optimize the hyperparameters of the LSTM and construct an AROA-LSTM combination model; use the data set to train the model, and obtain the prediction results through training and verification; use the root mean square error (RMSE), mean absolute error (MAE), and mean relative percentage error (MAPE) as evaluation indicators.
[0099] It should be understood that Figure 3 The modules and references documented in Figure 1 Therefore, the operations and features described above for the method and the corresponding technical effects are also applicable to Figure 3 The modules in it will not be described in detail here.
[0100] In some other embodiments, the embodiments of the present invention further provide a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the rooftop photovoltaic power prediction method of K-means-AROA-LSTM in any embodiment of the present invention;
[0101] As an implementation mode, the computer-readable storage medium of the present invention stores computer-executable instructions, and the computer-executable instructions are configured as follows:
[0102] Acquire rooftop photovoltaic historical data and pre-process the data using K-means;
[0103] Performing Pearson correlation analysis on meteorological influencing factors, and selecting meteorological influencing factors and the preprocessed data as a data set according to the correlation coefficient;
[0104] The AROA algorithm is used to optimize the hyperparameters of LSTM and build an AROA-LSTM combination model;
[0105] The model is trained using the data set, and prediction results are obtained through training and verification;
[0106] The root mean square error (RMSE), mean absolute error (MAE) and mean relative percentage error (MAPE) were used as evaluation indicators.
[0107] The computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created by the use of a rooftop photovoltaic power prediction system based on K-means-AROA-LSTM, etc. In addition, the computer-readable storage medium may include a high-speed random access memory, and may also include a memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the computer-readable storage medium may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the household photovoltaic multi-path inspection data processing system via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0108] Figure 4 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the device includes: a processor 310 and a memory 320. The electronic device may also include: an input device 330 and an output device 340. The processor 310, the memory 320, the input device 330 and the output device 340 may be connected via a bus or other means. Figure 4 In the example, the bus connection is used. The memory 320 is the above-mentioned computer-readable storage medium. The processor 310 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 320, that is, the above-mentioned method implements the rooftop photovoltaic power prediction method based on K-means-AROA-LSTM. The input device 330 can receive input digital or character information and generate key signal input related to user settings and function control of the rooftop photovoltaic power prediction system based on K-means-AROA-LSTM. The output device 340 may include display devices such as display screens.
[0109] The electronic device can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0110] As an implementation mode, the electronic device is applied to a K-means-AROA-LSTM rooftop photovoltaic power prediction method system for a client, and includes: instructions executed by at least one processor, the instructions being executed by the at least one processor so that the at least one processor can;
[0111] Acquire rooftop photovoltaic historical data and pre-process the data using K-means;
[0112] The meteorological influencing factors are subjected to Pearson correlation analysis. The meteorological influencing factors and the pre-processed data are selected as a data set according to the correlation coefficient. The Pearson correlation coefficient calculation formula is as follows:
[0113]
[0114] In the formula, n is the total number of samples, x is i is the ith meteorological influencing factor, x is the average value of the meteorological influencing factor, y i is the ith photovoltaic output power, is the average value of photovoltaic output power, ρ xy is the correlation coefficient.
[0115] The AROA algorithm is used to optimize the hyperparameters of LSTM and build an AROA-LSTM combination model;
[0116] The model is trained using the data set, and prediction results are obtained through training and verification;
[0117] The root mean square error (RMSE), mean absolute error (MAE) and mean relative percentage error (MAPE) were used as evaluation indicators.
[0118] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A rooftop photovoltaic power prediction method based on K-means-AROA-LSTM, characterized in that: include: Obtain rooftop photovoltaic historical data and use K-means for preprocessing; The meteorological influencing factors are subjected to Pearson correlation analysis. The meteorological influencing factors and the pre-processed data are selected as a data set according to the correlation coefficient. The Pearson correlation coefficient calculation formula is as follows: In the formula, n is the total number of samples, x is i is the ith meteorological influencing factor, is the average value of meteorological factors, y i is the ith photovoltaic output power, is the average value of photovoltaic output power, ρ xy is the correlation coefficient; The AROA algorithm is used to optimize the hyperparameters of LSTM and build an AROA-LSTM combination model; The data set is used to train the AROA-LSTM combined model, and the prediction results are obtained through training and verification.
2. The rooftop photovoltaic power prediction method based on K-means-AROA-LSTM according to claim 1 is characterized in that: After obtaining the historical data of rooftop photovoltaics, K-means is used for preprocessing. Specifically, K initial centroids are randomly selected, each of which corresponds to a cluster. For each data point x in the data set, i , calculate its distance to each centroid, and assign each data point to the cluster corresponding to the centroid closest to it; after completing the data point assignment, recalculate the centroid of each cluster; repeat the assignment and update steps until the predetermined maximum number of iterations is reached; In the formula, x i is the ith data point, μ k is the centroid of the kth cluster, ||·|| represents the Euclidean distance, C i is the i-th cluster, |C k | represents the number of data points in the kth cluster, K is the number of clusters, and J is the sum of the squares of the distances between each data point and the centroid of its cluster.
3. The rooftop photovoltaic power prediction method based on K-means-AROA-LSTM according to claim 1 is characterized in that: The method for performing Pearson correlation analysis on meteorological influencing factors also includes: The collected relevant data are processed using the maximum-minimum normalization method. The calculation formula of the normalization method is as follows: In the formula, is the normalized value, X i is the normalized initial value, X max is the maximum value, X min is the minimum value.
4. The rooftop photovoltaic power prediction method based on K-means AROA-LSTM according to claim 3 is characterized in that: The processed data set is randomly divided into training set and test set.
5. The rooftop photovoltaic power prediction method based on K-means-AROA-LSTM according to claim 1, characterized in that: The AROA algorithm is used to optimize the hyperparameters of LSTM, including: It mimics the related balance of attraction-repulsion phenomena that occur in nature, where candidate solutions move in the search space according to the quality of solutions in their neighborhood and the best candidate solution. The position of the candidate solution is updated according to the fitness information achieved by other members of the group, and the solutions are guided to converge toward the optimal solution by dynamically adjusting the attraction and repulsion between each solution. The initial value of n individuals X is generated first, and then the value of X is updated by calculating the fitness level of adjacent individuals, and then based on the movement from the i-th individual to X and d i,j ∈D to update the attraction-repulsion operator, then apply the attraction to the best solution, and finally determine the optimal solution based on the three local search operators and the new and old values; the relevant calculation formula is as follows: X i =rand ⊙ (X up -X low )+X low Where, X i is the value of the ith individual, X j is the value of the jth individual, is an individual x i The coordinate value in the kth dimension, is an individual x j The coordinate value in the kth dimension, k is the current dimension index number, rand is a random vector, X up and X low are the upper and lower bounds of the search space, respectively, and D is the distance matrix, where d i,j is the distance between the i-th and j-th individuals, i,j∈{1,2, ... ,n}, dim is X i The dimension of , c is the step size, d i,max is the distance between the ith individual and the farthest member of the population, s is a function that determines the direction of change based on the fitness value, and f i is the fitness value of the ith individual, f j is the fitness value of the jth individual, n i is the attraction and repulsion operator, t is the current iteration number, t max is the maximum number of iterations; Then, the new optimal solution is determined by three local search operators and the old value. The relevant calculation formula is as follows: X i (t)=X i (t-1)+n i +b i +r i r R =u3⊙(2·a3-o)⊙(X up -X low ) Where, X best is the optimal solution, a1 is a random vector, parameter r1∈[0,1] is a random number, p1 is the probability threshold, m is a parameter used to simulate the impact of the optimal solution, b i is the attraction operator; r B is an operator that represents Brownian motion by updating the standard deviation according to the search domain boundary, u1 is a binary vector; N is a random vector generated value following a normal distribution, and f r1 is the contact value; r tri is a candidate solution based on trigonometric functions and roulette wheel selection, f r2 is the multiplier, u2 is a binary vector, r4 and r5 are random numbers between 0 and 1, a2 is a random vector, X w is a randomly selected solution from X; u3 is a binary vector, a3 is a vector of randomly selected values, o is the identity matrix; r7 is a random integer variable from 0 to 1, e f is the probability cutoff, u4 is the use of 1-e f The binary vector obtained by the threshold value, a4 is a vector composed of random numbers, r8 and r9 are parameters randomly selected from X, and c f is the updated parameter, X i (t) represents X i The value of the tth iteration, f(X i (t)) represents X i The fitness value of the tth iteration, X i (t-1) represents X i The value of the t-1th iteration, f(X i (t-1)) represents X i The fitness value at the t-1th iteration.
6. The rooftop photovoltaic power prediction method based on K-means-AROA-LSTM according to claim 1, characterized in that: The AROA-LSTM combined model is constructed, further comprising: Initialize the LSTM neural network structure and hyperparameters, the population size, number of iterations, spatial dimension and hidden layer nodes of the AROA particle swarm, the learning rate and the particle position corresponding to the number of network iterations; calculate the fitness of each particle; update the individual optimal solution of the particle, the global optimal solution and the particle position; repeat the above steps until the optimal position is found or the maximum number of iterations is reached; output parameters for training and prediction until they are less than the error threshold and then output.
7. The method for predicting rooftop photovoltaic power based on K-means AROA-LSTM according to claim 6, characterized in that: The model error was evaluated, and the root mean square error RMSE, mean absolute error MAE and mean absolute percentage error MAPE were used as evaluation indicators to evaluate the error of the AROA-LSTM combined model.
8. A device for implementing the rooftop photovoltaic power prediction method based on K-means-AROA-LSTM according to any one of claims 1 to 7, characterized in that ,include: A construction module is configured to obtain rooftop photovoltaic historical data and pre-process the data using K-means; A computing module configured to process photovoltaic historical data using a K-means algorithm; The method is configured to perform a Pearson correlation analysis on the meteorological influencing factors, and select the meteorological influencing factors and the pre-processed data as a data set according to the correlation coefficient; The processing module is configured to use the AROA algorithm to optimize the hyperparameters of the LSTM and build an AROA-LSTM combination model; use the data set to train the model, and obtain the prediction result through training and verification.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.