Photovoltaic power generation power prediction model training method, prediction method, device, equipment and medium
Through the combination of the principal component analysis method, the combination of the dimensionality reduction and the hybrid attention mechanism-bidirectional long and short-term memory network model, the one-sided and stability problems of LSTM in predicting photovoltaic power generation power is solved, and higher prediction accuracy and model stability are achieved.
Patent Information
- Application Number
- CN202510339463.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-03-21
AI Technical Summary
LSTM has one-sided and stable problems when predicting photovoltaic power generation, and failed to effectively consider the size of a specific correlation coefficient, and the time span set during model training is too long, which affects the stability of the model.
The principal component analysis method is used to reduce the dimensionality of the characteristic data, extract the principal component features with the largest contribution rate of variance, and combine the hybrid attention mechanism-bidirectional long and short-term memory network model to capture the dependence of key information and time series in the data through local attention mechanism and self-attention mechanism.
Through the combination of dimensionality reduction processing and hybrid attention mechanism, the prediction accuracy of the model is improved, and the one-sidedness and stability of the LSTM model when predicting photovoltaic power generation power is solved, achieving higher prediction accuracy and model stability.
Smart Images

Figure CN119853033A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of photovoltaic power generation, and in particular to a photovoltaic power generation power prediction model training method, prediction method, device, equipment and medium. Background Art
[0002] Long Short-Term Memory Network (LSTM) is an improved recurrent neural network (RNN). On the basis of RNN, it solves the problem of gradient vanishing or gradient exploding when processing long time series data. The advantage of LSTM is that it can extract the spatiotemporal correlation between output and related input variables compared to traditional photovoltaic power prediction methods, and has made greater progress in the field of complex time series prediction.
[0003] However, there are two problems with LSTM when predicting photovoltaic power generation. First, the size of the specific correlation coefficient is not taken into account, and the results obtained are one-sided. Second, the time span set by LSTM during model training is too long, which may affect the stability of LSTM.
[0004] Therefore, it is necessary to propose a photovoltaic power generation power prediction model training method, prediction method, device, equipment and medium to solve the above problems. Summary of the invention
[0005] The purpose of the present invention is to provide a photovoltaic power generation power prediction model training method, prediction method, device, equipment and medium to improve model performance and improve prediction accuracy.
[0006] In a first aspect, the present invention provides a photovoltaic power generation prediction model training method, the model training method comprising: S101: acquiring photovoltaic power generation history data of the photovoltaic power station, extracting feature data from the photovoltaic power generation history data, calculating feature importance scores of the feature data using a CatBoost algorithm, and determining important feature data according to the feature importance scores; S102: using principal component analysis to perform data standardization on important feature data to obtain standardized data, calculating the covariance matrix of the standardized data, performing eigenvalue decomposition on the covariance matrix to obtain eigenvalues and eigenvectors corresponding to the eigenvalues, constructing a principal component loading matrix according to the eigenvectors, obtaining a principal component feature matrix according to the principal component loading matrix and the standardized data matrix, calculating the variance contribution rate of each principal component feature, and adding the principal component feature with the largest variance contribution rate to the important feature data to obtain updated feature data; S103: Dividing the updated feature data into a training set, a validation set, and a test set according to a preset ratio; S104: Establish a hybrid attention mechanism-bidirectional long short-term memory network model, the hybrid attention mechanism includes a local attention mechanism and a self-attention mechanism, select a hyperparameter type and set the initial value of each hyperparameter; S105: Use the training set to train the hybrid attention mechanism-bidirectional long short-term memory network model, and use the validation set to verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model reaches the expected effect. If not, adjust the value of the hyperparameter and return to step S105; if yes, output the trained photovoltaic power generation prediction model; S106: Use the test set to test and evaluate the trained photovoltaic power generation prediction model.
[0007] In a possible embodiment, the important feature data is a feature data set of n×m X =[ x 1 , x 2 ,…, x n ] T , No. i The feature vector of the sample x i =[ x i1 , x i2 ,…, x im ]; The calculation formula for data standardization includes: ; ; ; The calculation formula of the covariance matrix includes: ; ; The calculation formula for eigenvalue decomposition includes: ; ; V =[ v 1 , v 2 , …, v m ]; The calculation formula of the principal component feature matrix includes: A = V; T = ZA ; The calculation formulas for variance contribution rate and cumulative variance contribution rate include: ; ; In the formula, n represents the number of samples; m Indicates the number of features; i Indicates the sample index; j Represents the feature index; Indicates i The sample j Features Indicates j The mean of the features; Indicates j The variance of the feature; Represents the standardized data matrix; Represents the standardized data matrix The transposed matrix of ; ∑ represents the covariance matrix; x :i Indicates i Features x :j Indicates j Features r ij Represents the standardized features x :i and x :j The correlation coefficient of Indicates The sample Features Indicates The sample j Features Indicates The mean of the features; Indicates The variance of the features; E represents the identity matrix; λ represents the eigenvalue; v represents the feature vector; V represents the eigenvector matrix; A represents the principal component loading matrix; T represents the principal component feature matrix; Indicates The eigenvalues of the principal components; Indicates j The eigenvalues of the principal components; η krepresents the variance contribution rate; γ k Before The sum of the variance contributions of the principal component features.
[0008] In one possible embodiment, the operation steps of the local attention mechanism include: For each position t in the sequence, focus on the elements within the set local window size (2w+1), and calculate the attention score of the local window by the following formula: ; The context representation of time step t is obtained by weighted summing the values of the local window using the following formula: ; In the calculation step formula of the local attention mechanism, the trainable parameters are used by the following formula To replace the local window center t: ; Introducing the normal distribution term into the attention score formula yields: ; In the formula, represents the input time step; t represents the current output time step; Indicates half of the local window size; Indicates the range of the local window; Represents the input time step The attention weight for the current output time step t; represents the query vector at the current output time step t; is the key vector The transpose of Represents the input time step i The key vector of ; represents the normalization factor for scaling dot product similarity; represents the local dynamic context vector at the current output time step t; Indicates that at the input time step i The eigenvector when ; is a trainable parameter; represents the scaling factor; Indicates the length of the input sequence; Represents the sigmoid activation function; is the trainable parameter vector The transpose of represents a trainable parameter vector; represents the input vector at the current output time step t.
[0009] In one possible embodiment, the operation steps of the self-attention mechanism include: According to the following formula, the query vector and key vector The similarity of , using the dot product model to calculate the attention score: ; The attention score is converted to attention weight by the following formula: ; The value vector is adjusted according to the attention weight by the following formula Perform weighted summation to generate context vector : ; Query Vector , key vector and value vector Derived from the same input sequence, it satisfies the following formula: Q=K=V; ; In the formula, represents the input time step; t represents the current output time step; represents the query vector at the current output time step t; represents the key vector at input time step i, is the key vector The transpose of Represents the query vector and key vector Similarity score of Represents the input time step The attention weight for the current output time step t; Indicates the length of the input sequence; represents the input time step; Represents the input time step A vector of values of ; represents the context vector generated by weighted summation at the input time step t; Q represents the query matrix, where each row represents a query vector ; K represents the key matrix, where each row represents a key vector ; is the transpose of the key matrix K; V represents the value matrix, where each row represents a value vector ; represents the normalization factor for scaling dot product similarity; is a function call representing the output of the self-attention mechanism.
[0010] In a possible embodiment, the hybrid attention mechanism-bidirectional long short-term memory network model includes a memory unit, and the operation steps of the memory unit include: Receive the current time step Input and the previous time step The hidden state of ; The forget gate is calculated by the following formula: ; The input gate is calculated by the following formula: ; The cell status is updated by calculating the following formula: ; The output gate is calculated by the following formula: ; The updated hidden state is calculated using the following formula: ; In the formula, Indicates the current time step The input vector of Represents the previous time step The hidden state of represents the output of the forget gate; Represents the weight matrix of the forget gate; Represents the bias term of the forget gate; Represents the weight matrix from hidden state to forget gate; Represents the bias term from the hidden state to the forget gate; represents the output of the input gate; Represents the sigmoid activation function; represents the weight matrix of the input gate; represents the bias term of the input gate; Represents the weight matrix from hidden state to input gate; Represents the bias term from the hidden state to the input gate; Indicates the cell state at the current moment; Indicates the cell state at the previous moment; Indicates corresponding multiplication of elements in the same position; represents the candidate cell state; represents the output of the output gate; Represents the weight matrix of the output gate; represents the bias term of the output gate; Represents the weight matrix from hidden state to output gate; Represents the bias term from the hidden state to the output gate; Represents the output of the current time step, which is also used as the next time step The hidden state of the input.
[0011] In a possible embodiment, the photovoltaic power generation history data includes global horizontal irradiance, direct normal irradiance, diffuse horizontal irradiance, relative humidity, wind speed, inclined irradiance, component temperature and DC side power.
[0012] In a second aspect, an embodiment of the present invention further provides a photovoltaic power prediction method, comprising: Obtain analytical data of the photovoltaic power station, including meteorological data and power data of the photovoltaic power station; The analysis data is input into the trained photovoltaic power prediction model to obtain the predicted data of the photovoltaic power station power generation output by the trained photovoltaic power prediction model. The trained photovoltaic power prediction model is a model trained based on the model training method as described above.
[0013] In a third aspect, an embodiment of the present invention further provides a photovoltaic power generation prediction model training device, which includes a module / unit that executes any possible design method of the first aspect. These modules / units can be implemented by hardware, or by hardware executing corresponding software implementations.
[0014] In a fourth aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory is used to store one or more computer programs; when the one or more computer programs stored in the memory are executed by the processor, the electronic device can implement any possible design method of the first aspect.
[0015] In a fifth aspect, a computer-readable storage medium is also provided in an embodiment of the present invention, and the computer-readable storage medium includes a computer program. When the computer program runs on an electronic device, the electronic device executes any possible design method of the first aspect mentioned above.
[0016] In a sixth aspect, an embodiment of the present invention further provides a method comprising a computer program product, which, when the computer program product runs on an electronic device, enables the electronic device to execute any possible design of any of the above aspects.
[0017] The beneficial effects of the present invention are as follows: a photovoltaic power generation prediction method based on a hybrid attention mechanism-bidirectional long short-term memory network model is proposed, the feature data set is reduced in dimension through principal component analysis, and the first principal component is extracted as a new feature, retaining the key change trend in the data; a bidirectional long short-term memory network is adopted to capture past and future information at the same time; a hybrid attention mechanism of local attention and self-attention is introduced, firstly the short-term dependency of the sequence is captured through local attention, and then the global range relationship is captured through self-attention, thereby achieving a comprehensive improvement in the model performance, so as to achieve the purpose of effectively improving the prediction accuracy and meeting the actual prediction requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a schematic diagram of the flow of the photovoltaic power generation prediction model training method of the present invention.
[0019] Figure 2 The present invention is a flowchart of the local attention mechanism in the photovoltaic power prediction model training method.
[0020] Figure 3 The present invention is a flowchart of the calculation of the self-attention mechanism in the photovoltaic power prediction model training method.
[0021] Figure 4 It is a structural diagram of the SLA-BiLSTM network in the photovoltaic power generation prediction model training method of the present invention.
[0022] Figure 5 The figure is a flow chart of a specific example of the photovoltaic power generation prediction model training method of the present invention.
[0023] Figure 6 It is a schematic diagram of the photovoltaic power generation prediction device of the present invention.
[0024] Figure 7 It is a schematic diagram of the structure of the electronic device of the present invention. DETAILED DESCRIPTION
[0025] 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. 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.
[0026] In view of the problems existing in the above-mentioned technologies, an embodiment of the present invention provides a photovoltaic power generation prediction model training method, see Figure 1 , the model training method includes: S101: Obtaining photovoltaic power generation history data of the photovoltaic power station, the photovoltaic power generation history data includes meteorological data and photovoltaic power generation data, extracting feature data from the photovoltaic power generation history data, calculating feature importance scores of the feature data using the Split Statistics principle in the CatBoost algorithm, and determining important feature data according to the feature importance scores; S102: using the principal component analysis (PCA) method to perform data standardization processing on the important feature data to obtain standardized data, calculating the covariance matrix of the standardized data, performing eigenvalue decomposition on the covariance matrix to obtain eigenvalues and eigenvectors corresponding to the eigenvalues, constructing a principal component loading matrix according to the eigenvectors, obtaining a principal component feature matrix according to the principal component loading matrix and the standardized data matrix, calculating the variance contribution rate of each principal component feature, and adding the principal component feature with the largest variance contribution rate to the important feature data to obtain updated feature data; S103: Dividing the updated feature data into a training set, a validation set, and a test set according to a preset ratio; S104: Establish a hybrid attention mechanism-bidirectional long short-term memory network model, the hybrid attention mechanism includes a local attention mechanism and a self-attention mechanism, select a hyperparameter type and set the initial value of each hyperparameter; S105: Use the training set to train the hybrid attention mechanism-bidirectional long short-term memory network model, and use the validation set to verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model reaches the expected effect. If not, adjust the value of the hyperparameter and return to step S105; if yes, output the trained photovoltaic power generation prediction model; S106: Use the test set to test and evaluate the trained photovoltaic power generation prediction model.
[0027] The present invention optimizes feature extraction and time-dependent modeling and improves prediction accuracy by combining PCA dimensionality reduction, bidirectional long short-term memory network, local attention mechanism and self-attention mechanism. The specific analysis is as follows: By obtaining the historical data of photovoltaic power generation of photovoltaic power stations, including meteorological data and photovoltaic power generation data, and extracting feature data from them, the split statistics principle in the CatBoost algorithm is then used to calculate the number of splits of each feature in the decision tree and the gain brought by the splits, and the feature importance score is obtained. According to the feature importance score, samples with significant impact on power prediction are screened out to reduce redundant information.
[0028] Data standardization eliminates the dimension and order of magnitude differences between different features, allowing each feature to be compared and analyzed on the same scale, improving the quality and comparability of the data. This helps the subsequent covariance matrix calculation and eigenvalue decomposition, avoiding calculation deviations caused by different data scales. By selecting the principal component with the largest variance contribution rate, the main change trend in the data is extracted, the most important information in the data is retained, and the redundant information in the data is removed, which helps to reduce the risk of overfitting of the model and improve the generalization ability of the model. After removing redundant information, the data set is more concise and the model training is more efficient. The principal component feature with the largest variance contribution rate is selected and added to the important feature data to obtain the updated feature data, ensuring that the updated feature data contains the most important information in the original data to better capture the main change trend in the data, thereby improving the stability of the model and the prediction accuracy. The original high-dimensional feature data set is converted into a low-dimensional principal component matrix by principal component analysis, reducing the dimension and calculation amount of the data and improving the calculation efficiency. This can not only improve the training speed of the model, but also reduce the consumption of computing resources, providing a solid foundation for subsequent model training and prediction.
[0029] A hybrid attention mechanism-bidirectional long short-term memory network model is established. The hybrid attention mechanism includes a local attention mechanism and a self-attention mechanism, which can better capture the key information in the data and the dependencies of the time series. At the same time, the bidirectional long short-term memory network can consider both past and future information at the same time, thereby improving the stability and prediction accuracy of the model. By reasonably selecting the hyperparameter type and setting the initial value of each hyperparameter, the training process of the model can be further optimized to avoid stability problems caused by improper time span settings.
[0030] In a specific embodiment, the photovoltaic power generation historical data includes global horizontal irradiance, direct normal irradiance, diffuse horizontal irradiance, relative humidity, wind speed, inclined irradiance, component temperature and DC side power.
[0031] In one embodiment, the important feature data is a feature data set of n×m X =[ x 1 , x 2 ,…, x n ] T , No. i The feature vector of the sample x i =[ x i1 , x i2 ,…, x im]. The calculation formula for data standardization includes: j The mean of the features ; Calculate the j The variance of the features ; Standardized calculation of the jth feature of the i-th sample The calculation formula of the covariance matrix includes: ; Because the mean of each feature after standardization is 0 and the variance is 1, we get: The covariance matrix ∑ is a symmetric matrix, so it can be decomposed into eigenvalues. Let one eigenvalue of the covariance matrix be λ , the corresponding eigenvector is v , the calculation formula of eigenvalue decomposition includes: ; The eigenvalue λ is obtained by solving the characteristic equation: ; The eigenvalues from large to small are , the corresponding eigenvector is . Let the eigenvector matrix be V =[ v 1 , v 2 , …, v m ]; The calculation formula of the principal component characteristic matrix includes: When the principal component loading matrix A = V When , the principal component feature matrix can be constructed T = ZA The calculation formulas for variance contribution rate and cumulative variance contribution rate include: ; In the above calculation formula, n represents the number of samples; m Indicates the number of features; i Indicates the sample index; j Represents the feature index; Indicates i The sample j Features Indicates j The mean of the features; Indicates j The variance of the feature; Represents the standardized data matrix; Represents the standardized data matrix The transposed matrix of ; ∑ represents the covariance matrix; x :i Indicates i Features x :j Indicates j Featuresr ij Represents the standardized features x :i and x :j The correlation coefficient of Indicates The sample Features Indicates The sample j Features Indicates The mean of the features; Indicates The variance of the features; E represents the identity matrix; λ represents the eigenvalue; v represents the feature vector; V represents the eigenvector matrix; A represents the principal component loading matrix; T represents the principal component feature matrix; Indicates The eigenvalues of the principal components; Indicates j The eigenvalues of the principal components; η k represents the variance contribution rate, that is, principal component features T:,k The proportion of total variance; γ k Before The sum of the variance contributions of the principal component features.
[0032] In this embodiment, the principal component feature with the largest variance contribution rate, that is, the first principal component T:, 1 is added to the important feature data to obtain the updated feature data. Since the first principal component T:, 1 has the strongest ability to explain the overall variance of the data, so it is taken as the m+1th feature of the important feature data set.
[0033] Through standardization, covariance matrix decomposition and principal component selection, PCA achieves the following: 1. Eliminate redundancy: remove features with low variance or high correlation; 2. Capture key trends: the first principal component retains the most significant change pattern in the data; 3. Improve model efficiency: reduce dimensionality and reduce computational complexity while alleviating overfitting.
[0034] In one embodiment, see Figure 2 , the operation steps of the local attention mechanism include: paying attention to the elements within the set local window size (2w+1) for each position t in the sequence, and calculating the attention score of the local window by the following formula: The context representation of time step t is obtained by weighted summing the values of the local window using the following formula: In the calculation step formula of the local attention mechanism, the trainable parameters are used by the following formula To replace the local window center t: ;because It may be a floating point number type. The normal distribution term is introduced into the attention score formula to obtain: In the above calculation formula, represents the input time step; t represents the current output time step; Indicates half of the local window size; Indicates the range of the local window; Represents the input time step The attention weight for the current output time step t; represents the query vector at the current output time step t; is the key vector The transpose of Represents the input time step The key vector of ; represents the normalization factor for scaling dot product similarity; represents the local dynamic context vector at the current output time step t; Indicates that at the input time step The eigenvector when ; is a trainable parameter; represents the scaling factor; Indicates the length of the input sequence; Represents the sigmoid activation function; is the trainable parameter vector The transpose of represents a trainable parameter vector; represents the input vector at the current output time step t.
[0035] The core idea of the local attention mechanism is to focus only on the elements in the nearby window for each position t in the sequence, rather than the global sequence. This design can capture short-term dependencies and significantly reduce computational complexity.
[0036] The core of the attention mechanism is to calculate the similarity between the query vector (Query), the key vector (Key) and the value vector (Value). Among them, the Value is used to calculate the aggregate information, and the weight of each Value is determined by calculating the similarity between the Query and the address Key of the element in the memory, and then the weighted sum of the Value is performed, which is the attention value.
[0037] In one embodiment, see Figure 3, the operation steps of the self-attention mechanism include: according to the query vector and key vector The similarity of , using the dot product model to calculate the attention score: The attention score is converted to the attention weight by the following formula: On the one hand, it can be normalized to obtain a probability distribution where the sum of all weight coefficients is 1, and on the other hand, the characteristics of the softmax function can be used to highlight the weights of important elements. The following formula is used to calculate the value vector according to the attention weight Perform weighted summation to generate context vector : Query vector , key vector and value vector Derived from the same input sequence, that is, Q=K=V, it helps different samples in the input sequence to pay attention to each other and better capture global dependencies. The formula is: In the above calculation formula, represents the input time step; t represents the current output time step; represents the query vector at the current output time step t; Represents the input time step The key vector of is the key vector The transpose of Represents the query vector and key vector Similarity score of Represents the input time step The attention weight for the current output time step t, i.e. the input time step Importance of the current output time step t; Indicates the length of the input sequence; represents the input time step; Represents the input time step A vector of values of ; represents the context vector generated by weighted summation at the input time step t; Q represents the query matrix, where each row represents a query vector ; K represents the key matrix, where each row represents a key vector ; is the transpose of the key matrix K; V represents the value matrix, where each row represents a value vector ; Represents the normalization factor of the scaled dot product similarity, which is used to alleviate the problem of gradient disappearance; is a function call representing the output of the self-attention mechanism.
[0038] In one embodiment, see Figure 4 , the hybrid attention mechanism-bidirectional long short-term memory network model includes a memory unit, and the operation steps of the memory unit include: initialization: receiving the current time step Input and the previous time step The hidden state of . Forget gate calculation: The purpose of the forget gate is to determine how much information to retain from the cell state. It is calculated using the sigmoid activation function and the forget gate is calculated using the following formula: . Input gate calculation: The input gate is responsible for determining which parts of the cell state to update and what new information to add. The input gate has two parts: a sigmoid function (determines the extent of the update) and a tanh function (generates new candidate values). The input gate is calculated using the following formula: . Cell state update: The cell state is updated by combining the output of the forget gate and the input gate. Specifically, the cell state is updated by calculating the following formula: Output gate calculation: The output gate determines how much information in the hidden state of the current time step will be passed to the output. Similar to the forget gate and input gate, the output gate also uses the sigmoid function and is calculated using the following formula: Hidden state update: The hidden state is calculated by applying a function of the cell state to the output of the output gate. The updated hidden state is calculated as follows: , as the output for the current time step, and also for the next time step The hidden state of the input In the above calculation formula, Indicates the current time step The input vector of Represents the previous time step The hidden state of represents the output of the forget gate; Represents the weight matrix of the forget gate; Represents the bias term of the forget gate; Represents the weight matrix from hidden state to forget gate; Represents the bias term from the hidden state to the forget gate; represents the output of the input gate; Represents the sigmoid activation function; represents the weight matrix of the input gate; represents the bias term of the input gate; Represents the weight matrix from hidden state to input gate; Represents the bias term from the hidden state to the input gate; Indicates the cell state at the current moment; Indicates the cell state at the previous moment; Indicates corresponding multiplication of elements in the same position; represents the candidate cell state; represents the output of the output gate; Represents the weight matrix of the output gate; represents the bias term of the output gate; Represents the weight matrix from hidden state to output gate; Represents the bias term from the hidden state to the output gate; Represents the output of the current time step, which is also used as the next time step The hidden state of the input.
[0039] The present invention also provides a photovoltaic power generation power prediction method, comprising: Obtain analytical data of the photovoltaic power station, including meteorological data and power data of the photovoltaic power station; The analysis data is input into the trained photovoltaic power prediction model to obtain the predicted data of the photovoltaic power station power generation output by the trained photovoltaic power prediction model. The trained photovoltaic power prediction model is a model trained based on the model training method as described above.
[0040] The following is an explanation of the process of model training methods for different models with specific examples.
[0041] See also Figure 5, select the power station, determine the power station configuration, obtain meteorological data and power data, and screen the samples; analyze the features, perform PCA dimensionality reduction on the features, and PCA dimensionality reduction includes: feature standardization, calculation of covariance matrix, eigenvalue decomposition, and obtain the eigenvalues and corresponding eigenvectors of the covariance matrix, load matrix, principal component matrix, and the first principal component, that is, the principal component feature with the largest variance contribution rate as the m+1th feature. Normalize the feature data after PCA dimensionality reduction, and divide the data into training set, validation set, and test set. Build a model and select the hyperparameter category, set the initial value of the hyperparameter, train the model, check the model effect on the validation set, and determine whether the expected effect is achieved. If the expected effect is not achieved, adjust the hyperparameter value and train the model again until the model achieves the expected effect. According to the above-mentioned model training method, the model training of the Long Short-Term Memory (LSTM) model, the Bidirectional Long Short-Term Memory (BiLSTM) model, the Principal Component Analysis-Bidirectional Long Short-Term Memory (PCA-BiLSIM) model, and the Principal Component Analysis-Specific Local Attention-Bidirectional Long Short-Term Memory (PCA-SLA-BiLSTM) model is completed, and then the performance of each model is tested and evaluated. The test and evaluation steps include: determining the hyperparameter value, using the test set to test each model respectively, and evaluating and analyzing each model.
[0042] The following is a comparative analysis of the performance of each model based on specific cases.
[0043] Based on the analysis of 4473 sets of data from a centralized photovoltaic power station in a certain city from January to December 2020, the screened data set was divided into training set, validation set and test set in the ratio of 9:0.5:0.5; secondly, the hyperparameters were adjusted many times, and the hyperparameter values were determined by the results of the validation set as follows: the time step value is 1, the number of hidden layers is 3, the number of hidden layer units is 128, the learning rate is 0.01, the number of iterations is 150 times, the loss function is the mean square error MSE, and the optimizer uses the Adam gradient descent method.
[0044] Root mean square error (RMSE), mean absolute error (MAE), determination coefficient (R2) and mean absolute percentage error (MAPE) were selected as evaluation indicators of the model. Four algorithm models, LSTM, BiLSTM, PCA-BiLSTM and PCA-SLA-BiLSTM, were built and compared. The evaluation indicators of the four models for predicting the test set are shown in the following table: ; Among the four evaluation indicators, the PCA-SLA-BiLSTM model has the best overall performance, with the lowest RMSE (63.8871), MAE (36.1304) and MAPE, and R2 (0.9974) is closest to 1, indicating the best fitting effect. The BiLSTM and PCA-BiLSTM models are also better than the original LSTM model in all aspects. Although the PCA-BiLSTM model is slightly higher than the BiLSTM in terms of RMSE, its MAPE has a more significant decrease compared to the BiLSTM, which is 0.3709% lower. In summary, by adding bidirectional networks, principal component analysis and self-local attention mechanisms, the LSTM model has achieved an overall improvement in performance.
[0045] The present invention provides a short-term photovoltaic power prediction method based on a PCA-SLA-BiLSTM model. The method performs dimensionality reduction processing on the original data set through principal component analysis, and extracts the principal component features with the largest variance contribution rate as new features, thereby retaining the key change trends in the data; converting the LSTM network into a bidirectional network to capture past and future information at the same time; introducing a hybrid attention mechanism of local attention and self-attention, thereby achieving a comprehensive improvement in model performance, thereby solving the problem that the results obtained by the LSTM prediction method are one-sided and unstable, and improving the accuracy of photovoltaic power station prediction of photovoltaic power generation. This can not only avoid the paralysis of the power system that may be caused by the fluctuation of the grid-connected photovoltaic power generation power when the proportion of the total power generation power of the entire power system exceeds 15%, but also reduce the impact of grid connection and the adjustment work of the power grid. At the same time, through more accurate resource allocation, the method helps to improve the overall efficiency of power grid dispatching and photovoltaic power station operation, thereby improving the economic benefits of the power station.
[0046] The photovoltaic power generation prediction model training method of the present invention is compared and analyzed with the traditional model training method to explain the technical effect of the present invention.
[0047] Traditional local attention usually uses a fixed window (such as a sliding window) or a preset offset, and the center position of the window is fixed to the current time step t, which has low flexibility. Dynamically adjust the window center position, window center Based on the hidden state at the previous moment Dynamic generation enables the window position to adapt to data characteristics (such as sudden changes in irradiance or cloud movement), expanding the range of attention to capture a wider context, thereby achieving adaptive perception. The neural network adjusts the window range to adapt to the dependencies of different time scales and has time series adaptability. Therefore, the flexibility and adaptability are improved by adapting to the data characteristics through dynamic windows.
[0048] Traditional local attention usually uses hard truncation (such as fixed window boundaries) to directly average or linearly weight the positions within the window, which may cause information loss at the boundaries due to hard truncation. , introduce the normal distribution probability density function as the position weight, and smoothly weight the position in the window. The position weight in the window increases with the distance Attenuation avoids the boundary effects of hard clipping and enhances the focus on nearby key locations, e.g. Higher weights are given to historical moments to achieve smooth attention distribution. Normal distribution weighting can be combined with dot product attention to reduce redundant calculations and optimize computational efficiency. Normal distribution weighting reduces noise interference and improves the accuracy of capturing sudden events (such as cloud occlusion), thereby achieving noise resistance.
[0049] Traditional local attention and self-attention are usually used independently or simply stacked, which may ignore multi-scale feature fusion. The traditional self-attention mechanism directly calculates global dependencies, but the computational complexity is high and local details may be ignored. The present invention forms a local-global hierarchical attention structure by using the local attention output as the input of self-attention. The local attention captures short-term fluctuations, and the complexity is reduced to the window size. Based on the local attention output, the self-attention further models the global long-term cycle. Local dependency and global dependency complement each other, improving the model's modeling ability for complex time series patterns and realizing multi-scale feature fusion. Local attention limits the calculation range of the window size, and self-attention focuses on key global nodes, making the overall complexity lower than the pure self-attention model. Local fluctuations and global trends are collaboratively modeled to improve prediction robustness.
[0050] The present invention uses dynamic window center and normally distributed weights, on the one hand, the attention mechanism can be associated with meteorological time series patterns, for example: The offset direction reflects the temporal propagation characteristics of meteorological events, and the standard deviation of the normal distribution controls the scope of attention, corresponding to the spatiotemporal diffusion range of meteorological impacts. On the other hand, the principal components guide attention, and combined with the principal component characteristics with the largest variance contribution rate extracted by principal component analysis, the self-attention weight can be interpreted as a dynamic response to the core meteorological variables, thereby improving the reliability of the model.
[0051] The weight matrix and bias of the forget gate, input gate and output gate of the traditional LSTM are fixed parameters and cannot be adjusted dynamically according to the input. The present invention introduces an environmental perception mechanism to dynamically correct the gating parameters through the principal component features with the largest variance contribution rate extracted by PCA, thereby enhancing the gating's responsiveness to core meteorological trends. The principal component features with the largest variance contribution rate are directly injected into the candidate cell state generation process to improve the modeling accuracy of key trends. The gating behavior is dynamically adjusted with external features. For example, when the irradiance drops sharply, the cleaning effect of the forget gate is enhanced to avoid interference from outdated meteorological information.
[0052] The forward and backward LSTMs of the traditional BiLSTM operate independently, and only combine information by splicing hidden states, and the interaction is delayed. The present invention designs a forward-backward forget gate coordination mechanism. Through cross-gated interaction, the forward forget gate can be dynamically affected by the backward hidden state, directly introduce cross-gated interaction at the gating level, adjust the information flow in real time, and enhance the response speed and accuracy to time series events (such as sudden meteorological changes). The present invention adopts dynamic bidirectional information fusion to integrate historical and future information in real time at the gating level, which can be interpreted as the intensity of the impact of future information on current decisions, and improves the response ability to time series events. Associate the gated signal with meteorological events to support model decision analysis. Through the dynamic fusion of cross-gating, the problem of historical-future information splitting in traditional BiLSTM is solved, which is particularly suitable for the mixed scenario of sudden fluctuations and long-term trends in photovoltaic power forecasting.
[0053] In addition, the present invention also proposes a photovoltaic power generation prediction model training device, see Figure 6The device includes: a feature processing module 601, which is used to obtain the photovoltaic power generation history data of the photovoltaic power station, extract feature data from the photovoltaic power generation history data, use the CatBoost algorithm to calculate the feature importance score of the feature data, and determine the important feature data according to the feature importance score; a principal component analysis module 602, which is used to use the principal component analysis method to perform data standardization processing on the important feature data to obtain standardized data, calculate the covariance matrix of the standardized data, perform eigenvalue decomposition on the covariance matrix to obtain eigenvalues and eigenvectors corresponding to the eigenvalues, construct a principal component load matrix according to the eigenvectors, obtain a principal component feature matrix according to the principal component load matrix and the standardized data matrix, calculate the variance contribution rate of each principal component feature, and add the principal component feature with the largest variance contribution rate to the important feature data to obtain updated feature data; data The partition module 603 is used to divide the updated feature data into a training set, a validation set and a test set according to a preset ratio; the model building module 604 is used to establish a hybrid attention mechanism-bidirectional long short-term memory network model, the hybrid attention mechanism includes a local attention mechanism and a self-attention mechanism, select the hyperparameter type and set the initial value of each hyperparameter; the model training optimization module 605 is used to use the training set to train the hybrid attention mechanism-bidirectional long short-term memory network model, and use the validation set to verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model reaches the expected effect. If not, adjust the value of the hyperparameter and return to the execution model training optimization module; if so, output the trained photovoltaic power generation prediction model; the model test evaluation module 606 is used to test and evaluate the trained photovoltaic power generation prediction model using the test set. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.
[0054] In some other embodiments of the present invention, an electronic device is disclosed. Figure 7 , the electronic device may include: one or more processors 701; memory 702; display 703; one or more applications (not shown); and one or more computer programs 704, and the above components may be connected via one or more communication buses 705. The one or more computer programs 704 are stored in the above memory 702 and configured to be executed by the one or more processors 701, and the one or more computer programs 704 include instructions, which may be used to execute the following: Figure 1 and Figure 6 And each step in the corresponding embodiment.
[0055] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0056] Each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0057] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk and other media that can store program codes.
[0058] Although the embodiments of the present invention are described in detail above, it is obvious to those skilled in the art that various modifications and changes can be made to these embodiments. However, it should be understood that such modifications and changes are within the scope and spirit of the present invention described in the claims. Moreover, the present invention described herein may have other embodiments and may be implemented or realized in a variety of ways. Unless otherwise defined, the technical terms or scientific terms used herein should be understood by people with ordinary skills in the field to which the present invention belongs. The words "including" and the like used herein mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects.
Claims
1. A photovoltaic power generation prediction model training method, characterized in that: The model training method comprises: S101: Acquire photovoltaic power generation history data of a photovoltaic power station, extract feature data from the photovoltaic power generation history data, calculate feature importance scores of the feature data using a CatBoost algorithm, and determine important feature data according to the feature importance scores; S102: using principal component analysis to perform data standardization on the important feature data to obtain standardized data, calculating the covariance matrix of the standardized data, performing eigenvalue decomposition on the covariance matrix to obtain eigenvalues and eigenvectors corresponding to the eigenvalues, constructing a principal component loading matrix according to the eigenvectors, obtaining a principal component feature matrix according to the principal component loading matrix and the standardized data matrix, calculating the variance contribution rate of each principal component feature, and adding the principal component feature with the largest variance contribution rate to the important feature data to obtain updated feature data; S103: Dividing the updated feature data into a training set, a validation set and a test set according to a preset ratio; S104: Establishing a hybrid attention mechanism-bidirectional long short-term memory network model, wherein the hybrid attention mechanism includes a local attention mechanism and a self-attention mechanism, selecting a hyperparameter type and setting an initial value of each hyperparameter; S105: using the training set to train the hybrid attention mechanism-bidirectional long short-term memory network model, and using the validation set to verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model reaches the expected effect; if not, adjusting the value of the hyperparameter, and returning to step S105; if yes, outputting the trained photovoltaic power generation prediction model; S106: Use the test set to test and evaluate the trained photovoltaic power generation prediction model.
2. The model training method according to claim 1, characterized in that: The important feature data is a feature data set of n×m X =[ x 1 , x 2 ,…, x n ] T , No. i The feature vector of the sample x i =[ x i1 , x i2 ,…, x im ]; The calculation formula for data standardization includes: ; ; ; The calculation formula of the covariance matrix includes: ; ; The calculation formula of the eigenvalue decomposition includes: ; ; V =[ v 1 , v 2 , …, v m ]; The calculation formula of the principal component feature matrix includes: A = V ; T = ZA ; The calculation formulas for the variance contribution rate and the cumulative variance contribution rate include: ; ; In the formula, n represents the number of samples; m Indicates the number of features; i Indicates the sample index; j Represents the feature index; Indicates i The sample j Features Indicates j The mean of the features; Indicates j The variance of the feature; Represents the standardized data matrix; Represents the standardized data matrix The transposed matrix of ; ∑ represents the covariance matrix; x :i Indicates i Features x :j Indicates j Features r ij Represents the standardized features x :i and x :j The correlation coefficient of Indicates The sample Features Indicates The sample j Features Indicates The mean of the features; Indicates The variance of the features; E represents the identity matrix; λ represents the eigenvalue; v represents the feature vector; V represents the eigenvector matrix; A represents the principal component loading matrix; T represents the principal component feature matrix; Indicates The eigenvalues of the principal components; Indicates j The eigenvalues of the principal components; η k represents the variance contribution rate; γ k Before The sum of the variance contributions of the principal component features.
3. The model training method according to claim 1, characterized in that: The operation steps of the local attention mechanism include: For each position t of the sequence, focus on the elements within the set local window size (2w+1), and calculate the attention score of the local window by the following formula: ; The values of the local window are weighted and summed by the following formula to obtain the context representation of time step t: ; In the operation step formula of the local attention mechanism, the trainable parameters are used by the following formula To replace the local window center t: ; The normal distribution term is introduced into the attention score formula to obtain: ; In the formula, represents the input time step; t represents the current output time step; Indicates half of the local window size; Indicates the range of the local window; Represents the input time step The attention weight for the current output time step t; represents the query vector at the current output time step t; is the key vector The transpose of Represents the input time step i The key vector of ; represents the normalization factor for scaling dot product similarity; represents the local dynamic context vector at the current output time step t; Indicates that at the input time step i The eigenvector when ; is a trainable parameter; represents the scaling factor; Indicates the length of the input sequence; Represents the sigmoid activation function; is the trainable parameter vector The transpose of represents a trainable parameter vector; represents the input vector at the current output time step t.
4. The model training method according to claim 1, characterized in that: The operation steps of the self-attention mechanism include: According to the following formula, the query vector and key vector The similarity of , using the dot product model to calculate the attention score: ; The attention score is converted into attention weight by the following formula: ; The value vector is given by the following formula according to the attention weight Perform weighted summation to generate context vector : ; Query Vector , key vector and value vector Derived from the same input sequence, it satisfies the following formula: Q=K=V; ; In the formula, represents the input time step; t represents the current output time step; represents the query vector at the current output time step t; represents the key vector at input time step i, is the key vector The transpose of Represents the query vector and key vector Similarity score of ; Represents the input time step The attention weight for the current output time step t; Indicates the length of the input sequence; represents the input time step; Represents the input time step A vector of values of ; represents the context vector generated by weighted summation at the input time step t; Q represents the query matrix, where each row represents a query vector ; K represents the key matrix, where each row represents a key vector ; is the transpose of the key matrix K; V represents the value matrix, where each row represents a value vector ; represents the normalization factor for scaling dot product similarity; is a function call representing the output of the self-attention mechanism.
5. The model training method according to claim 1, characterized in that: The hybrid attention mechanism-bidirectional long short-term memory network model includes a memory unit, and the operation steps of the memory unit include: Receive the current time step Input and the previous time step The hidden state of ; The forget gate is calculated by the following formula: ; The input gate is calculated by the following formula: ; The cell status is updated by calculating the following formula: ; The output gate is calculated by the following formula: ; The updated hidden state is calculated using the following formula: ; In the formula, Indicates the current time step The input vector of Represents the previous time step The hidden state of Represents the output of the forget gate; Represents the weight matrix of the forget gate; Represents the bias term of the forget gate; Represents the weight matrix from hidden state to forget gate; Represents the bias term from the hidden state to the forget gate; represents the output of the input gate; Represents the sigmoid activation function; represents the weight matrix of the input gate; represents the bias term of the input gate; Represents the weight matrix from hidden state to input gate; Represents the bias term from the hidden state to the input gate; Indicates the cell state at the current moment; Indicates the cell state at the previous moment; Indicates the corresponding multiplication of elements in the same position; represents the candidate cell state; represents the output of the output gate; Represents the weight matrix of the output gate; Represents the bias term of the output gate; Represents the weight matrix from hidden state to output gate; Represents the bias term from the hidden state to the output gate; Represents the output of the current time step, which is also used as the next time step The hidden state of the input.
6. The model training method according to any one of claims 1 to 5, characterized in that: The photovoltaic power generation historical data includes global horizontal irradiance, direct normal irradiance, diffuse horizontal irradiance, relative humidity, wind speed, inclined irradiance, component temperature and DC side power.
7. A photovoltaic power generation power prediction method, characterized in that: include: Acquiring analysis data of the photovoltaic power station, wherein the analysis data includes meteorological data and power data of the photovoltaic power station; The analysis data is input into the trained photovoltaic power generation prediction model to obtain the prediction data of the photovoltaic power station power generation output by the trained photovoltaic power generation prediction model, wherein the trained photovoltaic power generation prediction model is a model trained based on the model training method according to any one of claims 1 to 6.
8. A photovoltaic power generation prediction model training device, characterized in that: The device comprises: A feature processing module, used to obtain photovoltaic power generation history data of the photovoltaic power station, extract feature data from the photovoltaic power generation history data, calculate feature importance scores of the feature data using a CatBoost algorithm, and determine important feature data according to the feature importance scores; A principal component analysis module, for performing data standardization processing on the important feature data using the principal component analysis method to obtain standardized data, calculating the covariance matrix of the standardized data, performing eigenvalue decomposition on the covariance matrix to obtain eigenvalues and eigenvectors corresponding to the eigenvalues, constructing a principal component loading matrix according to the eigenvectors, obtaining a principal component feature matrix according to the principal component loading matrix and the standardized data matrix, calculating the variance contribution rate of each principal component feature, and adding the principal component feature with the largest variance contribution rate to the important feature data to obtain updated feature data; A data partitioning module, used to divide the updated feature data into a training set, a validation set and a test set according to a preset ratio; A model building module is used to establish a hybrid attention mechanism-bidirectional long short-term memory network model, wherein the hybrid attention mechanism includes a local attention mechanism and a self-attention mechanism, select a hyperparameter type and set an initial value of each hyperparameter; A model training optimization module is used to train the hybrid attention mechanism-bidirectional long short-term memory network model using the training set, and to verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model reaches the expected effect using the verification set. If not, the value of the hyperparameter is adjusted, and the model training optimization module is returned to execute; if yes, the trained photovoltaic power generation prediction model is output; The model testing and evaluation module is used to test and evaluate the trained photovoltaic power generation prediction model using the test set.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store a computer program; The processor is configured to execute the computer program stored in the memory so as to enable the electronic device to perform the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Wind power ultra-short-term prediction method of improved bidirectional long-short-term memory network
CN112949945A
Photovoltaic power prediction method and system based on principal component analysis and improved LSTM
CN113487064A
Wind power prediction method based on EMD-KPCA-BiLSTM-ATT model
CN118232341A
Solar photovoltaic power generation power prediction method fusing time-space relationship
CN118569423A
Industrial circulating water system temperature prediction method based on BiLSTM-ARIMA-Attention
CN118981750A
Cited By
Internet of Things system and device based on fifth generation mobile communication technology, and medium
CN120342910A
Process parameter optimization method and equipment in injection molding process and medium
CN120449724A
Temperature prediction method, system and equipment of hot blast stove vault and medium
CN120632429A