# Monitoring Within-Field Variability of Corn Yield using Sentinel-2 and Machine Learning Techniques
## 2 Materials and Methods
### Yield Prediction with Machine Learning  
The prediction of a continuous variable, i.e., regression, can be done with several ML approaches. Three algorithms were tested in this investigation: multiple regression (MR), random forests (RF), and support vector machines (SVM). The last two are nonparametric methods, as the number of parameters in the model is not fixed, but changes depend on the data used for training--which usually grows as the training data volume increases [46]. These models were chosen because in the existing literature, they have been proven to yield better results when compared with other methods [56; 57; 58; 59; 60]. The independent variables were the reflectance values of the considered bands and the dependent variable to be predicted was the yield value. At each image, band values were used as independent variables to train a model using the values in the raster derived from the measured yield, as described in Section 2.2. Multiple regression uses multiple simple linear regressions on the input variables using least squares optimization to define the best fit for each dependent variable as a function of the independent variable (measured yield). This is the simplest model and assumes a linear relationship between the yield and the band reflectance values, and that band values are not correlated. This last assumption is known to be untrue, as band values are correlated; thus, this method was applied to the first four principal components which contained 92% of variance. Random Forests (RF) is a method based on decision trees for classification and regression. The training data are used to define decision boundaries that create the \"trees\" in the \"forest\" via split nodes in the decision tree process. The best combinations of splits are defined by a bootstrap approach. The available training data is sampled without replacement, keeping the remaining data for determining residuals from an independent set (out-of-bag validation) and thus comparing the accuracy metrics between combinations and choosing the best. Two main parameters need to be defined by the user: the number of features randomly sampled as candidates at each split--usually the square root of the total number of features--and the number of trees to grow. The Support Vector Machine (SVM) method defines boundaries in high-dimensional space, i.e., a hyperplane, that separates training data into labelled classes, which, in our case, is a continuous variable (yield) for the regression task. Nonlinear boundaries use a nonlinear kernel function, in our case, the Radial Basis kernel \"Gaussian\" RBF. For more information on the method, there is extensive literature on SVM applied to remote sensing [45; 48; 56; 57]. In order to validate the tested models, the predicted yield was compared against the measured yield from independent samples. Only cells that were free from clouds were used by masking any cell with a cloud coverage probability above zero (see Table 2). The cause for using this conservative threshold is to avoid the noise from clouds taking into consideration that this study investigated the within-field variability of a relatively small area cultivated with the same crop through limited satellite spectral reflectance bands. Therefore, for each cloud-free date, we made 2006 observations with 12 variables, i.e., reflectance values of the land cover at the time the satellite image was recorded. In case of clouds, fewer cells were used. The model was run 60 times, each time randomly dividing data into two parts and using one half for training and the remaining half for validation. This procedure was repeated to assess variation in accuracy metrics when using different point samples for training. Five accuracy metrics were extracted in order to obtain a thorough overview of the distribution of errors as per Equations (10)-(14).