Photovoltaic power generation prediction method and system containing error correction, storage medium and product
By combining the TCN-LSTM model with Savitzky-Golay smoothing and XGBoost model error correction, the problem of error accumulation in photovoltaic power generation prediction under complex environments is solved, achieving high-precision and robust prediction results.
Patent Information
- Application Number
- CN202511409317.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2026-01-23
Smart Images

Figure CN121390397A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of photovoltaic power generation prediction technology, and more specifically, relates to a photovoltaic power generation prediction method, system, storage medium and product with error correction. Background Technology
[0002] As the penetration rate of photovoltaic (PV) power generation in microgrids continues to increase, accurate prediction of its output power is crucial for the safe and stable operation of highway power supply systems. However, PV power generation prediction faces two major challenges: First, PV output is affected by the nonlinear coupling of multiple factors such as weather and temperature, making it difficult to fully characterize its dynamic characteristics with a single time scale or local features; second, noise interference and frequent extreme weather events in weak grid environments lead to significant time correlation and cumulative effects in prediction errors, necessitating the development of an adaptive error correction mechanism.
[0003] Current photovoltaic (PV) power generation forecasting methods are mainly divided into two categories: physical model-based methods and data-driven methods. Physical model-based methods calculate power output by establishing physical characteristic equations for the PV array. These methods have theoretical advantages under ideal conditions but struggle to adapt to the complex and ever-changing environmental factors encountered in actual operation. Data-driven methods, on the other hand, directly learn power mapping relationships from historical data using machine learning algorithms, such as employing LSTM networks for time-series forecasting. While avoiding the complexity of explicit modeling, a single model struggles to simultaneously capture local fluctuations and predict long-term trends, and is sensitive to outlier data, exhibiting significant prediction errors under extreme weather conditions. Summary of the Invention
[0004] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides a photovoltaic power generation prediction method, system, storage medium and product with error correction, the purpose of which is to dynamically correct the prediction error and improve the accuracy and robustness of photovoltaic power generation prediction.
[0005] To achieve the above objectives, according to a first aspect of the present invention, a photovoltaic power generation prediction method with error correction is proposed, comprising the following steps: Model building phase: Training and testing sets were constructed based on environmental data and corresponding photovoltaic power generation. The preliminary prediction model is trained using the training set; The environmental data from the test set is input into the trained preliminary prediction model to obtain the preliminary prediction value of photovoltaic power generation; Based on the deviation between the actual and preliminary predicted values of photovoltaic power generation in the test set, an error sequence is obtained; the Savitzky-Golay smoothing method is used to reduce noise in the error sequence. The XGBoost model is trained based on the initial predicted values and the noise-reduced error sequence. During the training process, the hyperparameters of the XGBoost model are optimized using the Bayesian optimization algorithm. The trained XGBoost model is the error correction model. Model application phase: The environmental data to be predicted is input into the trained preliminary prediction model to obtain the preliminary prediction value of photovoltaic power generation; the preliminary prediction value is input into the error correction model to obtain the error correction value; the preliminary prediction value is corrected by the error correction value to obtain the final prediction value of photovoltaic power generation.
[0006] As a further preferred embodiment, the preliminary prediction model adopts the TCN-LSTM model, wherein the TCN module is used to extract preliminary feature vectors based on environmental data, and the LSTM module is used to obtain preliminary prediction values of photovoltaic power generation based on the preliminary feature vectors.
[0007] As a further preferred approach, training and test sets are constructed based on environmental data and corresponding photovoltaic power generation, including: After acquiring environmental data and corresponding photovoltaic power generation, all data are preprocessed: outliers are identified and removed using the 3σ criterion, and missing data are filled in; then all data are normalized, and finally training and test sets are constructed by sampling using the sliding window method.
[0008] As a further preferred option, missing data is filled in, including: when the length of the missing data is less than 2 hours, linear interpolation is used to fill in the missing data; when the length of the missing data is not less than 2 hours, adaptive data filling is performed using data from the same period on adjacent dates.
[0009] As a further preferred option, when denoising the error sequence using the Savitzky-Golay smoothing method, the window size is set to 5 and the polynomial order is set to 2.
[0010] As a further preferred option, when training the initial prediction model and the XGBoost model, the loss function used is one of the following: MAE, RMSE, or a weighted combination of MAE and RMSE.
[0011] As a further preferred embodiment, the environmental data includes solar irradiance, ambient temperature, and humidity.
[0012] According to a second aspect of the present invention, a photovoltaic power generation prediction system with error correction is provided, including a processor for executing the above-described photovoltaic power generation prediction method with error correction.
[0013] According to a third aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described photovoltaic power generation prediction method with error correction.
[0014] According to a fourth aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the above-described photovoltaic power generation prediction method with error correction.
[0015] In summary, compared with the prior art, the above-described technical solutions conceived by this invention mainly possess the following technical advantages: 1. Based on the preliminary prediction model, this invention introduces an error correction module based on XGBoost. The error sequence is first preprocessed using the Savitzky-Golay smoothing method to reduce noise interference. Then, the ensemble learning characteristics of XGBoost and optimization strategies such as regularization and pruning are used to accurately learn the error evolution law. Combined with Bayesian optimization of hyperparameters to enhance nonlinear fitting ability, it effectively makes up for the prediction bias of the basic model and greatly improves prediction accuracy and robustness.
[0016] 2. This invention integrates TCN and LSTM to construct a preliminary prediction model, achieving complementary advantages. TCN, with its structural characteristics of causal convolution, dilated convolution, and residual connections, can accurately capture local features of photovoltaic power generation data and effectively extract multi-scale spatiotemporal details. LSTM, through its forget gate, input gate, and output gate gating mechanisms and cell states, focuses on capturing long-term temporal dependencies and retaining key historical information. The synergistic effect of these two technologies can simultaneously handle local features and long-term information, providing a more comprehensive understanding of sequence data, overcoming the limitations of single-cell neural network structures, fully exploring complex patterns in the data, and significantly improving the accuracy of photovoltaic power generation prediction.
[0017] 3. The TCN-LSTM-XGBoost model constructed in this invention integrates the advantages of TCN's parallel computing and flexible adjustment of the receptive field, LSTM's handling of long sequence dependencies, and XGBoost's efficient error correction, forming a multi-model collaborative mechanism with complementary advantages. This can better cope with the impact of complex scenarios and significantly improve the model's generalization ability. Attached Figure Description
[0018] Figure 1 This is a flowchart of a photovoltaic power generation prediction method with error correction according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the TCN-LSTM model according to an embodiment of the present invention; Figure 3 This is a graph showing the prediction results of the TCN-LSTM model in an embodiment of the present invention; Figure 4This is a comparison chart showing the prediction effects before and after the error correction model in this embodiment of the invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0020] This invention provides a photovoltaic power generation prediction method with error correction, such as... Figure 1 As shown, it includes the following steps: S1. Dataset Construction: Environmental data (including solar irradiance, ambient temperature, and humidity) and corresponding photovoltaic power generation were collected over a continuous period. Data preprocessing was performed: invalid data was removed, followed by data cleaning, missing value imputation, and normalization to construct time-series samples suitable for supervised learning. Finally, the processed dataset was divided into training, validation, and test sets.
[0021] Specifically, the 3σ criterion is used to identify and remove outliers. For missing data, different strategies are employed to fill in the missing data based on its duration: short-term missing data (less than 2 hours) is filled using linear interpolation, while long-term missing data (not less than 2 hours) is filled using adaptive methods by combining data from adjacent dates. Subsequently, all feature data are subjected to Min-Max normalization, scaling them to the [0,1] interval to eliminate dimensional differences between different features. A sliding window method is used to construct the sample set, thus forming supervised learning samples corresponding to the input features and the target output. Finally, the sample set is divided into training, validation, and test sets in an 8:1:1 ratio.
[0022] S2. Preliminary prediction model construction: The preliminary prediction model is trained using a training set. This preliminary prediction model can employ various neural network models capable of predicting power generation, with the TCN-LSTM model being preferred. Figure 2As shown, the TCN module extracts multi-scale spatiotemporal features from the preprocessed environmental data to generate a preliminary feature vector. The LSTM module then models long-term temporal dependencies based on this preliminary feature vector, outputting a preliminary prediction value. Specifically, the data is input into the TCN module, where causal convolution ensures temporal causality, dilated convolution captures multi-scale local features, and residual connections alleviate gradient problems, extracting a sequence that integrates multi-scale local features. This sequence is then input into the LSTM module, where the forget gate, input gate, and output gate work together to filter key information and retain long-term information using cell states. Finally, the sequence is mapped to a preliminary prediction value of photovoltaic power generation through a fully connected layer.
[0023] Specifically, the TCN module includes causal convolution, dilated convolution, and residual connections. Causal convolution considers only current and past time steps, ensuring that the model's predictions rely solely on historical information, preserving the causality of time-series data, and avoiding the leakage of future information. Dilated convolution expands the receptive field of the convolution kernel by inserting holes between kernel elements, while maintaining the total number of parameters, thus overcoming the limitations of causal convolution in capturing long-term sequence information. The calculation method is shown below. The residual connection structure provides a direct path, allowing gradients to flow directly to earlier layers of the network, thereby mitigating the problems of vanishing or exploding gradients.
[0024]
[0025] In the formula, The kernel size is [size]. For convolution kernel, This is the index of the current convolution kernel. The input sequence for the model, For expansion rate, For the first in the sequence Each element.
[0026] Specifically, the LSTM module includes three key gating units: the forget gate, the input gate, and the output gate, as well as the cell state across time steps. These components work together to transfer and update information. The forget gate is composed of a Sigmoid layer, whose input is the hidden state from the previous time step. and current input The output is a weight vector ranging from 0 to 1. The input gate weights are calculated through a Sigmoid layer. Determine the current input and the hidden state of the previous moment The information needs to be updated to reflect the cell state. Simultaneously, a candidate value vector is generated through a Tanh layer. This represents the new information to be added to the cell state, and both are weighted together to inject new content into the cell state. After the cell state update is complete, the output gate calculates its weights through the Sigmoid layer. Determines cell state Which parts need to be passed to the output? (Cell state) Processed using the Tanh function and compared with the output gate weights. Multiplying element by element yields the final hidden state. .
[0027]
[0028]
[0029]
[0030]
[0031]
[0032] S3. Error sequence acquisition: Environmental data from the test set is input into the trained preliminary prediction model to obtain preliminary predictions of photovoltaic power generation. The difference between the initial predictions and the actual values in the test set is calculated to generate an error sequence. The error sequence is then denoised using the Savitzky-Golay smoothing method, with a preferred window size of 5 and a polynomial order of 2, to reduce high-frequency noise interference while preserving the error trend. This method involves fitting a k-th order polynomial to n=2m+1 data points within the window; the calculation method is shown in the following formula:
[0033] Based on the weighted relationship between the center point and neighborhood points within the sampling window, the estimated value of each center point is calculated. By sliding through the window, the complete fitting result of the original data is obtained. The calculation process is shown in the following formula:
[0034] In the formula: and These are the values before and after smoothing, respectively. The moving weighting coefficients are obtained using the least squares method. It is the sum of all weights.
[0035] S4. Error Correction Model Construction: The XGBoost model is trained based on the initial predicted values and the denoised error sequence. The trained XGBoost model is the error correction model.
[0036] Specifically, using the initial predictions from the preliminary prediction model as input features and the denoised error sequence as the target, the XGBoost model is trained using column sampling. During training, a Bayesian optimization algorithm is used to optimize the hyperparameters of the XGBoost model within a predefined hyperparameter space (including learning rate, maximum tree depth, subsampling ratio, etc.) to achieve efficient learning and accurate prediction of the error sequence. Specifically, the model hyperparameters are optimized once after a certain number of training iterations. Bayesian optimization performs an efficient search within the predefined hyperparameter space to optimize model performance and accelerate convergence, ultimately obtaining a high-precision error correction model to compensate for the deviation of the initial predictions.
[0037] Furthermore, during the training of the initial prediction model and the XGBoost model, the loss function used is MAE, RMSE, or a weighted combination of MAE and RMSE.
[0038] S5, Final Prediction: The environmental data to be predicted is input into a trained preliminary prediction model to obtain a preliminary prediction value for photovoltaic power generation; this preliminary prediction value is then input into an error correction model to obtain an error correction value; finally, the preliminary prediction value is corrected using this error correction value to obtain the final prediction value for photovoltaic power generation. Let... The output of the error correction model is:
[0039] In the formula: , These are the predicted values before and after correction, respectively, which are the final output values of the photovoltaic power prediction.
[0040] This invention captures multi-scale local features through TCN, models long-term dependencies using LSTM, and introduces XGBoost to dynamically learn and correct prediction errors, thereby constructing a prediction framework that takes into account both temporal feature extraction and error self-correction. This can solve the shortcomings of existing prediction methods in feature extraction, temporal modeling, and prediction accuracy, and significantly improve the accuracy and robustness of photovoltaic power generation prediction.
[0041] The following are specific examples: A section of highway in a remote area was selected as the research object to verify the effectiveness of the proposed method. This section of highway is approximately 130km long, encompassing 7 toll stations and 2 service areas, totaling 9 nodes. Each service area is equipped with photovoltaic power generation facilities to provide energy support for passing vehicles and the service area's own operation. Regarding data sources, the photovoltaic power generation data all come from the microgrid cloud platform systems of the two service areas.
[0042] In the TCN-LSTM model, the TCN uses two layers of residual units containing 64 convolutional kernels of size 5, with dilation factors set to 1, 2, and 4. The LSTM has 128 neurons, uses the Adam optimizer, has a batch size of 128, a learning rate of 0.005, and 500 iterations.
[0043] To comprehensively evaluate the model's performance, MAE, RMSE, and other metrics were selected. As an evaluation indicator, among them ∈(0,1) reflects the goodness of fit of the model; the larger the value, the better the fit.
[0044] Figure 3 The prediction results of the TCN-LSTM model are presented. This model excels in capturing the nonlinear characteristics of time series data, achieving high-precision predictions. Overall, the actual and predicted values show a high degree of consistency. Even in areas of significant data fluctuation, the predicted curve still fits the trajectory of the actual values well. This phenomenon not only verifies the model's ability to capture global trend changes but also highlights its accurate representation of local features (such as those near extreme points). Furthermore, although minor errors exist in the model's predictions, they are all within a reasonable range of fluctuation, without significant systematic bias or outliers. By combining the advantages of convolutional neural networks and long short-term memory networks, the TCN-LSTM model effectively captures complex nonlinear relationships in time series data, further validating the model's effectiveness and superiority in processing this type of data.
[0045] Table 1 shows the relevant evaluation metrics of the model. The MAE of the TCN-LSTM model is 9.2031, indicating that the mean absolute error between the predicted and actual values is small. The RMSE is 11.7302, indicating that it can maintain high overall accuracy even in the presence of large errors. The value of 0.8893 indicates that the model can explain most of the variability in the data, fully demonstrating its powerful ability to capture the inherent patterns in the data. These metrics collectively demonstrate the efficiency and reliability of TCN-LSTM in time series forecasting, highlighting its advantages in handling complex nonlinear relationships.
[0046] Table 1 Model Evaluation Indicators
[0047] Figure 4 The comparison of prediction performance before and after the model error correction module is presented. Analysis shows that after introducing the error correction mechanism, the model's prediction curve shows a significant improvement in its fit to the true values, and the prediction bias is further reduced, fully demonstrating the positive effect of the error correction module on optimizing model performance. Table 2 shows the comparison of model evaluation metrics before and after the introduction of the error correction module. Data shows that after error correction, the model's MAE decreased by 0.1443, and RMSE decreased by 0.127. An improvement of 0.0019. This indicates that the introduction of the error correction module can effectively reduce prediction bias and enhance the model's ability to interpret data variability, thereby substantially improving prediction accuracy. Table 2 Comparison of evaluation indicators before and after error correction
[0048] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A photovoltaic power generation prediction method with error correction, characterized in that, include: Model building phase: Training and testing sets were constructed based on environmental data and corresponding photovoltaic power generation. The preliminary prediction model is trained using the training set; The environmental data from the test set is input into the trained preliminary prediction model to obtain the preliminary prediction value of photovoltaic power generation; Based on the deviation between the actual and preliminary predicted values of photovoltaic power generation in the test set, an error sequence is obtained; the Savitzky-Golay smoothing method is used to reduce noise in the error sequence. The XGBoost model is trained based on the initial predicted values and the noise-reduced error sequence. During the training process, the hyperparameters of the XGBoost model are optimized using the Bayesian optimization algorithm. The trained XGBoost model is the error correction model. Model application phase: The environmental data to be predicted is input into the trained preliminary prediction model to obtain the preliminary prediction value of photovoltaic power generation; the preliminary prediction value is then input into the error correction model to obtain the error correction value. The initial prediction value is corrected using this error correction value to obtain the final prediction value of photovoltaic power generation.
2. The photovoltaic power generation prediction method with error correction as described in claim 1, characterized in that, The preliminary prediction model adopts the TCN-LSTM model, in which the TCN module is used to extract preliminary feature vectors based on environmental data, and the LSTM module is used to obtain preliminary prediction values of photovoltaic power generation based on the preliminary feature vectors.
3. The photovoltaic power generation prediction method with error correction as described in claim 1, characterized in that, Training and test sets are constructed based on environmental data and corresponding photovoltaic power generation, including: After acquiring environmental data and corresponding photovoltaic power generation, all data are preprocessed: outliers are identified and removed using the 3σ criterion, and missing data are filled in; then all data are normalized, and finally training and test sets are constructed by sampling using the sliding window method.
4. The photovoltaic power generation prediction method with error correction as described in claim 3, characterized in that, Missing data is filled in using the following methods: when the missing data length is less than 2 hours, linear interpolation is used to fill in the missing data; when the missing data length is not less than 2 hours, adaptive filling is performed using data from the same period on adjacent dates.
5. The photovoltaic power generation prediction method with error correction as described in claim 1, characterized in that, When denoising the error sequence using the Savitzky-Golay smoothing method, the window size is set to 5 and the polynomial order is set to 2.
6. The photovoltaic power generation prediction method with error correction as described in claim 1, characterized in that, When training the initial prediction model and the XGBoost model, the loss function used is one of the following: MAE, RMSE, or a weighted combination of MAE and RMSE.
7. The photovoltaic power generation prediction method with error correction as described in any one of claims 1-6, characterized in that, The environmental data includes solar irradiance, ambient temperature, and humidity.
8. A photovoltaic power generation prediction system with error correction, characterized in that, Includes a processor for executing the photovoltaic power generation prediction method with error correction as described in any one of claims 1-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the photovoltaic power generation prediction method with error correction as described in any one of claims 1-7.
10. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the photovoltaic power generation prediction method with error correction as described in any one of claims 1-7.