# Improvement of Wheat Grain Yield Prediction Model Performance Based on Stacking Technique
## 2 Materials and Methods
### Method
#### 2.3.4 Stacking Technology  
Ensemble learning can achieve better generalization performance than using a single learner by constructing and combining multiple learners. Based on the different strategies of the learner combination, it can be divided into boosting, bagging, and stacking learning methods [37]. Among them, stacking is a typical representative of the learning method, which learns how to best combine the predictions from multiple machine learning models with good performance and is typically used to generate a set of heterogeneous prediction variables. The basic idea of stacking regression is as follows: first, the entire training set is divided into T blocks by bootstrapped sampling, and the subset of T-1 blocks is randomly selected for model training of the primary learners. The model is tested on the remaining subset. Subsequently, through the training of the primary learner, the output of various learners is used as input of the next level to train the secondary learner to obtain a final output. Figure 3 showed the working principal diagram of this study based on the use of the stacking regression technology to predict the yield of winter wheat.  
The stacking method of different growth periods is similar to the stacking method of the regression model, and the entire process is divided into two levels. In this study, the ENET was used as the primary model and the secondary model for testing, to effectively avoid collinearity between the yield prediction results of each growth period of the winter wheat because of the overlap of information. First, the dataset was randomly and evenly divided into 10 parts, 9 of which were randomly selected as the original training dataset to train the first-level learner, and the remaining one was used as the model test set. Subsequently, the primary model was trained with ten-fold cross-validation to obtain the prediction of each fold, and the results were collected in the prediction matrix outside the sample. At the same time, the 10 models trained in the test set were used to predict the yield of winter wheat. The results produced 10 groups of predicted values in the test set, and the average predicted value was calculated. In this study, the regression models of the four growth stages were tested, and the outputs of each primary model were used as input to the secondary model to train again, thus integrating the prediction ability of the multiple growth stages. Similarly, ten-fold cross-validation was also used in the secondary model to obtain the final predicted value to minimize model uncertainty. To compare the prediction accuracies of the different models more fairly, the dataset was divided into training set and test set with a sampling strategy of 9:1, which was repeated 100 times, and the same ten-fold cross-validation was performed on the primary model and the secondary model in each division process. Finally, 1000 models were generated, and the average values of the coefficient of determination (R\({}^{2}\)) and root-mean-square error (RMSE) on these 1000 test sets were used as the final evaluation index of the model. The stacking regression framework was built in R v4.0.2.  
Figure 3: The workflow of the stacking regression model for predicting grain yield. In the figure: CV, cross-validation; P, prediction values of grain yield; J, jointing; F, flagging; A, anthesis; G, grain filling.