# Intra-Plot Variable N Fertilization in Winter Wheat through Machine Learning and Farmer Knowledge
## 3 Results and Discussion
### Selecting the Best Machine Learning Regression Algorithm for Wheat Yield at S2 Pixel Resolution  
The comparative analysis of the performance of the 15 algorithms with the training dataset shows that RF had the best results (Figure 3). The RMSE values ranged from 1325 for the linear model to 528 for the RF. The R\({}^{2}\) ranged from 0.39 for the linear model with DEM information to 0.90 for the RF. The standard deviation of LM with DEM (LM MDT) is greater than the LM algorithm (Figure 4). These results suggest that the data used to train the model (in each iteration) had a greater influence on the results. Considering this, it is not strange that, although the RMSE of the LM MDT is lower, the R\({}^{2}\) is somewhat lower in relation to the LM. One of the reasons for the better performance of RF is that it is optimized to work with many variables and is difficult to overtrain [35]. Furthermore, RF is not strongly affected by the presence of outliers, as these are clustered and subsequently analyzed. Each tree in the RF has high variance and low bias, but it is reduced by averaging all tree results. In this case, the algorithm was composed of 500 trees. Finally, RF does not require much model training time because it works with subsets rather than whole trees.  
Surprisingly, the NNET algorithm, widely used in precision agriculture to estimate the yields of different crops [36; 37], performed poorly in this experiment (Figure 4). This could be because with medium-sized datasets, such as the ones used in this article, the NNET does not train itself adequately because it needs huge amounts of data to work properly [38].  
The KNN algorithm is another widely used algorithm for yield estimation. However, in this experiment, it was not among the top five algorithms. Its low performance was probably a consequence of the use of many correlated variables [39].  
The five algorithms (RF, SvmRadial, Gaussian, BstTree, and Brnn) that obtained the best results with the training dataset were validated using the test dataset. The prediction capability of the five selected algorithms was significant (\(p<0.001\)). The best results were obtained again by the RF algorithm, with an R\({}^{2}\) value of 0.90 and an RMSE of 496. On the other hand, Brnn was the algorithm with the worst results obtained with the test dataset (R\({}^{2}\) = 0.81 and RMSE = 722). The rest of the algorithms performed practically equally. The RMSE ranged between 589 and 573, and the R\({}^{2}\) was the same: 0.86. The RF algorithm was used by [PERSON] et al. (2009) with good results to predict wheat yield for large areas of the United Kingdom. Taking both statistics (RMSE and R\({}^{2}\)) into account, and the fact that it has been used successfully for similar purposes before, the RF was selected to analyze its performance when predicting the wheat grain yield of the whole plot of farmer 2, using the information from the rest of the fields to train the algorithm.  
Figure 4: Comparison of the performance of the 15 machine learning algorithms, ordered from lowest to highest R\({}^{2}\) and RMSE (LM = Linear model, LM MDT = Simple linear model with DEM, NNET = Artificial Neural Networks, PLS = Partial Least Squares, LeapForward = Linear Regression with Forward Selection, Lasso = Lasso, GLM = General Lineal Model, Treebag = Bagged CART, BagEarth = Bagged EARTH, knn = k-Nearest Neighbors, Bmn = Bayesian Regularized Neural Networks, BstTree = Boosted Tree, Gaussian = Gaussian Process, SvmRadia = Support Vector Machines with Radial Basis Function Kernel, RF = Random Forest). The mean value of 10 iterations is represented with a black dot, the blue box represents the standard deviation, and the blue lines represent the threshold of the outlier.