An XGBoost-based distributed photovoltaic power generation amount prediction method and system
By combining hourly irradiance and periodic time characteristics with the XGBoost regression model, the problem of high computing power and high cost in photovoltaic power generation prediction in existing technologies is solved, realizing high-precision and low-cost distributed photovoltaic power generation prediction, which is suitable for multi-site deployment and grid dispatch.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG AOFEI NEW ENERGY CO LTD
- Filing Date
- 2025-10-13
- Publication Date
- 2026-07-24
AI Technical Summary
Existing photovoltaic power generation prediction technologies have high computational overhead and training costs, and their robustness depends on preprocessing, making it difficult to achieve efficient and low-cost distributed photovoltaic power generation prediction.
The XGBoost regression model is used to construct training samples by combining hourly irradiance data and periodic time features. The time periodicity is reflected by sine and cosine values, which simplifies the preprocessing steps, reduces hardware resource requirements, and improves the robustness of the model.
It achieves high-precision (over 95%) photovoltaic power generation prediction, reduces training time from hours to seconds, is suitable for multi-site distributed deployment, and supports smart grid dispatch and distributed energy management.
Smart Images

Figure CN121417151B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of photovoltaic power generation technology, and specifically to a method and system for predicting distributed photovoltaic power generation based on XGBoost. Background Technology
[0002] Photovoltaic (PV) power generation, as a core component of renewable energy, plays a crucial role in energy structure transformation. However, PV power generation is significantly volatile and uncertain due to factors such as solar irradiance, weather conditions (e.g., cloud cover, precipitation), and diurnal cycles. For example, a sudden drop in midday irradiance can cause a momentary decline in power generation, while there may be no power output at night. This characteristic not only affects the direct utilization efficiency of PV energy but may also lead to "curtailment" (where power generation fluctuations exceed the grid's capacity, forcing the abandonment of some electricity), while posing challenges to the grid's stable dispatch of new energy sources. Therefore, accurate prediction of distributed PV power generation has become a core technological requirement for improving PV energy utilization, optimizing power dispatch strategies, and ensuring stable grid operation.
[0003] Currently, various photovoltaic power generation prediction technologies exist in the industry. For example, patent document CN114004139B proposes a "photovoltaic power generation prediction method," which uses the KMeans clustering algorithm to process and classify historical data for anomalies, and then constructs a prediction model using an SVM (Support Vector Machine) model. Patent document CN117913808A proposes a "distributed photovoltaic power generation prediction method and device," which also uses KMeans clustering as the core of data preprocessing, and then combines it with LSTM (Long Short-Term Memory) network for modeling and prediction. These solutions achieve preliminary screening of historical data through KMeans clustering and have a certain ability to process anomalies and generalize performance, but they have the following key shortcomings:
[0004] High computational cost and high efficiency: KMeans clustering algorithm requires multiple iterations to calculate the distance between samples, resulting in significant computational overhead when processing large-scale historical data; SVM model has high time and space complexity during training when processing massive amounts of data, and the adjustment of model parameters (such as kernel function and penalty coefficient) depends on experience, making optimization difficult; LSTM model, as a deep neural network, not only requires massive amounts of samples to support training, but also requires complex network structure design (such as the number of layers and hidden units), and the training time often reaches several hours or even longer, with high dependence on hardware resources (such as GPUs) and persistently high prediction costs.
[0005] Robustness depends on preprocessing: The ability of existing solutions to resist interference from outlier data depends entirely on the filtering effect of KMeans clustering. If the clustering parameters are not set properly, outlier samples will still significantly interfere with subsequent model training, leading to a decrease in prediction accuracy. Furthermore, the additional clustering preprocessing steps further increase the complexity and execution time of the overall solution.
[0006] To address the shortcomings of the existing technologies, there is an urgent need for a distributed photovoltaic power generation prediction scheme that requires no complex data preprocessing, has a lightweight model, and offers high prediction accuracy, in order to meet the low-cost and high-efficiency requirements of multi-site distributed deployment. Summary of the Invention
[0007] This application provides a distributed photovoltaic power generation prediction method and system based on XGBoost, aiming to solve the problems of high computing power overhead, high training cost, and robustness dependence on preprocessing in existing prediction schemes, and to achieve lightweight and high-precision distributed photovoltaic power generation prediction.
[0008] To achieve the above objectives, the present invention provides a distributed photovoltaic power generation prediction method based on XGBoost, comprising the following steps:
[0009] Collect historical power generation data of distributed photovoltaic power stations within a predetermined period;
[0010] Obtain hourly solar irradiance data recorded by a meteorological station at the geographical location corresponding to the photovoltaic power station within the predetermined period;
[0011] The timestamps of each data point in the historical power generation data and hourly solar irradiance data are periodically mapped, with the timestamps mapped to the interval [0, 2π] in seconds, and the sine and cosine values of the mapped time values are calculated to obtain the time periodicity characteristics;
[0012] The hourly solar irradiance data is combined with the time periodicity features to construct training samples for the XGBoost regression model;
[0013] The XGBoost regression model is trained using the training samples to obtain the power generation prediction model;
[0014] Obtain the predicted solar irradiance data for the region corresponding to the photovoltaic power station within the target time period, input it into the power generation prediction model, and output the photovoltaic power generation prediction results for the target time period.
[0015] As a further improvement to the technical solution of the present invention, the predetermined period is set to 1 day, 1 week or 1 month according to the forecast requirements, and the collection frequency of the historical power generation data is consistent with the collection frequency of the hourly solar irradiance data, which is 1 data point per hour.
[0016] As a further improvement to the technical solution of the present invention, when periodically mapping the timestamp, the total length of a day, T = 86400 seconds, is used as the benchmark. The sine characteristic of the timestamp t is calculated by the formula sin (2πt / T), and the cosine characteristic of the timestamp t is calculated by the formula cos (2πt / T), where t is the number of seconds corresponding to the timestamp.
[0017] As a further improvement to the technical solution of the present invention, when constructing the training samples of the XGBoost regression model, the input features of each training sample include: the hourly solar irradiance value at the corresponding time point, the sine feature value of the timestamp at that time point, and the cosine feature value of the timestamp at that time point; the label of each training sample is the historical power generation value at the corresponding time point.
[0018] As a further improvement to the technical solution of this invention, when training the XGBoost regression model, the model parameter configuration includes: n_estimators=2000, max_depth=5, learning_rate=0.04, reg_alpha=0.1, reg_lambda=1, subsample=0.9, colsample_bytree=0.9.
[0019] As a further improvement to the technical solution of the present invention, when training the XGBoost regression model using the training samples, the training samples are divided into a training set and a test set in a 7:3 ratio. The training set is used for model training, and the test set is used to verify the model performance.
[0020] As a further improvement to the technical solution of this invention, when training the XGBoost regression model, an early stopping mechanism of early_stopping_rounds=50 is introduced. If the model evaluation index does not show a significant improvement after 50 consecutive iterations on the validation set, the training is terminated. The model evaluation index is the mean absolute error (MAE).
[0021] A second aspect of the present invention provides a distributed photovoltaic power generation prediction system based on XGBoost, wherein the system comprises:
[0022] The data acquisition module is used to collect historical power generation data of the distributed photovoltaic power station within a predetermined period, as well as hourly solar irradiance data recorded by the meteorological station at the geographical location corresponding to the photovoltaic power station within the predetermined period.
[0023] The time processing module is used to periodically map the timestamps of each data point in the historical power generation data and solar irradiance data, mapping the timestamps to the [0, 2π] interval in seconds, and calculating the sine and cosine values of the mapped time values to obtain the time periodicity characteristics.
[0024] The feature construction module is used to combine the hourly solar irradiance data with the time periodic features to construct training samples for the XGBoost regression model.
[0025] The model training module is used to train the XGBoost regression model using the training samples to obtain the power generation prediction model.
[0026] The prediction module is used to obtain the predicted solar irradiance data of the region corresponding to the photovoltaic power station within the target time period, input the power generation prediction model, and output the photovoltaic power generation prediction results for the target time period.
[0027] A third aspect of the present invention provides a computer device including a memory and a processor, the memory storing code, and the processor being configured to acquire the code and execute the above-described XGBoost-based distributed photovoltaic power generation prediction method.
[0028] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described XGBoost-based distributed photovoltaic power generation prediction method.
[0029] Compared with the prior art, this application has the following advantages:
[0030] This application achieves a technological breakthrough in distributed photovoltaic power generation prediction through an innovative combination of "hourly irradiance + periodic time characteristics + XGBoost model," with core advantages including:
[0031] Robust and requiring no preprocessing: XGBoost’s weighted tree ensemble mechanism can automatically reduce the impact of outliers on the model, eliminating the need to rely on clustering algorithms such as KMeans for outlier screening, simplifying the process while improving anti-interference capabilities.
[0032] Lightweight and low-cost model: Compared to deep models such as LSTM, XGBoost has low hardware resource requirements (it can run on a regular CPU), and the training time is reduced from hours to seconds, significantly reducing computing costs and deployment difficulty;
[0033] High accuracy and good generalization: By capturing the daily cycle of power generation through periodic time features and combining XGBoost’s nonlinear learning capability, the prediction accuracy reaches over 95%, and it maintains stable performance in different seasons and weather scenarios.
[0034] Flexible deployment and wide applicability: It supports distributed deployment at multiple sites and can provide forecasting services for multiple photovoltaic power plants at the same time. The output results can be directly connected to the power grid dispatching system or user power management platform, providing key technical support for smart grid construction and distributed energy management. Attached Figure Description
[0035] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0036] Figure 1 is a schematic diagram of the framework of a distributed photovoltaic power generation prediction method based on XGBoost according to an embodiment of the present invention;
[0037] Figure 2 is a schematic diagram of the composition of a distributed photovoltaic power generation prediction system based on XGBoost according to an embodiment of the present invention;
[0038] Figure 3 This is a schematic diagram of the composition of a computing device according to an embodiment of the present invention. Detailed Implementation
[0039] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. The illustrative embodiments and descriptions of the present invention are used to explain the present invention, but are not intended to limit the present invention.
[0040] It should be noted that all directional indicators (such as up, down, left, right, front, back, upper end, lower end, top, bottom, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indicator will also change accordingly.
[0041] In this invention, unless otherwise explicitly specified and limited, the term "connection" should be interpreted broadly. For example, "connection" can be a fixed connection, a detachable connection, or an integral part; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal communication of two components or the interaction between two components, unless otherwise explicitly limited. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0042] Furthermore, in this invention, descriptions involving "first," "second," etc., are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. Additionally, the technical solutions of various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. If the combination of technical solutions is contradictory or impossible to implement, such a combination should be considered non-existent and not within the scope of protection claimed by this invention.
[0043] The present invention will be further described in detail below with reference to the accompanying drawings.
[0044] Reference Figure 1 The first aspect of this invention provides a method for predicting distributed photovoltaic power generation based on XGBoost, comprising the following steps:
[0045] Collect historical power generation data of distributed photovoltaic power stations within a predetermined period;
[0046] Obtain hourly solar irradiance data recorded by a meteorological station at the geographical location corresponding to the photovoltaic power station within the predetermined period;
[0047] The timestamps of each data point in the historical power generation data and hourly solar irradiance data are periodically mapped, with the timestamps mapped to the interval [0, 2π] in seconds, and the sine and cosine values of the mapped time values are calculated to obtain the time periodicity characteristics;
[0048] The hourly solar irradiance data is combined with the time periodicity features to construct training samples for the XGBoost regression model;
[0049] The XGBoost regression model is trained using the training samples to obtain the power generation prediction model;
[0050] Obtain the predicted solar irradiance data for the region corresponding to the photovoltaic power station within the target time period, input it into the power generation prediction model, and output the photovoltaic power generation prediction results for the target time period.
[0051] This invention addresses the problems of high computational cost of KMeans clustering, high training cost of SVM / LSTM, and reliance on outlier preprocessing in existing technologies by combining hourly irradiance data, periodic time features, and the XGBoost model. XGBoost's weighted tree ensemble mechanism naturally reduces the impact of outliers, eliminating the need for additional outlier screening steps. Periodic time features accurately capture the daily cycle of photovoltaic power generation, enhancing the model's ability to learn from changes in power generation over time periods. The overall solution maintains a prediction accuracy of over 95% while significantly shortening training time (completed in seconds) and reducing hardware resource requirements (can run on a standard CPU), making it suitable for multi-site distributed deployment and effectively supporting smart grid dispatching and distributed energy management.
[0052] Specifically, in this embodiment, the predetermined period is set to 1 day, 1 week, or 1 month according to the prediction requirements, and the collection frequency of the historical power generation data is consistent with the collection frequency of the hourly solar irradiance data, both being 1 data point per hour. This invention, by flexibly setting the predetermined period, can adapt to prediction requirements in different scenarios, such as short-term (e.g., the next day) and medium-to-long-term (e.g., the next month), improving the applicability of the solution; at the same time, it ensures that the collection frequency of historical power generation and irradiance data is consistent, avoiding feature correlation bias caused by data granularity mismatch, ensuring the effectiveness of training samples, and further improving the model prediction accuracy.
[0053] Specifically, in this embodiment, when performing periodic mapping on timestamps, the total length of a day, T = 86400 seconds, is used as a benchmark. The sine feature of timestamp t is calculated using the formula sin(2πt / T), and the cosine feature is calculated using the formula cos(2πt / T), where t is the number of seconds corresponding to the timestamp. This invention, through explicit periodic mapping formulas, can transform discrete timestamps into continuous sine and cosine features, accurately quantifying the daily periodic pattern of photovoltaic power generation. Compared to directly using timestamps (which cannot reflect periodicity), this allows the XGBoost model to learn the correlation between time and power generation more efficiently, reducing the learning cost of meaningless time information and improving feature utilization efficiency and prediction accuracy.
[0054] Specifically, in this embodiment, when constructing training samples for the XGBoost regression model, the input features of each training sample include: the hourly solar irradiance value at the corresponding time point, the sine feature value of the timestamp at that time point, and the cosine feature value of the timestamp at that time point; the label of each training sample is the historical power generation value at the corresponding time point. This invention, by standardizing the input and output structure of training samples, ensures that the XGBoost model clearly learns the mapping relationship between "irradiance - time feature - power generation," avoiding model training bias caused by chaotic feature dimensions; simultaneously, it focuses on core influencing factors (irradiance, time period), eliminates redundant features, reduces the amount of data and computation required for model training, improves training efficiency, and ensures the consistency of feature inputs during model prediction, enhancing the reliability of prediction results.
[0055] Specifically, in this embodiment, the XGBoost regression model is trained using the following parameter configurations: n_estimators=2000, max_depth=5, learning_rate=0.04, reg_alpha=0.1, reg_lambda=1, subsample=0.9, and colsample_bytree=0.9. It should be noted that this parameter configuration has been experimentally verified to balance the XGBoost model's fitting ability and generalization performance: n_estimators=2000 ensures the model can fully learn nonlinear relationships; max_depth=5 avoids overfitting caused by excessively deep tree structures; learning_rate=0.04 ensures model convergence stability; reg_alpha and reg_lambda reduce the impact of redundant features and suppress parameter extreme values through regularization; and subsample and colsample_bytree reduce the model's dependence on the training set through sample / feature perturbation. This overall parameter combination allows the model to stably output high-precision prediction results even on small-scale datasets, while avoiding overfitting and improving the model's adaptability to different weather and seasonal scenarios.
[0056] Specifically, in this embodiment, when training the XGBoost regression model using the training samples, the training samples are divided into a training set and a test set in a 7:3 ratio. The training set is used for model training, and the test set is used to verify model performance. It should be noted that the 7:3 sample division ratio ensures sufficient training data (to support model learning) while retaining enough test data (to verify generalization ability), avoiding overfitting due to an excessively high proportion of training data or insufficient training due to an excessively high proportion of test data. Real-time verification of model performance using the test set allows for timely detection of deviations during model training (such as overfitting trends), ensuring that the final power generation prediction model maintains high accuracy even on unseen data, thus enhancing the model's practical application value.
[0057] Specifically, in this embodiment, when training the XGBoost regression model, an early stopping mechanism of early_stopping_rounds=50 is introduced. If the model evaluation metric does not show significant improvement after 50 consecutive iterations on the validation set, training is terminated. The model evaluation metric is the mean absolute error (MAE). It should be noted that the early stopping mechanism of early_stopping_rounds=50 avoids invalid iterations after the model's performance on the validation set no longer improves, significantly reducing the waste of computational resources (e.g., preventing a model that originally required 2000 iterations from continuing to run after 1200 iterations when it has converged), and reducing training time costs. Using MAE as the evaluation metric can intuitively reflect the average absolute deviation between the predicted value and the true value. Compared with other metrics (such as mean squared error), it better reflects the prediction accuracy requirements in practical applications, ensuring that the model training direction is consistent with the actual usage requirements.
[0058] Reference Figure 2 A second aspect of the present invention provides a distributed photovoltaic power generation prediction system based on XGBoost, wherein the system comprises:
[0059] The data acquisition module is used to collect historical power generation data of the distributed photovoltaic power station within a predetermined period, as well as hourly solar irradiance data recorded by the meteorological station at the geographical location corresponding to the photovoltaic power station within the predetermined period.
[0060] The time processing module is used to periodically map the timestamps of each data point in the historical power generation data and solar irradiance data, mapping the timestamps to the [0, 2π] interval in seconds, and calculating the sine and cosine values of the mapped time values to obtain the time periodicity characteristics.
[0061] The feature construction module is used to combine the hourly solar irradiance data with the time periodic features to construct training samples for the XGBoost regression model.
[0062] The model training module is used to train the XGBoost regression model using the training samples to obtain the power generation prediction model.
[0063] The prediction module is used to obtain the predicted solar irradiance data of the region corresponding to the photovoltaic power station within the target time period, input the power generation prediction model, and output the photovoltaic power generation prediction results for the target time period.
[0064] This invention employs a modular design, breaking down the prediction process into five main units: data acquisition, time processing, feature construction, model training, and prediction. Each module functions independently yet collaboratively, facilitating system deployment, maintenance, and iteration (e.g., the interface compatibility of the data acquisition module can be optimized separately later). Simultaneously, the model training module integrates optimized parameters and an early stopping mechanism, ensuring the system can automatically output high-precision, low-cost prediction results. The entire system requires no manual intervention in data preprocessing and model training, achieving full automation and improving the efficiency and convenience of distributed photovoltaic power station power generation prediction, adapting to multi-site batch prediction scenarios.
[0065] Reference Figure 3 A third aspect of this invention provides a computer device including a memory and a processor. The memory stores code, and the processor is configured to acquire the code and execute the aforementioned XGBoost-based distributed photovoltaic power generation prediction method. It should be noted that this computer device does not rely on a high-performance GPU (a regular CPU is sufficient), significantly reducing hardware procurement and operating costs. When the processor executes the prediction method, it can efficiently complete the entire process of data processing, model training, and prediction, and supports multi-threaded processing (it can simultaneously provide prediction services for multiple distributed photovoltaic power stations), improving the device's resource utilization and application scenario coverage, and meeting the needs of power grid dispatching or energy management platforms for concurrent prediction of multiple sites.
[0066] A fourth aspect of this invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned XGBoost-based distributed photovoltaic power generation prediction method. It should be noted that the computer-readable storage medium can flexibly store the computer program corresponding to the prediction method, supporting migration and deployment between different computer devices (e.g., copying from a cloud server to a local terminal in a photovoltaic power station), making it particularly suitable for on-site prediction scenarios in environments without or with weak networks. Simultaneously, the portability and stability of the storage medium ensure that the prediction method can be stored long-term and accessed at any time, improving the deployment flexibility and application scope of the solution.
[0067] Example:
[0068] Reference Figure 1Firstly, this application provides a distributed photovoltaic power generation prediction method based on XGBoost. This method combines hourly solar irradiance data with periodic time characteristics, and utilizes the inherent robustness and efficiency of the XGBoost regression model to achieve accurate power generation prediction. Specifically, it includes the following steps:
[0069] Step 1: Collect historical power generation and hourly solar irradiance data
[0070] Collect historical power generation data of distributed photovoltaic power stations within a predetermined period. The predetermined period can be flexibly set according to actual forecasting needs. For example, for short-term forecasts (such as forecasts for the next day), one month of historical data can be selected, and for medium- and long-term forecasts (such as forecasts for the next month), three to six months of historical data can be selected. The collection frequency of historical power generation data is uniformly set to "one data point per hour" to ensure that the data granularity matches the subsequent irradiance data.
[0071] Simultaneously, solar irradiance data recorded by a meteorological station at the corresponding geographical location of the photovoltaic power station within the aforementioned predetermined period is obtained. It is necessary to ensure that the geographical distance between the meteorological station and the photovoltaic power station does not exceed 1 kilometer (to avoid irradiance data deviation caused by geographical differences), and the irradiance data is also "1 data point per hour", with the data unit being "watts per square meter (W / ㎡)", covering different weather scenarios such as sunny days, cloudy days, and partly cloudy days, to ensure the diversity and representativeness of the data.
[0072] Step 2: Periodicity feature conversion of timestamps
[0073] Because photovoltaic power generation exhibits significant diurnal cyclical characteristics (e.g., highest power generation at noon, no power generation in the early morning), directly using timestamps (e.g., "2023-10-01 12:00:00") as model input cannot reflect this cyclical pattern. Therefore, it is necessary to perform a periodic feature transformation on the timestamp of each data point:
[0074] Convert the timestamp to a numerical value t in seconds (e.g., "12:00:00" corresponds to t = 12 × 3600 = 43200 seconds, "01:00:00" corresponds to t = 3600 seconds).
[0075] Based on the total length of a day, T = 86400 seconds (24 × 3600), t is mapped to the interval [0, 2π]. The mapping formula is: mapping value = 2π × t / T;
[0076] The sine and cosine values of the mapped value, namely sin(2πt / T) and cos(2πt / T), are calculated and used as time periodic features. For example, when t=3600 seconds, the mapped value = 2π×3600 / 86400=π / 12, the sine value ≈0.2588, and the cosine value ≈0.9659; when t=43200 seconds, the mapped value = π, the sine value = 0, and the cosine value = -1. This conversion can effectively quantify the periodicity of time and help the model capture the trend of power generation changes in different time periods.
[0077] Step 3: Construct XGBoost model training samples
[0078] The "hourly solar irradiance data" obtained in step 1 and the "time periodicity features (sine and cosine values)" obtained in step 2 are used as the model input features, and the "historical power generation data" collected in step 1 is used as the model output label to construct a training sample set. The structure of each training sample is: [solar irradiance value, time sine feature value, time cosine feature value] → historical power generation value.
[0079] For example, if a sample corresponds to the time "2024-10-01 12:00:00" and the irradiance value is 1000 W / m², then the input feature is [1000, 0, -1]. If the historical power generation at this time point is 500 kWh, then the sample label is 500, and the complete sample is [1000, 0, -1] → 500.
[0080] Step 4: Train the XGBoost regression model
[0081] The XGBoost regression model is trained using the training sample set constructed in step 3. To balance the model's fitting ability and generalization performance, the following core parameters are set (the parameter configuration has been verified through multiple experiments and can effectively avoid overfitting and ensure training efficiency):
[0082] n_estimators=2000: Sets the maximum number of trees to 2000 to ensure that the model can fully learn the non-linear relationship between input features and power generation;
[0083] max_depth=5: Limits the maximum depth of a single tree to 5 layers to avoid overfitting caused by excessively deep tree structures (if the depth exceeds 5, the model is prone to memorizing training set noise).
[0084] learning_rate=0.04: Set a small learning rate to gradually improve the model's convergence stability and avoid model oscillations caused by an excessively large learning rate;
[0085] reg_alpha=0.1: Introduces L1 regularization, which penalizes the model parameters, reduces the impact of redundant features, and improves the sparsity of feature selection;
[0086] reg_lambda=1: Introduces L2 regularization, which suppresses extreme values of model parameters by adding a squared penalty term to the objective function, further preventing overfitting;
[0087] subsample=0.9: 90% of the training samples are randomly selected for modeling in each round of training. This sample perturbation reduces the model's dependence on the training set and improves its generalization ability.
[0088] colsample_bytree=0.9: Randomly select 90% of the input features when building each tree to avoid excessive influence of a single feature on the model and enhance the robustness of the model.
[0089] Meanwhile, the training sample set is divided into a training set (70%) and a test set (30%) in a 7:3 ratio. The training set is used for model training, and the test set is used to verify the model performance in real time. An early stopping mechanism with early_stopping_rounds=50 is introduced—if the mean absolute error (MAE) on the test set does not decrease significantly for 50 consecutive iterations (the decrease is less than 0.01 kWh), the training is automatically terminated to avoid wasting computational resources on invalid iterations.
[0090] Step 5: Power generation forecast for the target time period
[0091] Obtain the predicted solar irradiance data for the region corresponding to the photovoltaic power station within the target time period (e.g., 00:00-23:00 the next day) (hourly prediction data can be obtained from the weather forecast platform). Perform the periodic feature transformation in step 2 on the timestamp of each time point within the target time period to obtain the corresponding sine and cosine features. Input the "predicted solar irradiance value + time periodic features" into the trained power generation prediction model. The model outputs the photovoltaic power generation prediction results for each time point, and finally forms the power generation prediction curve for the target time period.
[0092] Preferred embodiments detailed
[0093] Detailed step 1: Data cleaning and supplementation
[0094] After collecting data in step 1, if there are a few missing values (such as missing irradiance data due to weather station malfunction), the "linear interpolation method" is used to supplement them. For example, if the irradiance data at a certain time point t is missing, the irradiance values of the two adjacent valid data points before and after t are taken, and the supplementary value at point t is calculated by linear fitting to avoid the impact of missing values on model training.
[0095] Refinement 2: Supplementing Model Evaluation Indicators
[0096] In step 4, in addition to using MAE as the core evaluation indicator, the root mean square error (RMSE) and coefficient of determination (R²) can also be combined to comprehensively evaluate the model performance.
[0097] MAE: Reflects the average absolute deviation between the predicted value and the true value. The calculation formula is MAE=Σ|y_true - y_pred| / n (n is the number of samples). In this application, MAE≤5 kWh.
[0098] RMSE: The effect of amplified large deviations, calculated by the formula RMSE=√[Σ(y_true - y_pred)² / n]. In this application, RMSE≤8 kWh.
[0099] R²: measures the model's ability to explain the data, with a value range of [0,1]. In this application, R²≥0.95, indicating that the model can explain more than 95% of the power generation variation.
[0100] Reference Figure 2 Secondly, this application provides a distributed photovoltaic power generation prediction system based on XGBoost. This system corresponds one-to-one with the methods described above, and through modular design, it achieves full automation of the data acquisition, processing, modeling, and prediction process, including:
[0101] 1. Data Acquisition Module
[0102] Hardware interface: Supports communication with inverters of distributed photovoltaic power stations via RS485 / Ethernet interface to collect historical power generation data in real time; connects to the National Meteorological Information Center or third-party meteorological platforms via API interface to obtain hourly solar irradiance data for the corresponding geographical location;
[0103] Data storage: The collected power generation data and irradiance data are stored in a MySQL database and managed by partitioning by "Power Plant ID - Date" for easy subsequent data query and retrieval;
[0104] Data validation: Built-in data validity validation rules automatically remove obviously abnormal data (such as irradiance values exceeding 2000 W / ㎡ or being negative, or power generation values being negative), ensuring the reliability of input data.
[0105] 2. Time processing module
[0106] Timestamp conversion unit: Converts timestamps stored in the database (e.g., in "YYYY-MM-DD HH:MM:SS" format) into second-level numerical values t;
[0107] Periodic calculation unit: Calculates time periodicity characteristics based on the formulas sin(2πt / 86400) and cos(2πt / 86400), and supports batch processing (time feature transformation of more than 100,000 data points can be processed at a time).
[0108] Feature storage unit: Associates the calculated time-periodic features with the original data and updates the feature table in the MySQL database.
[0109] 3. Feature Construction Module
[0110] Feature extraction unit: Reads historical power generation data, hourly irradiance data and time periodic features from the database;
[0111] Sample combination unit: Training samples are combined according to the structure of "[irradiance value, sine feature, cosine feature] → power generation value", and the sample set can be automatically generated according to a predetermined period (e.g., 1 month).
[0112] Sample partitioning unit: Divide the sample set into training set and test set in a 7:3 ratio, and generate CSV format file for model training.
[0113] 4. Model Training Module
[0114] Parameter configuration unit: Provides a visual parameter configuration interface, allowing users to adjust the core parameters of the XGBoost model (such as n_estimators, max_depth) and save the parameter configuration scheme;
[0115] Training execution unit: Model training is implemented based on the Python XGBoost library, which supports CPU / GPU hybrid computing (training speed is 3-5 times faster than CPU in GPU mode).
[0116] Model evaluation unit: calculates MAE, RMSE and R² of the test set in real time during training, generates evaluation curves, and automatically terminates training according to the early_stopping_rounds mechanism;
[0117] Model storage unit: Stores the trained model as a binary file (.model format) to the server, and supports model version management (retains historical training models for easy backtracking and comparison).
[0118] 5. Prediction Module
[0119] Predictive data acquisition unit: Obtains predicted solar irradiance data for the target time period through API interface, and calls the time processing module to generate corresponding time periodic features;
[0120] Prediction Execution Unit: Loads the trained model, takes "predicted irradiance + time features" as input, and outputs the predicted power generation result;
[0121] Results Display Unit: Displays the power generation forecast results for the target time period in the form of tables, line graphs, etc., supports exporting forecast reports in Excel format, and provides an API interface to push the forecast results to the power grid dispatch system or user power management platform.
[0122] Reference Figure 3 Thirdly, this application provides a computer device:
[0123] The computer device includes a memory and a processor. The memory stores a computer program, and the processor is configured to retrieve the computer program and execute the XGBoost-based distributed photovoltaic power generation prediction method described in the first aspect above.
[0124] Specifically, the computer equipment can use an industrial-grade server (such as an Intel Xeon E5 processor, 32GB of memory, and 1TB of SSD storage), with the operating system being Linux CentOS 7.0. It supports Python 3.8 and above and requires the installation of dependent libraries such as XGBoost 1.7.5, Pandas 1.5.3, and NumPy 1.24.3. The processor can automate the entire process of data acquisition, feature transformation, model training, and prediction by calling computer programs stored in memory, and supports multi-threaded processing (it can provide prediction services for more than 10 distributed photovoltaic power stations simultaneously).
[0125] Fourthly, this application provides a computer-readable storage medium:
[0126] The computer-readable storage medium stores a computer program that, when executed by a processor, implements the XGBoost-based distributed photovoltaic power generation prediction method described in the first aspect above.
[0127] The storage medium can take the form of various media such as USB flash drive, portable hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk; for example, after storing the computer program on the USB flash drive, it can be read and executed on different computer devices, realizing the flexible deployment of the prediction method, which is especially suitable for the on-site prediction scenario of distributed photovoltaic power station in the absence of network environment.
[0128] In some embodiments, the XGBoost-based distributed photovoltaic power generation prediction method described above can be implemented using a computer device, which includes at least one processor, a communication bus, a memory, and at least one communication interface.
[0129] A processor can be a general-purpose central processing unit (CPU) or an application-specific integrated circuit (ASIC).
[0130] A communication bus can be used to transmit information between the aforementioned components.
[0131] The memory can be read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions, random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, universal optical discs, Blu-ray discs, etc.), magnetic disks or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited to these. The memory can exist independently and be connected to the processor via a communication bus. The memory can also be integrated with the processor.
[0132] The memory stores program code that executes the scheme of this application, and its execution is controlled by a processor. The processor executes the program code stored in the memory. The program code may include one or more software modules. In the above embodiments, the distributed photovoltaic power generation prediction method based on XGBoost can be implemented by a processor and one or more software modules in the program code in the memory.
[0133] A communication interface is a device that uses any transceiver or similar device to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0134] In a specific implementation, as one example, a computer device may include multiple processors, each of which may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. Here, a processor may refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).
[0135] The aforementioned computer device can be a general-purpose computer device or a special-purpose computer device. In specific implementations, the computer device can be a desktop computer, a portable computer, a network server, a handheld digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device. This application does not limit the type of computer device.
[0136] To further illustrate the technical effects of this application, a distributed photovoltaic power station (located in a city in a province, with an installed capacity of 1MW) is used as an example, and the following operations are performed:
[0137] 1. Data Acquisition Phase
[0138] Historical power generation data for the power station from July 1 to September 30, 2024 (92 days in total) was collected, with a collection frequency strictly set at one data point per hour, ultimately yielding 92 × 24 = 2208 data points. Simultaneously, hourly solar irradiance data from meteorological stations within a 3-kilometer radius of the power station were obtained via API interface, also yielding 2208 data points. The data unit was uniformly set to "watts per square meter (W / ㎡)," covering various weather scenarios such as sunny, cloudy, partly cloudy, and light rain, ensuring the diversity and representativeness of the data.
[0139] After data collection, the original data was validated, revealing a 0.5% missing rate (11 missing data points, all of which were irradiance data). Linear interpolation was used to complete the missing data. For example, since the irradiance data for 14:00 on July 15th was missing, data from 13:00 (irradiance 850 W / m²) and 15:00 (irradiance 780 W / m²) were taken. Linear fitting was used to calculate the completed value for 14:00 as 815 W / m². This completed dataset provides a reliable data foundation for subsequent feature processing and model training.
[0140] 2. Time Feature Transformation Stage
[0141] The timestamps of each data point in the completed dataset undergo periodic feature transformation. The specific steps are as follows:
[0142] Taking "July 1, 2024, 12:00:00" as an example, firstly, the timestamp is converted into a second-level value t. The number of seconds corresponding to 12 hours is 12 × 3600 = 43200 seconds, that is, t = 43200. Then, based on the total time of a day T = 86400 seconds, the mapping value is calculated as 2π × 43200 / 86400 = π. Finally, the sine value sin (π) = 0 and the cosine value cos (π) = -1 are calculated respectively, and the time periodicity characteristic of this time point is [0, -1].
[0143] Taking "July 1, 2024, 06:00:00" as an example, t = 6 × 3600 = 21600 seconds, the mapping value = 2π × 21600 / 86400 = π / 2, the sine value sin (π / 2) = 1, the cosine value cos (π / 2) = 0, and the time periodicity characteristic is [1, 0].
[0144] Following the above process, each of the 2208 data points was processed to obtain four dimensions of data for each data point: "historical power generation value + irradiance value + time sine feature + time cosine feature", thus preparing for the construction of training samples.
[0145] 3. Model Training Phase
[0146] The above four-dimensional data are combined according to the structure of "[irradiance value, time sine feature, time cosine feature] → historical power generation value" to form a training sample set. Then, the sample set is divided into a training set (1546 samples) and a test set (662 samples) in a 7:3 ratio. The training set is used for model parameter learning, and the test set is used for real-time verification of model performance.
[0147] The model parameters are strictly set according to the optimized configuration in the invention: n_estimators=2000, max_depth=5, learning_rate=0.04, reg_alpha=0.1, reg_lambda=1, subsample=0.9, colsample_bytree=0.9, and the early stopping mechanism of early_stopping_rounds=50 is enabled, with MAE as the model evaluation metric.
[0148] Training was performed using a standard Intel Xeon E5 CPU server, requiring no GPU support throughout the entire process, with an actual training time of only 8 seconds. By the 1120th epoch, the MAE on the test set showed no significant decrease for 50 consecutive iterations (stabilizing at 3.2 kWh), triggering the early termination mechanism and ending the training. After training, a comprehensive evaluation of the model's performance revealed an RMSE of 5.8 kWh and an R² of 0.96 on the test set, indicating that the model not only has low prediction bias but also explains over 96% of the power generation variation, fully meeting the accuracy requirements of practical applications.
[0149] 4. Prediction Verification Phase
[0150] To verify the actual predictive performance of the model, hourly predicted solar irradiance data (obtained from a third-party meteorological platform) for the region corresponding to the power station on October 1, 2024 (a date not covered by the training data) was obtained, totaling 24 data points. Time feature transformation was performed on the timestamp of each time point to obtain the corresponding sine and cosine features. The "predicted irradiance value + time periodicity feature" were input into the trained model in sequence to obtain the predicted power generation results for each hour on October 1, 2024.
[0151] After October 1st, the actual power generation data of the power station on that day was collected and compared with the prediction results: the overall prediction accuracy reached 95.7%, with the smallest prediction deviation during the period from 12:00 to 14:00 (average deviation of 2.1 kWh), and the largest deviation occurred at 14:00 (actual power generation 482.3 kWh, predicted value 475.2 kWh, deviation 7.1 kWh). This deviation was mainly caused by a sudden short-term cloudy weather at 14:00 on that day, which led to a temporary decrease in irradiance, but it was still within an acceptable range.
[0152] Meanwhile, the proposed solution was compared with the existing "KMeans+LSTM" solution on the same dataset: the existing solution requires GPU training, with a training time of 1200 seconds and a test set MAE of 6.5 kWh, which increases to 8.9 kWh when the proportion of outlier data is 8%; while the proposed solution is significantly better than the existing solution in terms of training efficiency, prediction accuracy, and anti-interference ability, which fully verifies the advanced nature and practicality of the technical solution.
[0153] In summary, compared with the prior art, the present invention has the following beneficial effects:
[0154] This application achieves a technological breakthrough in distributed photovoltaic power generation prediction through an innovative combination of "hourly irradiance + periodic time characteristics + XGBoost model," with core advantages including:
[0155] Robust and requiring no preprocessing: XGBoost’s weighted tree ensemble mechanism can automatically reduce the impact of outliers on the model, eliminating the need to rely on clustering algorithms such as KMeans for outlier screening, simplifying the process while improving anti-interference capabilities.
[0156] Lightweight and low-cost model: Compared to deep models such as LSTM, XGBoost has low hardware resource requirements (it can run on a regular CPU), and the training time is reduced from hours to seconds, significantly reducing computing costs and deployment difficulty;
[0157] High accuracy and good generalization: By capturing the daily cycle of power generation through periodic time features and combining XGBoost’s nonlinear learning capability, the prediction accuracy reaches over 95%, and it maintains stable performance in different seasons and weather scenarios.
[0158] Flexible deployment and wide applicability: It supports distributed deployment at multiple sites and can provide forecasting services for multiple photovoltaic power plants at the same time. The output results can be directly connected to the power grid dispatching system or user power management platform, providing key technical support for smart grid construction and distributed energy management.
[0159] The technical solutions provided by the embodiments of the present invention have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the embodiments of the present invention. The descriptions of the embodiments above are only for helping to understand the principles of the embodiments of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the embodiments of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for predicting distributed photovoltaic power generation based on XGBoost, characterized in that, Includes the following steps: Collect historical power generation data of distributed photovoltaic power stations within a predetermined period, wherein the predetermined period is set to 1 day, 1 week or 1 month according to the predicted demand, and the collection frequency of the historical power generation data is 1 data point per hour. Obtain hourly solar irradiance data recorded by a meteorological station at the geographical location corresponding to the photovoltaic power station within the predetermined period, wherein the collection frequency of the hourly solar irradiance data is consistent with the historical power generation data; The timestamps of each data point in the historical power generation data and hourly solar irradiance data are periodically mapped. Based on the total length of a day T=86400 seconds, the timestamps are mapped to the interval [0,2π] in seconds. The sine characteristic of timestamp t is calculated by the formula sin(2πt / T), and the cosine characteristic of timestamp t is calculated by the formula cos(2πt / T) to obtain the time periodic characteristics. The hourly solar irradiance data is combined with the time periodicity features to construct training samples for the XGBoost regression model. The input features of each training sample include the hourly solar irradiance value at the corresponding time point, the sine feature value of the timestamp at that time point, and the cosine feature value of the timestamp at that time point. The label of each training sample is the historical power generation value at the corresponding time point. The training samples were divided into training and test sets in a 7:3 ratio. The XGBoost regression model was trained with the following parameters: n_estimators=2000, max_depth=5, learning_rate=0.04, reg_alpha=0.1, reg_lambda=1, subsample=0.9, and colsample_bytree=0.
9. An early stopping mechanism of early_stopping_rounds=50 was introduced during training. If the mean absolute error of the power generation prediction model did not improve significantly after 50 consecutive iterations on the validation set, the training was terminated. Obtain the predicted solar irradiance data for the region corresponding to the photovoltaic power station within the target time period. Perform the above-mentioned periodic mapping operation on the timestamp of each time point within the target time period to obtain the corresponding time periodic feature. Input the predicted solar irradiance data and the time periodic feature into the power generation prediction model and output the photovoltaic power generation prediction result for the target time period.
2. A distributed photovoltaic power generation prediction system based on XGBoost that applies the method described in claim 1, characterized in that, include: The data acquisition module is used to collect historical power generation data of the distributed photovoltaic power station within a predetermined period, as well as hourly solar irradiance data recorded by the meteorological station at the corresponding geographical location of the photovoltaic power station within the predetermined period. The acquisition frequency of the historical power generation data and the hourly solar irradiance data is 1 data point per hour. The time processing module is used to periodically map the timestamps of each data point in the historical power generation data and solar irradiance data. Based on the total length of a day T=86400 seconds, the timestamps are mapped to the interval [0,2π] in seconds. The sine characteristic of the timestamp t is calculated by the formula sin(2πt / T), and the cosine characteristic of the timestamp t is calculated by the formula cos(2πt / T) to obtain the time periodic characteristics. The feature construction module is used to combine the hourly solar irradiance data with the time periodic features to construct training samples for the XGBoost regression model. The input features of each training sample include the hourly solar irradiance value at the corresponding time point, the sine feature value of the timestamp at that time point, and the cosine feature value of the timestamp at that time point. The label of each training sample is the historical power generation value at the corresponding time point. The model training module is used to divide the training samples into training and test sets in a 7:3 ratio. The XGBoost regression model is trained with the following parameters: n_estimators=2000, max_depth=5, learning_rate=0.04, reg_alpha=0.1, reg_lambda=1, subsample=0.9, and colsample_bytree=0.
9. An early stopping mechanism of early_stopping_rounds=50 is introduced during training. If the mean absolute error of the validation set does not improve significantly after 50 consecutive iterations, the training is terminated, and the power generation prediction model is obtained. The prediction module is used to obtain the predicted solar irradiance data of the region corresponding to the photovoltaic power station within the target time period, call the time processing module to periodically map the timestamp of each time point within the target time period to obtain the corresponding time periodic feature, input the predicted solar irradiance data and the time periodic feature into the power generation prediction model, and output the photovoltaic power generation prediction result for the target time period.
3. A computer device, the computer device comprising a memory and a processor, the memory storing code, characterized in that, The processor is configured to acquire the code and execute the XGBoost-based distributed photovoltaic power generation prediction method as described in claim 1.
4. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the distributed photovoltaic power generation prediction method based on XGBoost as described in claim 1.
Citation Information
Patent Citations
A photovoltaic power generation power prediction method
CN114004139B
Distributed photovoltaic power generation prediction method and device
CN117913808A
Photovoltaic generating capacity prediction method and device
CN115481772A
Feature extraction method and system for short-term photovoltaic power prediction
CN118885883A