# Monitoring Within-Field Variability of Corn Yield using Sentinel-2 and Machine Learning Techniques
## 3 Results
### Machine Learning Models  
The random forests algorithm can be tuned by changing two parameters: the number of trees (Nt) and the number of features (Nf). Iterative methods to find the best Nt and Nf combinations were applied by testing \(3\times 5\) combinations of Nf \(\in\) {4, 8, 12} and Nt \(\in\) {50, 100, 120, 200, 500}. The best combination resulted in Nf = 4 and Nt = 120. Each node in a tree is split by randomly selecting Nf features from the d-dimensional input feature space. Figure 5 shows how accuracy grows by increasing the number of trees, with the optimal value when no significant increase is seen. Figures 6 and 7 show that the results were optimal at a certain time from planting the crops, which is in line with results from vegetation indices correlations but with a higher overall R\({}^{2}\) value.  
The Random Forests method gave more accurate results when compared with other types of models that use decision trees and neural network ensembles (Figure 6). For each training and validation step, more runs were carried out, as mentioned in the Methods section; therefore, variance can be reported and is visible in the plot as standard deviation whiskers (Figure 6). Only ME had a high enough value of standard deviation to be visible in the plot, showing that the absolute accuracy metrics are significantly different between methods. This is coherent with the existing literature [56; 57].  
Figure 4: Measured yield maps (top) and Green Normalized Difference Vegetation Index (GNDVI) maps of date with a higher coefficient of determination for each year (middle) and corresponding scatter plot, equations, coefficient R\({}^{2}\) values where \(p\) values \(<\) 0.001 (bottom (**a**) for 2016, (**b**) for 2017 and (**c**) for 2018 season).  
Figure 5: Improvement of fit versus the number of trees used in the Random Forests method.  
Figure 6 shows the result of the five calculated accuracy metrics, as reported in Equations (10)-(14). The mean absolute error (MAE) and the same as a percentage (MAPE) can distinguish how the best ML method ranges between 0.7 and 1.0 ton/ha, which corresponds to 5-8% of measured yields. Mean error is useful to assess bias; support vector machines ME values show that predicted yield values underestimated with respect to measured values. The whiskers in Figure 6 in the plot of the mean error show the variation of bias of each model when predictions were compared with measured yield values. This variation is +/- 0.05 ton/ha, which is minimal considering the 9 to 18 ton/ha range within-field zones. The correlation coefficient is reported for comparison reasons against the correlations found using the VIs reported in the previous section. Root mean square of errors is an important metric that is more sensitive than MAE to residuals of predicted and measured yield values.  
The results in Figure 7 report the accuracy of each model trained using certain images at certain dates (rows) when predicting yield values using other images from other dates (columns). More is discussed on this in the next section. The most accurate results (low MAE values) were provided by the 2016 images compared to 2017 and 2018. The availability of more images in 2017 and 2018 showed that MAE values are higher during the early and late corn growing stages which is in line with high correlations in R4-R6 growing stages.  
Figure 6: Accuracy metrics (average and 1\(\times\) standard deviation) of several machine learning methods: multiple regression (MR), random forests (RF), and support vector machines (SVM). Values are in kg for error metrics.  
Figure 7. Mean absolute error (MAE) values from the Random Forests model that was trained with Sentinel-2 data on a certain data (rows) applied for prediction using Sentinel-2 images at all dates (columns). Table color scaling from green for low values to red for high values. Values are in kg for error metrics.