# A Short-Term Photovoltaic Power Prediction Model Based on the Gradient Boost Decision Tree
## 2 GBDT Algorithm
### Decision Tree  
The decision tree (DT) is also known as the Classification and Regression Tree (CART). It can not only solve classification problems, but also can solve regression problems. As a matter of fact because the PV power prediction is a regression problem, we focus on the principle and establishment of regression trees in this paper. The process for building regression trees based on the minimum square error norm is the process to generate the binary tree recursively by choosing the best appropriate features and split points [24]. The tree structure can be adjusted according to the characteristics of the data set. Therefore we do not need to preset the function structure and are able to deal with discrete and continuous variables at the same time. However when the structure of a regression tree is too complex, the problems of over fitting or being trapped into local minimum points may appear [25].  
A simple type of decision tree is the binary tree, which has only one root node, two leaf nodes, and one branch. It is a common weak learning machine in the gradient descent algorithm, noted as \(h(\mathbf{x};\mathbf{a}_{m})\), where \(\mathbf{a}_{m}\) is the split characteristic variable and split point in the \(m\)th iteration. For continuous variables, \(\mathbf{a}_{m}\) is selected under the rule of mean variance being the minimum.  
For given samples \(R=\left\{\mathbf{x}_{i},y_{i}\right\}_{1}^{N}\) and continuous variables \(x_{i}\), there are \(n\) different values for \(x_{j}\) in set \(R\). We arrange these values in ascending order, written as \(\left\{x_{j}^{\,1},x_{j}^{\,2}\cdots,x_{j}^{\,n}\right\}\). Then we separate the set \(R\) into two parts \(R^{+}\) and \(R^{-}\) based on the split point \(s\). If the value of \(x_{ij}\) is less than \(s\), \(x_{ij}\) should belong to \(R^{-}\); otherwise, \(x_{ij}\) should belong to \(R^{+}\), which can be written as  
\[\begin{array}{ll}R^{+}(j,s)=\left\{\left.x_{ij}\right|x_{ij}\geq s\right\} \\ R^{-}(j,s)=\left\{\left.x_{ij}\right|x_{ij}<s\right\}\end{array} \tag{12}\]  
The predicted value of each set should be the same and equal to the average value of output values of all samples \(y\). The predicted value \(c_{m}\), for set \(R_{m}\) of which the amount of data is \(N_{m}\), can be calculated based on (13).  
\[c_{m}=\frac{1}{N_{m}}\sum_{x_{j}\in R_{m}}y_{i} \tag{13}\]  
For each continuous variable \(x_{j}\), all the possible values of split point \(s\) are in the set  
\[S_{x_{j}}=\Bigg{\{}\frac{x_{j}^{i}+x_{j}^{i+1}}{2}|1\leq i\leq N-1\Bigg{\}}.\]  
To find the appropriate features \(x_{j}\) and split points, we should traverse all split points \(s\) for all the features, and choose the one with minimum loss as the final split point.  
The loss can be calculated based on (14)  
\[\Psi(j,s)=\sum\limits_{x_{j}\in R^{+}}\bigl{(}y_{i}-c_{s}^{+}\bigr{)}^{2}+\sum \limits_{x_{j}\in R^{-}}\bigl{(}y_{i}-c_{s}^{-}\bigr{)}^{2} \tag{14}\]  
In conclusion, the optimal feature variable and split point can be written in the form of (15).  
\[(j^{*},s^{*})=\operatorname*{argmin}\limits_{j,s}\sum\limits_{x_{j}\in R^{+}} \bigl{(}y_{i}-c_{s}^{+}\bigr{)}^{2}+\sum\limits_{x_{j}\in R^{-}}\bigl{(}y_{i}- c_{s}^{-}\bigr{)}^{2} \tag{15}\]