# A Machine Learning Method to Estimate Reference Evapotranspiration Using Soil Moisture Sensors
## Materials and Methods
### Data Preparation and Preprocessing  
The information considered in the present research consists of the following variables: the measures obtained from the four soil moisture sensors at four different depths; the daily rain, temperature, and ETo measured in the agroclimatic station of La Murada; the amount of irrigation (by sprinkler and drip) applied every day to the reference crop. Recall that the purpose is to estimate ETo using the soil moisture sensors and agroclimatic data. In this way, the additional information required in the proposed approach can be easily obtained using a thermometer and a pluviometer. The total amount of information collected during the period of study contained more than 100 MB. However, some sensors had failures on certain days, providing no information. Therefore, data preprocessing was a very important preliminary step.  
On the one hand, it has to be observed that moisture measurements were taken very frequently (288 times per day), while ETo, rainfall, irrigation, and temperature were collected only daily. This can be seen in the sample depicted in Figure 3. Therefore, for each of the four different depths of the sensors, the daily median, average, and standard deviation were computed and used as input features. This way, all the features had daily frequency. In total, there were full data available for 187 days.  
Figure 2: Main agroclimatic and irrigation variables during the study period. The agroclimatic variables were obtained in the station of La Murada; irrigation was obtained in the crop. (**a**) Daily values of the temperature and reference evapotranspiration (ETo). (**b**) Daily values of the water supply by irrigation and rainfall.  
In the sample days shown in Figure 3, irrigation was done at approximately 8:30 a.m. every day. At these moments, moisture sensors reached their highest values before quickly decreasing. The rate of decrease was greater with a higher temperature and ETo, as seen in the days from 28 to 30 June 2015. It can also be observed in Figure 3 that no irrigation was applied in the last two days; thus, the soil moisture values continued decreasing, mainly from 12:00 to 6:00 p.m. on both days. To avoid the effect of peaks in the regression algorithms, before computing the statistics, the logarithm of the measures was firstly taken, and then the resulting values were normalized between 0 and 1.  
Moreover, since many days were removed because of the missing data, another dataset was generated to test the machine learning algorithms. In this case, we took into account that the evapotranspiration, temperature, moisture, etc. of the crops were not the same throughout the day, but they changed cyclically. Thus, this new dataset was obtained computing the same statistics (median, average, and standard deviation) from the moisture sensors in periods of 6 h, instead of 24 h. This way, for each day of the study, four different samples were generated: 0 to 6 h; 6 to 12 h; 12 to 18 h; 18 to 24 h. Some days presented missing data in these periods; thus, the total number of samples for the 187 days was 682 (i.e., 66 samples were discarded). Since the data of temperature, ETo, and irrigation were available as the mean/total of each day, these values were the same for the four tuples created for each day.  
Finally, it was observed that moisture sensor number 3 was responsible for the most missing data. In order to increase the number of available samples, a third dataset was generated. The procedure was the same as in the second dataset, with four periods per day, but without using the data from sensor 3. Consequently, in this dataset, the total number of samples increased to 930.