Environmental Parameters Analysis and Power
Prediction for Photovoltaic Power Generation Based on
Ensembles of Decision Trees

Shuai Zhang, Hongwei Dai, Aizhou Yang, Zhongzhi Shi

► To cite this version:

Shuai Zhang, Hongwei Dai, Aizhou Yang, Zhongzhi Shi. Environmental Parameters Analysis and Power Prediction for Photovoltaic Power Generation Based on Ensembles of Decision Trees. 11th International Conference on Intelligent Information Processing (IIP), Jul 2020, Hangzhou, China. pp.78-85, 10.1007/978-3-030-46931-3_8. hal-03456980

HAL Id: hal-03456980

https://inria.hal.science/hal-03456980

Submitted on 30 Nov 2021

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Environmental Parameters Analysis and Power
Prediction for Photovoltaic Power Generation Based on
Ensembles of Decision Trees

Shuai Zhang ¹,²,³, Hongwei Dai¹, Aizhou Yang ¹ and Zhongzhi Shi ²

¹Dongfang Electronics Co. Ltd., Yantai 264000, China

²Chinese Academy of Sciences, Beijing 110010, China

³Shandong Technology and Business University, Yantai 264005, China

**Abstract.** Due to the influence of solar irradiation, temperature and other environmental factors, the output power of photovoltaic power generation has great randomness and randomness discontinuity. In this paper, a method for analyzing environment data related photovoltaic power generation based on ensembles of decision trees algorithm is studied. Firstly, the characteristics of environmental factors of photovoltaic power generation are analyzed by K-means clustering. And then the corresponding cluster label is assigned. Furthermore, the Radom Forests is combined to build a model. Finally, the method is validated by given data above from a real project. The results show that the proposed method can provide reference for the forecasting of photovoltaic power.

**Keywords:** K-means Clustering, Ensembles of Decision Trees, Photovoltaic Power Generation, Environmental Data, Feature Analysis and Prediction

# 1 Introduction

With the replace old growth drivers with new ones strategy being implemented [1-2], new energy industry has become a strategic and pioneering one in the world. Photovoltaic power generation has been developing rapidly due to its advantages in safety, reliability, less geographic restrictions and short construction period [3]. At present, photovoltaic generation related technology have matured, but the output power has great randomness and randomness discontinuity by the influence of solar irradiation, temperature and other environmental factors [4-5]. Therefore, it is difficult to integrate into the power grid, and which is also disadvantage to rational planning for using of local energy. How to applying environmental data to analysis and predict solar power generation will become a major energy in the future [6-7].

The development of artificial intelligence, big data, data mining and other new gen-
eration of information technology have provided a good solution for solving the prob-
lem[8-9]. The reference [10] applied the K-means clustering to the actual operation data
processing of a PV station in the city of Foshan, Guangdong Province, and achieved
the operation state pattern recognition. A short-term forecasting method for photovol-
taic (PV) power is proposed in the reference [11], which established an SVM for-
casting model and uses leave-one-out algorithm to optimize the Kernel parameter and
penalty parameter to achieve the forecasting of PV power. The reference [12] proposed
a novel model called forest for photovoltaic power generation (FPPG), which is an as-
sembly predict model composed by multi regression tree and can perform better gener-
ated in power forecasting. However, photovoltaic power generation is influenced by
environmental factors greatly, such as temperature, humidity, irradiation and so on,
which are varies dramatically from one region to another. So how to make better those
data and improve data quality as still a hot topic.

In this paper, an approach which combined K-means clustering with random for-
ests, an ensemble of decision trees method, are researched and analyzed by some
measured data from a photovoltaic power station in Shandong province. Firstly, some
environmental data related photovoltaic power generation are analyzed. At the same
time, measured data from a photovoltaic power station are given. And then, the algo-
rithm principle of K-means clustering and random forests are introduced briefly.
Moreover, an algorithm which combined K-means clustering with random forests and
its flow chart are proposed. Finally, the method is validated by given data above from
a real project. The results show that the proposed method can provide reference for
the forecasting of PV power.

## 2. Some environmental data related photovoltaic power generation

The operating state of the photovoltaic power generation system is not only related
to the working state of the system internal components, but also related to the changes
of environmental parameters. There are many factors influencing the output power of
photovoltaic system. Furthermore, these factors also have a complex relationship with
the output power of photovoltaic power generation, especially the environmental data,
mainly including temperature, humidity, wind speed, air pressure, irradiation and so on,
which are the objective factors beyond human controlling but the key. Therefore, this
method has an experimental application and a research meaning to analyze the envi-
ronmental characteristics and find out the relationship between each factor and actual
power output for further prediction.

In this paper, the measured data samples of a 40MW photovoltaic power station sys-
tem in Shandong province are given. The samples including the wind speed, wind di-
rection, temperature, humidity, air pressure, irradiation factor and power at the same
sampling time. The sampling data are sampled at a 15-minute interval, 96 sampling
points per day. A total of 7,488 samples were collected from 78 consecutive days. Part
of the samples are shown in Fig. 1.

Where 'SDATE' stands for date marking, 'TIME' stands for sampling time,
'SYCG_SUMP' stands for power and 'QX000'- 'QX005' stands for: wind speed, wind
direction, temperature, humidity, air pressure and irradiation, respectively.
<table><thead><tr><th></th><th>SDATE</th><th>TIME</th><th>QX000</th><th>QX001</th><th>QX003</th><th>QX004</th><th>QX005</th><th>SYCG_SUMP</th></tr></thead><tbody><tr><td>0</td><td>17532</td><td>15</td><td>2.5100</td><td>112</td><td>0.0919</td><td>1021.679993</td><td>5.4794</td><td>0.0</td></tr><tr><td>1</td><td>17532</td><td>30</td><td>1.5599</td><td>126</td><td>0.0929</td><td>1021.679993</td><td>6.3926</td><td>0.0</td></tr><tr><td>2</td><td>17532</td><td>45</td><td>1.6400</td><td>113</td><td>0.0919</td><td>1021.690002</td><td>5.4794</td><td>0.0</td></tr><tr><td>3</td><td>17532</td><td>60</td><td>1.5200</td><td>96</td><td>0.0909</td><td>1021.570007</td><td>6.3926</td><td>0.0</td></tr><tr><td>4</td><td>17532</td><td>75</td><td>1.6200</td><td>114</td><td>0.0889</td><td>1021.479980</td><td>6.3926</td><td>0.0</td></tr><tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr><tr><td>7483</td><td>17614</td><td>1380</td><td>1.1699</td><td>178</td><td>0.1509</td><td>1018.219971</td><td>0.9132</td><td>0.0</td></tr><tr><td>7484</td><td>17614</td><td>1395</td><td>2.0999</td><td>168</td><td>0.1500</td><td>1018.210022</td><td>0.0000</td><td>0.0</td></tr><tr><td>7485</td><td>17614</td><td>1410</td><td>2.2999</td><td>159</td><td>0.1489</td><td>1018.219971</td><td>0.0000</td><td>0.0</td></tr><tr><td>7486</td><td>17614</td><td>1425</td><td>2.0499</td><td>175</td><td>0.1489</td><td>1018.200012</td><td>0.0000</td><td>0.0</td></tr><tr><td>7487</td><td>17614</td><td>1440</td><td>2.2199</td><td>183</td><td>0.1469</td><td>1018.099976</td><td>0.0000</td><td>0.0</td></tr></tbody></table>

[7488 rows x 9 columns]

<caption>Fig. 1. Part of the samples</caption>

The relationship between environmental factors and power are visualized by using line graphs. For the clarity of the data presentation, take only diurnal variation as an example, which are shown in Fig. 2(a)-(c).

<figure><img src="image_2.png" /><figcaption>(a) The relationship between wind speed/wind direction and power</figcaption></figure>
<figure><img src="image_3.png" /><figcaption>(b) The relationship between temperature/humidity and power</figcaption></figure>

<figure><img src="image_4.png" /><figcaption>(c) The relationship between air pressure/irradiation and power

**Fig. 2(a)-(c).** Various environmental factors and power line chart / day</figcaption></figure>

From Fig.2, we can see that power output has obvious correlation with temperature, irradiation and humidity, but poor correlation with wind speed, wind direction and air pressure, which can apply to preprocessed for subsequent cluster analysis to accurately cluster data ranges.
# 3. The Algorithm Principle of K-means Clustering and Random Forests

## 3.1 K-means Clustering [14]

The goal of cluster analysis is to partition the observations into groups ("clusters") so that the pairwise dissimilarities between those assigned to the same cluster tend to be smaller than those in different clusters. The K-means algorithm is one of the most popular iterative descent clustering methods. It is intended for situations in which all variables are of the quantitative type, and squared Euclidean distance equation (1) is chosen as the dissimilarity measure.

$$d(x_i, x_i') = \sum_{j=1}^{p} (x_{ij} - x_{i'j}) = \|x_i - x_{i'}\| \quad (1)$$

Note that weighted Euclidean distance can be used by redefining the $x_{ij}$ values.

The within-point scatter can be written as

$$W(C) = \frac{1}{2} \sum_{k=1}^{K} \sum_{C(i)=k} \sum_{C(i')=k} \|x_i - x_{i'}\|^2 = \sum_{k=1}^{K} N_k \sum_{C(i)=k} \|x_i - \bar{x}_k\|^2 \quad (2)$$

Where $\bar{x}_k = (\bar{x}_{1k}, \cdots, \bar{x}_{pk})$ is the mean vector associated with the kth cluster, and $N_k = \sum_{i=1}^{N} I(C(i) = k)$. Thus, the criterion is minimized by assigning the N observations to the K clusters in such a way that within each cluster the average dissimilarity of the observations from the cluster mean, as defined by the points in that cluster, is minimized.

## 3.2 Ensembles of Decision Trees-- Random Forests [13, 14]

Decision trees are a widely used models for some machine learning tasks. But a main drawback of decision trees is that they tend to overfit the training data. Although there are some measures for prevent it, such as pre-pruning and post-pruning, even with the use of pre-pruning, decision trees tend to overfit, and provide poor generalization performance.

Ensembles are methods that combine multiple machine learning models to create more powerful models, which are one way to address this problem. Random Forests are the model that belong to this category. Random forests are essentially a collection of decision trees, where each tree is slightly different from the others. To implement this strategy, we need to build many decision tree. The specific algorithm is as follow table 1:

Firstly, we first take what is called a bootstrap sample of our data. A bootstrap sample means from our n_sample points, we repeatedly draw an example randomly with replacement (i.e. the same sample can be picked multiple times), n_sample times. This will create a dataset that is as big as the original dataset, but some data points will be missing from it, and some will be repeated.

Next, a decision tree is built based on this newly created dataset. The bootstrap sampling leads to each decision tree in the random forest being built on a slightly different
dataset. Because of the selection of features in each node, each split in each tree operates on a different subset of features. Together these two mechanisms ensure that all the trees in the random forests are different.

<table><caption>**Table 1.** The algorithm of random forests [14]</caption><thead><tr><th></th><th>Random Forest</th></tr></thead><tbody><tr><td>1. For b = 1 to B:</td><td></td></tr><tr><td>(a) Draw a bootstrap sample Z* of size N from the training data.</td><td></td></tr><tr><td>(b) Grow a random-forest tree T<sub>b</sub> to the bootstrapped data, by recursively repeating the following steps for each terminal node of the tree, until the minimum node size nmin is reached.</td><td></td></tr><tr><td>i. Select m variables at random from the p variables.</td><td></td></tr><tr><td>ii. Pick the best variable/split-point among the m.</td><td></td></tr><tr><td>iii. Split the node into two daughter nodes.</td><td></td></tr><tr><td>2. Output the ensemble of trees {T<sub>b</sub>}<sup>B</sup><sub>1</sub>.</td><td></td></tr><tr><td>To make a prediction at a new point x:</td><td></td></tr><tr><td>Regression: f<sup>B</sup><sub>rf</sub>(x) = <sup>1</sup>&frasl;<sub>B</sub> &Sigma;<sup>B</sup><sub>b=1</sub> T<sub>b</sub>(x)</td><td></td></tr><tr><td>Classification: Let C&#770;<sub>b</sub>(x) be the class prediction of the bth random-forest tree. Then C&#770;<sup>B</sup><sub>rf</sub>(x) = majority vote {C&#770;<sub>b</sub>(x)}<sup>B</sup><sub>1</sub></td><td></td></tr></tbody></table>

# 4. The Algorithm Combined K-means Clustering with Random Forests and Engineering Testing

## 4.1 The Algorithm Combined K-means Clustering with Random Forests

In Random Forests Algorithm, critical parameter in this process is max_features. If we set max_features to n_features, that means that each split can look at all features in the dataset, and no randomness will be injected. If we set max_features to one, that means that the splits have no choice at all on which feature to test, and can only search over different thresholds for the feature that was selected randomly[13]. So, we applied K-means Clustering to preprocessing the data, thus, we can obtain a cluster label for every sampling point. Next, we let this label as the target function to establish a random forest to achieve forecast. The specific algorithm flow is shown in Fig. 3.
<figure><img src="image_5.png" /><figcaption>Fig. 3. Algorithm flow</figcaption></figure>

## 4.2 Engineering Testing

Based on Spark/Hadoop framework and python language, the data of the second part above are applied and analyzed. Due to limited space, only 1 day's data sampling point is taken as a legend and 7 days' data analysis is taken as a table example in Fig.4 and Table 2. It can be seen that K-means clustering has well realized self-analysis of data, and given cluster labels. In the last, a stable prediction accuracy is obtained.

<figure><img src="image_6.png" /><figcaption>Fig. 4. The result of 1day's data sampling point by using K-means Clustering -Random Forests</figcaption></figure>
<table><caption>**Table 2.** Forecast results for 7 days</caption><thead><tr><th>Sdate</th><th>n_clus-<br>ters</th><th>Accuracy on<br>training set</th><th>Accuracy on<br>testing set</th></tr></thead><tbody><tr><td>17532</td><td>10</td><td>1.000</td><td>0.958</td></tr><tr><td>17533</td><td>10</td><td>0.986</td><td>0.917</td></tr><tr><td>17534</td><td>10</td><td>1.000</td><td>0.958</td></tr><tr><td>17535</td><td>10</td><td>1.000</td><td>0.917</td></tr><tr><td>17536</td><td>10</td><td>1.000</td><td>0.958</td></tr><tr><td>17537</td><td>10</td><td>1.000</td><td>1.000</td></tr><tr><td>17538</td><td>10</td><td>1.000</td><td>0.958</td></tr></tbody></table>

## 5 Conclusions

One method based on ensembles of decision trees is studied in this paper. By K-means clustering, the characteristics of environmental factors of photovoltaic power generation are analyzed, and data related to the power output through visualization are found out, and simultaneously, the corresponding cluster label is assigned. After that, the Radom Forests is combined to build a model, and then power generation environment data and predict the power are analyzed. The results show that this method has stable prediction accuracy and certain reference value for the environment data analysis and power prediction of photovoltaic power generation.

## References

1. The Approval about the Overall Plan of Shandong the Replace Old Growth Drivers with New One Comprehensive Reform Pilot Area by the State Council, http://www.gov.cn/zhengce/content/2018-01/10/content_5255214.htm.

2. People's Government of Shandong Province: Implementation Planning for the Key Projects of the Replace Old Growth Drivers with New Ones in Shandong Province, http://www.shandong.gov.cn/art/2018/3/16/art_2522_11096.html.

3. China Electricity Council: China electric power industry annual development report. China Electric Power Press, Beijing(2018).

4. Bird, L., Lew, D., Milligan, M.: Wind and solar energy curtailment: A review of international experience. Re-newable and Sustainable Energy Reviews 65(577-586) 2016.

5. Zhang, C.Q., Zheng, Q.: SKBA-LSSVM Short-term Forecasting Model for PV Power Generation. Proceedings of the CSU-EPSA 31(8), 86-93 (2019).

6. Wu, J.Z.: Drivers and state-of-the-art of integrated energy systems in Europe. Automation of Electric Power Systems 40(5), 1-7 (2016).

7. Ai, X., Han, X.N., Sun, Y.Y.: The Development Status and Prospect of Grid-connected Photovoltaic Generation and Its Related Technologies. Modern Electric Power 30(1), 1-7 (2013).

8. He, Q., Li, N., Luo, W.J., Shi, Z.Z.: A Survey of Machine Learning Algorithms for Big Data. Pattern Recognition and Artificial Intelligence 27(4), 327-335 (2014).
9. Hu, K.Y., Li, Y.L., Jiang, X., Li, J., Hu, Z.H.: Application of Improved Neural Network Model in Photovoltaic Power Generation Prediction. Computer Systems & Applications 28(12), 37–46 (2019).

10. Yang, D.Y., Ge, Q., Dong, Y.C., Tang, Y.L., He, C.X.: Research on operation state pattern recognition of PV station based on the principle of K-means clustering. Power System Protection and Control 44(14), 25–30 (2016).

11. Yu, Q.L., Xu, C.Q., Li, S., Liu, H., Song, Y., Liu, X.O.: Application of Fuzzy Clustering Algorithm and Support Vector Machine to Short-term Forecasting of PV Power. Proceedings of the CSU-EPSA 28(12), 115–129 (2016).

12. Song, X.H., Guo, Z.Z., Guo, H.P., Wu, S.H., Wang, Z.Q., Wu, C.A.: A new forecasting model based on forest for photovoltaic power generation. Power System Protection and Control 43(2), 13–18 (2015).

13. Andreas C., M., Sarah, G.: Introduction to Machine learning with python. O’Reilly Media, Inc., Sebastopol (2016).

14. Hastie, T., Tibshirani, R., Friedman, J.: The Elements of Statistical Learning Data Mining, Inference, and Prediction. 2nd edn. Springer-Verlag, New York (2009).