Photovoltaic power generation power prediction model training method, prediction method, device, equipment and medium
By introducing a hybrid attention mechanism—a bidirectional long short-term memory network model and principal component analysis—in photovoltaic power generation prediction, the problems of bias and stability of LSTM results in photovoltaic power generation prediction are solved, thereby improving prediction accuracy and stability.
Patent Information
- Application Number
- CN202510339463.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-03-21
AI Technical Summary
Existing Long Short-Term Memory (LSTM) networks have insufficient consideration of specific correlation coefficients in photovoltaic power generation prediction, leading to biased results, and the long training time of the models affects stability.
A hybrid attention mechanism—a bidirectional long short-term memory network model—is adopted, which combines principal component analysis to reduce the dimensionality of the feature data. Local and self-attention mechanisms are introduced, with local attention capturing short-term dependencies and self-attention capturing global relationships to optimize model performance.
It improves the accuracy and stability of photovoltaic power generation forecasting, and can better capture key information and time series dependencies in the data to meet actual forecasting requirements.
Smart Images

Figure CN119853033B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of photovoltaic power generation technology, and in particular to a photovoltaic power generation prediction model training method, prediction method, device, equipment and medium. Background Technology
[0002] Long Short-Term Memory Network (LSTM) is an improved type of Recurrent Neural Network (RNN) that addresses the vanishing or exploding gradient problems encountered when processing long-term time series data. LSTM's advantages lie in its ability to extract the spatiotemporal correlation between the output and relevant input variables compared to traditional photovoltaic power prediction methods, and it has also made significant progress in the field of complex time series prediction.
[0003] However, LSTM has two problems when predicting photovoltaic power generation. First, it does not consider the magnitude of specific correlation coefficients, resulting in biased results. Second, setting the time span during LSTM model training to be too long may affect the stability of the LSTM.
[0004] Therefore, it is necessary to propose a training method, prediction method, device, equipment, and medium for photovoltaic power generation prediction models to solve the above problems. Summary of the Invention
[0005] The purpose of this invention is to provide a photovoltaic power generation prediction model training method, prediction method, device, equipment and medium to improve model performance and increase prediction accuracy.
[0006] In a first aspect, the present invention provides a method for training a photovoltaic power generation prediction model, the model training method comprising:
[0007] S101: Obtain historical photovoltaic power generation data from photovoltaic power plants, extract feature data from the historical photovoltaic power generation data, calculate the feature importance score of the feature data using the CatBoost algorithm, and determine important feature data based on the feature importance score;
[0008] S102: Principal component analysis is used to standardize the important feature data to obtain standardized data. The covariance matrix of the standardized data is calculated, and the covariance matrix is decomposed into eigenvalues to obtain eigenvalues and corresponding eigenvectors. The principal component loading matrix is constructed based on the eigenvectors. The principal component feature matrix is obtained based on the principal component loading matrix and the standardized data matrix. The variance contribution rate of each principal component feature is calculated, and the principal component feature with the largest variance contribution rate is added to the important feature data to obtain the updated feature data.
[0009] S103: Divide the updated feature data into training set, validation set and test set according to a preset ratio;
[0010] S104: Establish a hybrid attention mechanism-bidirectional long short-term memory network model. The hybrid attention mechanism includes local attention mechanism and self-attention mechanism. Select the hyperparameter type and set the initial value of each hyperparameter.
[0011] S105: Train the hybrid attention mechanism-bidirectional long short-term memory network model using the training set, and verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model meets the expected results using the validation set. If not, adjust the values of the hyperparameters and return to step S105; if yes, output the trained photovoltaic power generation prediction model.
[0012] S106: Use the test set to test and evaluate the trained photovoltaic power generation prediction model.
[0013] In one possible embodiment, the important feature data is an n×m feature dataset X = [x1, x2, ..., xm]. n ] T The feature vector x of the i-th sample i =[x i1 ,x i2 ,…,x im ];
[0014] The calculation formulas for data standardization include:
[0015]
[0016]
[0017] The formulas for calculating the covariance matrix include:
[0018]
[0019] The formulas for calculating eigenvalue decomposition include:
[0020] Σv=λv→(Σ-λE)v=0;
[0021] |Σ-λE|=0;
[0022] V = [v1, v2, ..., v m ];
[0023] The formula for calculating the principal component feature matrix includes: A = V;
[0024] T = ZA;
[0025] The formulas for calculating the variance contribution rate and the cumulative variance contribution rate include:
[0026]
[0027] In the formula, n represents the number of samples; m represents the number of features; i represents the sample index; j represents the feature index; x ij This represents the j-th feature of the i-th sample; s represents the mean of the j-th feature; :j Z represents the variance of the j-th feature; Z represents the standardized data matrix; Z T The matrix Z represents the transpose of the standardized data matrix Z; ∑ represents the covariance matrix; x :i x represents the i-th feature; :j Represents the j-th feature; r ij Represents the standardized feature x :i and x :j Correlation coefficient; x ki x represents the i-th feature of the k-th sample; kj This represents the j-th feature of the k-th sample; s represents the mean of the i-th feature; :i λ represents the variance of the i-th feature; E represents the identity matrix; λ represents the eigenvalue; v represents the eigenvector; V represents the eigenvector matrix; A represents the principal component loading matrix; T represents the principal component eigenma matrix; λ k λ represents the eigenvalue of the k-th principal component; j η represents the eigenvalue of the j-th principal component; k Indicates the variance contribution rate; γ k This represents the sum of the variance contribution rates of the features of the first k principal components.
[0028] In one possible embodiment, the computational steps of the local attention mechanism include:
[0029] For each output time step t of the sequence, focus on elements within a set local window size (2w+1), and calculate the attention score of the local window using the following formula:
[0030]
[0031] The context representation of the output time step t is obtained by weighted summing the values of the local window using the following formula:
[0032]
[0033] In the operational steps of the local attention mechanism, the trainable parameters p are used through the following formula. t To replace the output time step t:
[0034]
[0035] Introducing a normal distribution term into the attention score formula yields:
[0036]
[0037] In the formula, i represents the input time step; t represents the current output time step; w represents half the size of the local window; [tw, t+w] represents the range of the local window; α t,i q represents the attention weight of input time step i to the current output time step t; t This represents the query vector for the current output time step t; It is the key vector k i transpose, k i Represents the key vector at input time step i; c represents the normalization factor for scaling dot product similarity; t This represents the local dynamic context vector at the current output time step t; v i p represents the feature vector at input time step i; t γ represents the trainable parameters; N represents the scaling factor; σ represents the length of the input sequence; and σ represents the sigmoid activation function. It is a trainable parameter vector v p The transpose of W p x represents a trainable parameter vector; t This represents the input vector at the current output time step t.
[0038] In one possible embodiment, the computational steps of the self-attention mechanism include:
[0039] Based on the query vector q using the following formula t and key vector k i The similarity is used to calculate the attention score using a dot product model:
[0040]
[0041] The attention score is converted into attention weight using the following formula:
[0042]
[0043] The value vector v is adjusted according to the attention weights using the following formula. i Perform a weighted summation to generate a context vector c. t :
[0044]
[0045] Query vector q t Key vector k i and value vector v iThey originate from the same input sequence and satisfy the following formula:
[0046] Q = K = V;
[0047]
[0048] In the formula, i represents the input time step; t represents the current output time step; q t k represents the query vector for the current output time step t; i This represents the key vector at input time step i. It is the key vector k i transpose of s(q) t ,k i ) represents the query vector q t and key vector k i Similarity score; α t,i The input time step i represents the attention weight of the current output time step t; N represents the length of the input sequence; j represents the input time step; v i c represents the value vector of input time step i; t This represents the context vector generated by weighted summation at output time step t; Q represents the query matrix, where each row represents a query vector q. t K represents the key matrix, where each row represents a key vector k. i ;K T It is the transpose of the key matrix K; V represents the value matrix, where each row represents a value vector v. i ; The normalization factor represents the scaling of the dot product similarity; Attention((K,V),Q) is a function call representing the output of the self-attention mechanism.
[0049] In one possible embodiment, the hybrid attention mechanism-bidirectional long short-term memory network model includes memory units, and the computational steps of the memory units include:
[0050] Receive input x with current output time step t t The hidden state h at the previous time step t-1 t-1 ;
[0051] The forgetting gate is calculated using the following formula:
[0052] f t =σ(W if x t +b if +W hf h t-1 +b hf );
[0053] The input gate is calculated using the following formula:
[0054] i t =σ(W ii x t +b ii +W hi h t-1 +b hi );
[0055] The updated cell state is calculated using the following formula:
[0056]
[0057] The output gate is calculated using the following formula:
[0058] o t =σ(W io x t +b io +W ho h t-1 +b ho );
[0059] The hidden state is updated using the following formula:
[0060] h t =o t ☉tanh(C t );
[0061] In the formula, x t h represents the input vector at the current output time step t; t-1 f represents the hidden state at the previous time step t-1; t Indicates the output of the forget gate; W if The weight matrix of the forget gate; b if The bias term representing the forget gate; W hf The weight matrix representing the transition from the hidden state to the forget gate; b hf This represents the bias term from the hidden state to the forget gate; i t The input gate's output is represented by σ; the sigmoid activation function is represented by W. ii b represents the weight matrix of the input gate; ii W represents the bias term of the input gate. hi b represents the weight matrix from the hidden state to the input gate; hi This represents the bias term from the hidden state to the input gate; C t Indicates the current cell state; C t-1 The symbol ⊙ indicates the cell state at the previous moment; ⊙ indicates that elements at the same position are multiplied together. Indicates the state of candidate cells; o t Indicates the output of the output gate; W iob represents the weight matrix of the output gate; io W represents the bias term of the output gate. ho b represents the weight matrix from the hidden state to the output gate; ho The term representing the bias from the hidden state to the output gate; h t This represents the hidden state that is the output at the current time step t, and also the input at the next time step t+1.
[0062] In one possible embodiment, historical photovoltaic power generation data includes global horizontal irradiance, direct normal irradiance, diffuse horizontal irradiance, relative humidity, wind speed, tilted irradiance, module temperature, and DC-side power.
[0063] Secondly, this invention also provides a photovoltaic power generation prediction method, including:
[0064] Acquire analytical data from photovoltaic power plants, including meteorological and power data.
[0065] The analysis data is input into the trained photovoltaic power generation prediction model to obtain the predicted power generation data of the photovoltaic power station output by the trained photovoltaic power generation prediction model. The trained photovoltaic power generation prediction model is a model trained based on the model training method described above.
[0066] Thirdly, this invention also provides a photovoltaic power generation prediction model training device, which includes modules / units for executing any of the possible design methods described in the first aspect. These modules / units can be implemented in hardware or by hardware executing corresponding software.
[0067] Fourthly, embodiments of the present invention also provide an electronic device, including a processor and a memory. The memory stores one or more computer programs; when the one or more computer programs stored in the memory are executed by the processor, the electronic device is able to implement any of the possible design methods described in the first aspect.
[0068] Fifthly, the present invention also provides a computer-readable storage medium comprising a computer program that, when run on an electronic device, causes the electronic device to perform any of the possible designs of the first aspect described above.
[0069] Sixthly, embodiments of the present invention also provide a method comprising a computer program product, which, when run on an electronic device, causes the electronic device to perform any possible design of any of the above aspects.
[0070] The beneficial effects of this invention are as follows: It proposes a photovoltaic power generation prediction method based on a hybrid attention mechanism-bidirectional long short-term memory network model. Principal component analysis is used to reduce the dimensionality of the feature dataset and extract the first principal component as a new feature, thus preserving the key changing trends in the data. A bidirectional long short-term memory network is used to capture both past and future information. A hybrid attention mechanism of local attention and self-attention is introduced. Local attention is used to capture the short-term dependencies of the sequence, and then self-attention is used to capture the global scope relationships, thereby achieving a comprehensive improvement in model performance. This effectively improves prediction accuracy and meets the actual prediction requirements. Attached Figure Description
[0071] Figure 1 This is a flowchart illustrating the photovoltaic power generation prediction model training method of the present invention.
[0072] Figure 2 This is a flowchart of the local attention mechanism in the photovoltaic power generation prediction model training method of the present invention.
[0073] Figure 3 This is a flowchart illustrating the calculation of the self-attention mechanism in the photovoltaic power generation prediction model training method of the present invention.
[0074] Figure 4 This is a structural diagram of the SLA-BiLSTM network in the photovoltaic power generation prediction model training method of the present invention.
[0075] Figure 5 This is a flowchart illustrating a specific example of the photovoltaic power generation prediction model training method of the present invention.
[0076] Figure 6 This is a schematic diagram of the photovoltaic power generation prediction device of the present invention.
[0077] Figure 7 This is a schematic diagram of the structure of the electronic device of the present invention. Detailed Implementation
[0078] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0079] To address the problems existing in the above-mentioned technologies, embodiments of the present invention provide a method for training a photovoltaic power generation prediction model, see [link to relevant documentation]. Figure 1 The model training method includes:
[0080] S101: Obtain historical photovoltaic power generation data from the photovoltaic power plant. The historical photovoltaic power generation data includes meteorological data and photovoltaic power generation data. Extract feature data from the historical photovoltaic power generation data, calculate the feature importance score of the feature data using the split statistics principle in the CatBoost algorithm, and determine important feature data based on the feature importance score.
[0081] S102: Principal Component Analysis (PCA) is used to standardize the important feature data to obtain standardized data. The covariance matrix of the standardized data is calculated, and the covariance matrix is decomposed into eigenvalues to obtain eigenvalues and corresponding eigenvectors. The principal component loading matrix is constructed based on the eigenvectors. The principal component feature matrix is obtained based on the principal component loading matrix and the standardized data matrix. The variance contribution rate of each principal component feature is calculated, and the principal component feature with the largest variance contribution rate is added to the important feature data to obtain the updated feature data.
[0082] S103: Divide the updated feature data into training set, validation set and test set according to a preset ratio;
[0083] S104: Establish a hybrid attention mechanism-bidirectional long short-term memory network model. The hybrid attention mechanism includes local attention mechanism and self-attention mechanism. Select the hyperparameter type and set the initial value of each hyperparameter.
[0084] S105: Train the hybrid attention mechanism-bidirectional long short-term memory network model using the training set, and verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model meets the expected results using the validation set. If not, adjust the values of the hyperparameters and return to step S105; if yes, output the trained photovoltaic power generation prediction model.
[0085] S106: Use the test set to test and evaluate the trained photovoltaic power generation prediction model.
[0086] This invention optimizes feature extraction and time-dependent modeling by combining PCA dimensionality reduction, bidirectional long short-term memory networks, local attention mechanisms, and self-attention mechanisms, thereby improving prediction accuracy. The specific analysis is as follows:
[0087] Historical photovoltaic (PV) power generation data from photovoltaic power plants, including meteorological and PV power output data, is acquired, and feature data is extracted from these data. Then, using the splitting statistics principle of the CatBoost algorithm, the number of splits for each feature in the decision tree and the gain resulting from each split are calculated to obtain a feature importance score. Based on these score, samples that significantly impact power prediction are selected, reducing redundant information.
[0088] Data standardization eliminates differences in dimensions and orders of magnitude between different features, enabling comparison and analysis on the same scale and improving data quality and comparability. This facilitates subsequent covariance matrix calculation and eigenvalue decomposition, avoiding computational biases caused by different data scales. By selecting the principal components with the largest variance contribution rates, the main trends in the data are extracted, retaining the most important information and removing redundant information, which helps reduce the risk of overfitting and improves the model's generalization ability. After removing redundant information, the dataset is more concise, and model training is more efficient. Selecting the principal component features with the largest variance contribution rates and adding them to the important feature data results in updated feature data, ensuring that the updated feature data contains the most important information from the original data to better capture the main trends in the data, thereby improving model stability and prediction accuracy. Principal component analysis transforms the original high-dimensional feature dataset into a low-dimensional principal component matrix, reducing data dimensionality and computational load, and improving computational efficiency. This not only increases model training speed but also reduces computational resource consumption, providing a solid foundation for subsequent model training and prediction.
[0089] A hybrid attention mechanism—a bidirectional long short-term memory (LSTM) network model—is established. This hybrid attention mechanism, encompassing both local and self-attention, better captures key information and time-series dependencies in the data. Simultaneously, the bidirectional LSM network considers both past and future information, improving model stability and prediction accuracy. By appropriately selecting hyperparameter types and setting initial values for each hyperparameter, the model training process can be further optimized, avoiding stability issues caused by improper time span settings.
[0090] In one specific embodiment, the historical photovoltaic power generation data includes global horizontal irradiance, direct normal irradiance, diffuse horizontal irradiance, relative humidity, wind speed, tilted irradiance, module temperature, and DC-side power.
[0091] In one embodiment, the important feature data is an n×m feature dataset X = [x1, x2, ..., xm]. n ] T The feature vector x of the i-th sample i =[x i1 ,x i2 ,…,x im The formula for data standardization includes: calculating the mean of the j-th feature. Calculate the variance of the j-th feature. Standardization calculation of the j-th feature of the i-th sample The formulas for calculating the covariance matrix include: Since the mean of each standardized feature is 0 and the variance is 1, we can conclude that: The covariance matrix ∑ is a symmetric matrix, so it can be decomposed into eigenvalues. Let λ be an eigenvalue of the covariance matrix and v be the corresponding eigenvector. The formula for calculating the eigenvalues is: Σv=λv→(Σ-λE)v=0; the eigenvalue λ is obtained by solving the characteristic equation: |Σ-λE|=0; the eigenvalues obtained from largest to smallest are λ1, λ2, ..., λ m The corresponding feature vectors are v1, v2, ..., v m Let the eigenvector matrix V = [v1, v2, ..., v] be... m The formulas for calculating the principal component characteristic matrix include: when the principal component loading matrix A = V, the principal component characteristic matrix T = ZA can be constructed. The formulas for calculating the variance contribution rate and the cumulative variance contribution rate include: In the above calculation formula, n represents the number of samples; m represents the number of features; i represents the sample index; j represents the feature index; x ij This represents the j-th feature of the i-th sample; s represents the mean of the j-th feature; :j Z represents the variance of the j-th feature; Z represents the standardized data matrix; Z T The matrix Z represents the transpose of the standardized data matrix Z; ∑ represents the covariance matrix; x :i x represents the i-th feature; :j Represents the j-th feature; r ij Represents the standardized feature x :i and x :j Correlation coefficient; x ki x represents the i-th feature of the k-th sample; kj This represents the j-th feature of the k-th sample; s represents the mean of the i-th feature; :i λ represents the variance of the i-th feature; E represents the identity matrix; λ represents the eigenvalue; v represents the eigenvector; V represents the eigenvector matrix; A represents the principal component loading matrix; T represents the principal component eigenma matrix; λ k λ represents the eigenvalue of the k-th principal component; j η represents the eigenvalue of the j-th principal component; k γ represents the variance contribution rate, that is, the proportion of the k-th principal component feature T:,k in the total variance; k This represents the sum of the variance contribution rates of the features of the first k principal components.
[0092] In this embodiment, the principal component feature with the largest variance contribution rate, namely 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 explanatory power for the overall variance of the data, it is used as the (m+1)th feature of the important feature dataset.
[0093] PCA achieves the following through standardization, covariance matrix decomposition, and principal component selection: 1. Eliminating redundancy: removing features with low variance or high correlation; 2. Capturing key trends: the first principal component retains the most significant change patterns in the data; 3. Improving model efficiency: dimensionality reduction reduces computational complexity while mitigating overfitting.
[0094] In one embodiment, see Figure 2 The computational steps of the local attention mechanism include: focusing on elements within a set local window size (2w+1) for each output time step t of the sequence, and calculating the attention score of the local window using the following formula: The context representation of the output time step t is obtained by weighted summing the values of the local window using the following formula: In the operational steps of the local attention mechanism, the trainable parameters p are used through the following formula. t To replace the output time step t: Because p t It might be a floating-point number; the attention score formula can be obtained by introducing a normal distribution term: In the above calculation formula, i represents the input time step; t represents the current output time step; w represents half the size of the local window; [tw, t+w] represents the range of the local window; α t,i q represents the attention weight of input time step i to the current output time step t; t This represents the query vector for the current output time step t; It is the key vector k i transpose, k i Represents the key vector at input time step i; c represents the normalization factor for scaling dot product similarity; t This represents the local dynamic context vector at the current output time step t; v i p represents the feature vector at input time step i; t γ represents the trainable parameters; N represents the scaling factor; σ represents the length of the input sequence; and σ represents the sigmoid activation function. It is a trainable parameter vector v p The transpose of W p x represents a trainable parameter vector; t This represents the input vector at the current output time step t.
[0095] The core idea of local attention is to focus only on elements within a nearby window at each output time step t of the sequence, rather than the entire sequence. This design captures short-term dependencies while significantly reducing computational complexity.
[0096] The core of the attention mechanism is to calculate the similarity between the query vector, key vector, and value vector. The value is used to calculate aggregate information. The weight of each value is determined by calculating the similarity between the query and the address key of the element in memory. Then, the value values are weighted and summed to obtain the attention value.
[0097] In one embodiment, see Figure 3 The computational steps of the self-attention mechanism include: using the query vector q according to the following formula... t and key vector k i The similarity is used to calculate the attention score using a dot product model: The attention score is converted into attention weight using the following formula: On the one hand, normalization can be performed to obtain a probability distribution where the sum of all weight coefficients is 1. On the other hand, the characteristics of the softmax function can be used to highlight the weights of important elements. The value vector v is then weighted according to the attention weights using the following formula. i Perform a weighted summation to generate a context vector c. t : Query vector q t Key vector k i and value vector v i Since they originate from the same input sequence, i.e., Q = K = V, it helps different samples in the input sequence to interact with each other and is better able to capture global dependencies. The formula is: In the above calculation formula, i represents the input time step; t represents the current output time step; q t k represents the query vector for the current output time step t; i This represents the key vector at input time step i. It is the key vector k i transpose of s(q) t ,k i ) represents the query vector q t and key vector k i Similarity score; α t,i This represents the attention weight of input time step i to the current output time step t, i.e., the importance of input time step i to the current output time step t; N represents the length of the input sequence; j represents the input time step; v i c represents the value vector of input time step i; tThis represents the context vector generated by weighted summation at output time step t; Q represents the query matrix, where each row represents a query vector q. t K represents the key matrix, where each row represents a key vector k. i ;K T It is the transpose of the key matrix K; V represents the value matrix, where each row represents a value vector v. i ; The normalization factor representing the scaling of dot product similarity is used to alleviate the gradient vanishing problem; Attention((K,V),Q) is a function call representing the output of the self-attention mechanism.
[0098] In one embodiment, see Figure 4 The hybrid attention mechanism-bidirectional long short-term memory network model includes memory units. The operation steps of a memory unit include: initialization: receiving the input x at the current output time step t. t The hidden state h at the previous time step t-1 t-1 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: f t =σ(W if x t +b if +W hf h t-1 +b hf 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 (which determines the extent of the update) and a tanh function (which generates new candidate values). The input gate is calculated using the following formula: i t =σ(W ii x t +b ii +W hi h t-1 +b hi Cell state update: The cell state is updated by combining the outputs of the forget gate and the input gate. Specifically, the updated cell state is calculated using the following formula: Output gate calculation: The output gate determines how much information from the hidden state at time step t 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: o t =σ(W io x t +b io +W ho h t-1 +b hoHidden state update: The hidden state is calculated by applying a function of the cell state to the output of the output gate, and the hidden state is updated using the following formula: h t =o t ⊙tanh(C t ), h t The hidden state h is the output at the current time step t, and also the input at the next time step t+1. t-1 In the above calculation formula, x t h represents the input vector at the current output time step t; t-1 f represents the hidden state at the previous time step t-1; t Indicates the output of the forget gate; W if The weight matrix of the forget gate; b if The bias term representing the forget gate; W hf The weight matrix representing the transition from the hidden state to the forget gate; b hf This represents the bias term from the hidden state to the forget gate; i t The input gate's output is represented by σ; the sigmoid activation function is represented by W. ii b represents the weight matrix of the input gate; ii W represents the bias term of the input gate. hi b represents the weight matrix from the hidden state to the input gate; hi This represents the bias term from the hidden state to the input gate; C t Indicates the current cell state; C t-1 The symbol ⊙ indicates the cell state at the previous moment; ⊙ indicates that elements at the same position are multiplied together. Indicates the state of candidate cells; o t Indicates the output of the output gate; W io b represents the weight matrix of the output gate; io W represents the bias term of the output gate. ho b represents the weight matrix from the hidden state to the output gate; ho The term representing the bias from the hidden state to the output gate; h t This represents the hidden state that is the output at the current time step t, and also the input at the next time step t+1.
[0099] This invention also provides a method for predicting photovoltaic power generation, comprising:
[0100] Acquire analytical data from photovoltaic power plants, including meteorological and power data.
[0101] The analysis data is input into the trained photovoltaic power generation prediction model to obtain the predicted power generation data of the photovoltaic power station output by the trained photovoltaic power generation prediction model. The trained photovoltaic power generation prediction model is a model trained based on the model training method described above.
[0102] The following section explains the process of model training methods for different models using specific examples.
[0103] See Figure 5 The process involves selecting a power station, determining its configuration, acquiring meteorological and power data, and screening the samples. For feature analysis, PCA dimensionality reduction is performed on the features. PCA dimensionality reduction includes feature standardization, calculation of the covariance matrix, and eigenvalue decomposition, yielding the eigenvalues and corresponding eigenvectors of the covariance matrix, the loading matrix, the principal component matrix, and the first principal component (the feature with the largest variance contribution rate) as the (m+1)th feature. After PCA dimensionality reduction, the feature data is normalized and divided into training, validation, and test sets. A model is built, hyperparameter categories are selected, and initial hyperparameter values are set. The model is trained, and its performance on the validation set is observed to determine if it meets expectations. If not, the hyperparameter values are adjusted, and the model is trained again until the expected performance is achieved. Following the aforementioned model training methods, the training of the Long Short-Term Memory (LSTM), Bidirectional Long Short-Term Memory (BiLSTM), Principal Component Analysis-Bidirectional Long Short-Term Memory (PCA-BiLSIM), and Principal Component Analysis-Specific Local Attention-Bidirectional Long Short-Term Memory (PCA-SLA-BiLSTM) models was completed. Then, the performance of each model was tested and evaluated. The testing and evaluation steps included: determining hyperparameter values, testing each model using a test set, and performing evaluation analysis on each model.
[0104] The performance of each model will be compared and analyzed in detail below using specific cases.
[0105] 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 selected dataset was divided into training set, validation set and test set according to a ratio of 9:0.5:0.5. Then, the hyperparameters were adjusted multiple times, and the hyperparameter values were determined based on the validation set results as follows: time step value of 1, number of hidden layers of 3, number of hidden layer units of 128, learning rate of 0.01, number of iterations of 150, loss function of mean squared error (MSE), and Adam gradient descent method as the optimizer.
[0106] Root mean square error (RMSE), mean absolute error (MAE), coefficient of determination (R²), and mean absolute percentage error (MAPE) were selected as evaluation metrics for the models. Four algorithm models—LSTM, BiLSTM, PCA-BiLSTM, and PCA-SLA-BiLSTM—were built and compared. The evaluation metrics for the four models on the prediction test set are shown in the table below.
[0107] RMSE MAE R2 MAPE / % LSTM 65.8934 38.4508 0.9972 7.1764 BiLSTM 64.9092 37.5322 0.9973 6.7445 PCA-BiLSTM 64.9097 37.3038 0.9973 6.3736 PCA-SLA-BiLSTM 63.8871 36.1304 0.9974 6.2637
[0108] Among the four evaluation metrics, the PCA-SLA-BiLSTM model exhibited the best overall performance, with the lowest RMSE (63.8871), MAE (36.1304), and MAPE, and an R² (0.9974) closest to 1, indicating the best fit. Both the BiLSTM and PCA-BiLSTM models outperformed the original LSTM model in all aspects. Although the PCA-BiLSTM model had a slightly higher RMSE than BiLSTM, its MAPE showed a significant decrease of 0.3709%. In conclusion, by incorporating a bidirectional network, principal component analysis, and a self-local attention mechanism, the LSTM model achieved a comprehensive performance improvement.
[0109] This invention provides a short-term photovoltaic (PV) power generation prediction method based on a PCA-SLA-BiLSTM model. This method uses principal component analysis to reduce the dimensionality of the original dataset and extracts the principal component features with the largest variance contribution as new features, preserving key trends in the data. It converts the LSTM network into a bidirectional network to capture both past and future information. A hybrid attention mechanism combining local and self-attention is introduced, achieving a comprehensive improvement in model performance. This addresses the limitations and instability of LSTM prediction results, improving the accuracy of PV power generation prediction for PV power plants. This not only avoids the potential power system paralysis caused by fluctuations when grid-connected PV power generation exceeds 15% of the total power generation, reducing the impact of grid connection and grid adjustment work, but also helps improve the overall efficiency of grid dispatch and PV power plant operation through more precise resource allocation, thereby increasing the economic benefits of the power plant.
[0110] The following comparative analysis of the photovoltaic power generation prediction model training method of the present invention with the traditional model training method will be used to explain the technical effects of the present invention.
[0111] Traditional local attention mechanisms typically employ fixed windows (such as sliding windows) or preset offsets, with the window center position fixed at the current output time step t, resulting in low flexibility. This invention introduces a trainable parameter p. t Dynamically adjust the center position of the window, window center p t Based on the hidden state h of the previous moment t-1 Dynamic generation allows the window position to adapt to data characteristics (such as abrupt changes in irradiance or cloud movement), expanding the scope of interest to capture a broader context, thus achieving adaptive perception. Adjusting the window range through a scaling factor γ and a neural network adapts to dependencies at different time scales, exhibiting time-series adaptability. Therefore, adapting the window to data characteristics through dynamic windows improves flexibility and adaptability.
[0112] Traditional local attention methods typically employ hard truncation (e.g., fixing window boundaries), directly averaging or linearly weighting the positions within the window. This can lead to information loss at the boundaries due to hard truncation. This invention addresses this by applying a floating-point window center p... t A normal probability density function is introduced as the position weight to smoothly weight the positions within the window. The position weight within the window varies with distance p. t Attenuation avoids the boundary effects of hard truncation and enhances the ability to focus on nearby key locations, such as those near p. tHistorical moments are given higher weights, achieving smooth attention allocation. 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 abrupt events (such as cloud cover), thus enhancing noise resistance.
[0113] Traditional local attention and self-attention are often used independently or simply stacked, potentially neglecting multi-scale feature fusion. Traditional self-attention mechanisms directly compute global dependencies, but this is computationally complex and may overlook local details. This invention uses the output of local attention as input to self-attention, forming a local-global hierarchical attention structure. Local attention captures short-term fluctuations, reducing complexity to the window size. Based on the local attention output, self-attention further models the global long-term cycle. Local and global dependencies are complementary, enhancing the model's ability to model complex temporal patterns and achieving multi-scale feature fusion. Local attention limits the computational range of the window size, while self-attention focuses on key global nodes, resulting in lower overall complexity than pure self-attention models. Co-modeling of local fluctuations and global trends improves prediction robustness.
[0114] This invention utilizes a dynamic window center p t With normally distributed weights, on the one hand, attention mechanisms can be correlated with meteorological time-series models, for example: p t The offset direction reflects the temporal propagation characteristics of meteorological events, and the normal distribution standard deviation controls the scope of attention, corresponding to the spatiotemporal diffusion range of meteorological impacts. On the other hand, principal components guide attention, and combined with the principal component features with the largest variance contribution rate extracted by principal component analysis, the self-attention weight can be interpreted as a dynamic response to core meteorological variables, thus improving the reliability of the model.
[0115] Traditional LSTM's forget gate, input gate, and output gate have fixed weight matrices and biases, which cannot be dynamically adjusted based on the input. This invention introduces an environment-aware mechanism, dynamically correcting the gating parameters using the principal component features with the largest variance contribution rate extracted by PCA, thus 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, improving the modeling accuracy of key trends. The gating behavior is dynamically adjusted according to external features; for example, it enhances the forget gate's cleanup effect when irradiance drops sharply, avoiding interference from outdated meteorological information.
[0116] Traditional BiLSTM's forward and backward LSTM operations are independent, combining information only by splicing hidden states, resulting in a lag in interaction. This invention designs a forward-backward forget gate collaborative mechanism. Through cross-gating interaction, the forward forget gate can be dynamically influenced by the backward hidden state. Cross-gating interaction is directly introduced at the gating level, adjusting the information flow in real time and enhancing the response speed and accuracy to time-series events (such as sudden weather changes). This invention employs dynamic bidirectional information fusion, integrating historical and future information in real time at the gating level. This can be interpreted as the strength of the influence of future information on current decisions, improving the responsiveness to time-series events. Associating the gating signal with meteorological events supports model decision analysis. By dynamically fusing the two through cross-gating, the problem of the separation of historical and future information in traditional BiLSTM is solved, making it particularly suitable for scenarios involving a mixture of sudden fluctuations and long-term trends in photovoltaic power prediction.
[0117] In addition, this invention also proposes a photovoltaic power generation prediction model training device, see [link to relevant documentation]. Figure 6 The device includes: a feature processing module 601, used to acquire historical photovoltaic power generation data of a photovoltaic power station, extract feature data from the historical photovoltaic power generation data, calculate the feature importance score of the feature data using the CatBoost algorithm, and determine important feature data based on the feature importance score; and a principal component analysis module 602, used to perform data standardization processing on the important feature data using principal component analysis to obtain standardized data, calculate the covariance matrix of the standardized data, perform eigenvalue decomposition on the covariance matrix to obtain eigenvalues and corresponding eigenvectors, construct a principal component loading matrix based on the eigenvectors, obtain the principal component feature matrix based on the principal component loading 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; The partitioning module 603 is used to divide the updated feature data into training set, validation set, and test set according to a preset ratio; the model building module 604 is used to build a hybrid attention mechanism-bidirectional long short-term memory network model, where the hybrid attention mechanism includes local attention mechanism and self-attention mechanism, select hyperparameter types, and set the initial values of each hyperparameter; the model training optimization module 605 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 meets the expected effect using the validation set. If not, the hyperparameter values are adjusted, and the process returns to the model training optimization module; if yes, the trained photovoltaic power generation prediction model is output; the model testing and evaluation module 606 is used to test and evaluate the trained photovoltaic power generation prediction model using the test set. All relevant content of each step involved in the above method embodiment can be referred to in the functional description of the corresponding functional module, and will not be repeated here.
[0118] In other embodiments of the present invention, an electronic device is disclosed, see [link to relevant documentation]. Figure 7 The electronic device may include: one or more processors 701; a memory 702; a display 703; one or more application programs (not shown); and one or more computer programs 704. These devices may be connected via one or more communication buses 705. The one or more computer programs 704 are stored in the memory 702 and configured to be executed by the one or more processors 701. The one or more computer programs 704 include instructions that can be used to perform actions such as… Figure 1 and Figure 6 And the steps in the corresponding embodiments.
[0119] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be 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 be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0120] In the various embodiments of this invention, the functional units can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0121] If the integrated unit is implemented as 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 embodiments of the present invention, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.
[0122] While embodiments of the present invention have been described in detail above, it will be apparent to those skilled in the art that various modifications and variations can be made to these embodiments. However, it should be understood that such modifications and variations fall within the scope and spirit of the invention as set forth in the claims. Furthermore, the invention described herein may have other embodiments and can be implemented or carried out in various ways. Unless otherwise defined, the technical or scientific terms used herein should be understood in their ordinary sense by one of ordinary skill in the art to which this invention pertains. The terms "comprising" and similar expressions used herein mean that the element or object preceding the word encompasses the element or object listed following the word and its equivalents, but do not exclude other elements or objects.
Claims
1. A method for training a photovoltaic power generation prediction model, characterized in that, The model training method includes: S101: Obtain historical photovoltaic power generation data of the photovoltaic power station, extract feature data from the historical photovoltaic power generation data, calculate the feature importance score of the feature data using the CatBoost algorithm, and determine important feature data based on the feature importance score. The historical photovoltaic power generation data includes global horizontal irradiance, direct normal irradiance, diffuse horizontal irradiance, relative humidity, wind speed, tilted irradiance, module temperature, and DC side power. S102: The important feature data is standardized using principal component analysis to obtain standardized data. The covariance matrix of the standardized data is calculated. The covariance matrix is decomposed into eigenvalues to obtain eigenvalues and corresponding eigenvectors. The principal component loading matrix is constructed based on the eigenvectors. The principal component feature matrix is obtained based on the principal component loading matrix and the standardized data matrix. The variance contribution rate of each principal component feature is calculated. The principal component feature with the largest variance contribution rate is added to the important feature data to obtain updated feature data. S103: Divide 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, wherein 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; S105: Train the hybrid attention mechanism-bidirectional long short-term memory network model using the training set, and verify whether the performance of the hybrid attention mechanism-bidirectional long short-term memory network model has reached the expected effect using the validation set. 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.
2. The model training method according to claim 1, characterized in that, The important feature data is an n×m feature dataset X = [x1, x2, ..., xm]. n ] T The feature vector x of the i-th sample i =[x i1 ,x i2 ,…,x im ]; The calculation formula for data standardization includes: The formula for calculating the covariance matrix includes: The calculation formula for the eigenvalue decomposition includes: Σv=λv→(Σ-λE)v=0; |Σ-λE|=0; V=[v1,v2,…,v m ]; The formula for calculating the principal component feature matrix includes: A = V; T = ZA; The formulas for calculating the variance contribution rate and the cumulative variance contribution rate include: In the formula, n represents the number of samples; m represents the number of features; i represents the sample index; j represents the feature index; x ij This represents the j-th feature of the i-th sample; s represents the mean of the j-th feature; :j Z represents the variance of the j-th feature; Z represents the standardized data matrix; Z T The matrix Z represents the transpose of the standardized data matrix Z; ∑ represents the covariance matrix; x :i x represents the i-th feature; :j Represents the j-th feature; r ij Represents the standardized feature x :i and x :j Correlation coefficient; x ki x represents the i-th feature of the k-th sample; kj This represents the j-th feature of the k-th sample; s represents the mean of the i-th feature; :i λ represents the variance of the i-th feature; E represents the identity matrix; λ represents the eigenvalue; v represents the eigenvector; V represents the eigenvector matrix; A represents the principal component loading matrix; T represents the principal component eigenma matrix; λ k λ represents the eigenvalue of the k-th principal component; j η represents the eigenvalue of the j-th principal component; k Indicates the variance contribution rate; γ k This represents the sum of the variance contribution rates of the features of the first k principal components.
3. The model training method according to claim 1, characterized in that, The computational steps of the local attention mechanism include: For each output time step t of the sequence, focus on elements within a set local window size (2w+1), and calculate the attention score of the local window using the following formula: The context representation of the output time step t is obtained by weighted summing the values of the local window using the following formula: In the operational steps of the local attention mechanism, the trainable parameter p is used through the following formula. t To replace the output time step t: The attention score formula, by incorporating a normal distribution term, yields: In the formula, i represents the input time step; t represents the current output time step; w represents half the size of the local window; [tw, t+w] represents the range of the local window; α t,i q represents the attention weight of input time step i to the current output time step t; t k represents the query vector for the current output time step t; i T It is the key vector k i transpose, k i Represents the key vector at input time step i; c represents the normalization factor for scaling dot product similarity; t This represents the local dynamic context vector at the current output time step t; v i p represents the feature vector at input time step i; t γ represents the trainable parameters; N represents the scaling factor; σ represents the length of the input sequence; and σ represents the sigmoid activation function. It is a trainable parameter vector v p The transpose of W p x represents a trainable parameter vector; t This represents the input vector at the current output time step t.
4. The model training method according to claim 1, characterized in that, The computational steps of the self-attention mechanism include: Based on the query vector q using the following formula t and key vector k i The similarity is used to calculate the attention score using a dot product model: The attention score is converted into attention weight using the following formula: The attention weight is used to adjust the value vector v according to the following formula. i Perform a weighted summation to generate a context vector c. t : Query vector q t Key vector k i and value vector v i They originate from the same input sequence and satisfy the following formula: Q = K = V; In the formula, i represents the input time step; t represents the current output time step; q t k represents the query vector for the current output time step t; i This represents the key vector at input time step i. It is the key vector k i transpose of s(q) t ,k i ) represents the query vector q t and key vector k i Similarity score; α t,i The input time step i represents the attention weight of the current output time step t; N represents the length of the input sequence; k represents the input time step i. j V represents the key vector at the j-th input time step; i c represents the value vector of input time step i; t This represents the context vector generated by weighted summation at output time step t; Q represents the query matrix, where each row represents a query vector q. t K represents the key matrix, where each row represents a key vector k. i ;K T It is the transpose of the key matrix K; V represents the value matrix, where each row represents a value vector v. i ; The normalization factor represents the scaling of the dot product similarity; Attention((K,V),Q) 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 memory units, and the computational steps of the memory units include: Receive input x with current output time step t t The hidden state h at the previous time step t-1 t-1 ; The forgetting gate is calculated using the following formula: f t =σ(W if x t +b if +W hf h t-1 +b hf ); The input gate is calculated using the following formula: i t =σ(W ii x t +b ii +W hi h t-1 +b hi ); The updated cell state is calculated using the following formula: The output gate is calculated using the following formula: o t =σ(W io x t +b io +W ho h t-1 +b ho ); The hidden state is updated using the following formula: h t =o t ⊙tanh(C t ); In the formula, x t h represents the input vector at the current output time step t; t-1 f represents the hidden state at the previous time step t-1; t Indicates the output of the forget gate; W if The weight matrix of the forget gate; b if The bias term representing the forget gate; W hf The weight matrix representing the transition from the hidden state to the forget gate; b hf This represents the bias term from the hidden state to the forget gate; i t The input gate's output is represented by σ; the sigmoid activation function is represented by W. ii b represents the weight matrix of the input gate; ii W represents the bias term of the input gate. hi b represents the weight matrix from the hidden state to the input gate; hi This represents the bias term from the hidden state to the input gate; C t Indicates the current cell state; C t-1 The symbol ⊙ indicates the cell state at the previous moment; ⊙ indicates that elements at the same position are multiplied together. Indicates the state of candidate cells; o t Indicates the output of the output gate; W io b represents the weight matrix of the output gate; io W represents the bias term of the output gate. ho b represents the weight matrix from the hidden state to the output gate; ho The term representing the bias from the hidden state to the output gate; h t This represents the hidden state that is the output at the current time step t, and also the input at the next time step t+1.
6. A method for predicting photovoltaic power generation, characterized in that, include: Acquire analytical data from photovoltaic power plants, including meteorological and power data of the photovoltaic power plants; The analysis data is input into the trained photovoltaic power generation prediction model to obtain the predicted power generation data of the photovoltaic power station output by the trained photovoltaic power generation prediction model. The trained photovoltaic power generation prediction model is a model trained based on the model training method as described in any one of claims 1-5.
7. A photovoltaic power generation prediction model training device, characterized in that, The device includes: The feature processing module is used to acquire historical photovoltaic power generation data of photovoltaic power plants, extract feature data from the historical photovoltaic power generation data, calculate the feature importance score of the feature data using the CatBoost algorithm, and determine important feature data based on the feature importance score. The principal component analysis module is used to perform data standardization on the important feature data using principal component analysis to obtain standardized data, calculate the covariance matrix of the standardized data, perform eigenvalue decomposition on the covariance matrix to obtain eigenvalues and corresponding eigenvectors, construct a principal component loading matrix based on the eigenvectors, obtain a principal component feature matrix based on the principal component loading 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. The data partitioning module 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 is used to build 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, and selects the hyperparameter type and sets the initial value of each hyperparameter; The 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 has achieved the expected results using the validation set. If not, the hyperparameter values are adjusted, and the process returns to the model training optimization module. 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.
8. An electronic device, characterized in that, include: Processor and memory, wherein the memory is used to store computer programs; The processor is configured to execute a computer program stored in the memory to cause the electronic device to perform the method of any one of claims 1 to 5.
9. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Wind power prediction method based on EMD-KPCA-BiLSTM-ATT model
CN118232341A
Vehicle track prediction method and device suitable for different driving styles
CN119149905A