Figure 6 Forecasting Flowchart
1) Data preprocessing: The K-Nearest Neighbors (KNN) interpolation method is utilized to automatically calculate and fill in missing values in the data based on the neighboring values of the missing points. Outliers are replaced by the average of the values before and after the outlier at the preceding and following time steps.
2) Construction of input feature matrix: The input feature matrix consists of three parts: the original processed data, the time feature matrix, and the power cycle feature matrix. The original processed data refers to the data processed in step 1). The time feature matrix includes features extracted from the original data, such as the year and season. The power cycle feature matrix consists of periodic features extracted from the original data, such as the average, maximum, and minimum values of power. These three parts of feature matrices are concatenated to achieve data-level feature fusion.
3) Data standardization: The input feature matrix constructed in step 2) is standardized using Z-Score normalization to eliminate the influence of different magnitudes and dimensions. This process ensures that the mean of the data is 0 and the standard deviation is 1, while preserving the relative differences in the data without altering the distribution shape or the relative relationships of the data.
In the formulas, represents a selected feature or column from the matrix X. denotes the mean of all values for feature (), and represents the standard deviation of feature (). The standardized data are then divided into training, validation, and test sets to facilitate model training and evaluation.
4) Hyperparameter optimization: The dataset constructed in step 3) is input into the TPE-CBiGRU model, with the highest performance metric as the optimization objective. The Tree-Structured Parzen Estimator (TPE) based Bayesian hyperparameter optimization algorithm is then employed to search for and optimize the hyperparameters of the TPE-CBiGRU model, returning the optimal hyperparameter combination.
5) Training the optimal TPE-CBiGRU model: The standardized feature matrix from step 3) and the optimal hyperparameters obtained in step 4) are input into the TPE-CBiGRU model to extract high-dimensional temporal and spatial features. These high-dimensional spatiotemporal features are then superimposed and fused through the Add layer network (feature fusion at the model layer) for deep feature fusion. Subsequently, the fused features are processed by the Dense layer to produce the model’s training output, while monitoring overfitting using the validation set.
6) Analysis of prediction results: The test set data are input into the optimized TPE-CBiGRU model obtained in step 5) to obtain the photovoltaic power prediction results. By comparing the prediction results with those of the comparative models using error evaluation metrics, an in-depth analysis of the prediction performance of the TPE-CBiGRU model is conducted to validate its effectiveness and accuracy.

## Case Study Analysis

1. Experimental Platform Configuration and Data Sources

The experiment was conducted using PyCharm 2023.2 (Community Edition) as the development platform, with an integrated development environment constructed using Miniconda3. The short-term photovoltaic power prediction model was built on a deep learning framework based on Python 3.8, utilizing TensorFlow 2.6.0 and Keras 2.7.0. The model was validated using real-world data from a distributed photovoltaic (PV) power station in China. The dataset includes one year of power generation and meteorological data from February 21, 2022, to February 21, 2023, with a data sampling interval of 15 minutes. The data were split into training, validation, and test sets with proportions of 75%, 15%, and 15%, respectively.The experimental setup was as follows: the operating system was Windows 10, the CPU was a 12th Gen Intel(R) Core(TM) i5-12490F, the GPU was an NVIDIA GeForce RTX 3060, and the system had 16GB of RAM.
Evaluation Metrics
Due to the presence of zero values in photovoltaic power, the mean absolute percentage error (MAPE), commonly used in photovoltaic power prediction, becomes meaningless. Therefore, this paper selects the mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination () as the primary evaluation metrics to comprehensively represent the model’s prediction accuracy [41]. The MAE, RMSE, and are calculated as follows:
where , , and represent the actual photovoltaic power value, the mean of the actual photovoltaic power values, and the predicted photovoltaic power value, respectively; is the number of data points in the validation set; and is the index of the predicted data points.
Comparison of Parameter Optimization Methods
This paper employs the Bayesian hyperparameter optimization method based on Tree-Structured Parzen Estimator (TPE) within the Optuna optimization framework to optimize the critical hyperparameters of the CBi-GRU model [42]. The fundamental principle involves defining the hyperparameter search space and optimization objective. Through Bayesian optimization, the algorithm iteratively explores and updates the optimal hyperparameters within the search space to minimize the loss function. Based on an analysis of the CBi-GRU model, eight hyperparameters with the most significant impact on the model’s performance were selected for optimization through experimental analysis. Since the output structure of the last layer of the Bi-GRU only requires returning the predicted data of the last timestep, hyperparameter search was conducted exclusively for the last layer. The hyperparameters and their respective search spaces are shown in Table 4:
Table 4 Hyperparametric search space