Saving our Planet’s Water through Smart Agriculture

This article first appeared in Data Science Briefings, the DataMiningApps newsletter. Subscribe now for free if you want to be the first to receive our feature articles, or follow us @DataMiningApps. Do you also wish to contribute to Data Science Briefings? Shoot us an e-mail over at briefings@dataminingapps.com and let’s get in touch!

Contributed by: Boje Deforce, Bart Baesens, Jan Diels and Estefanía Serral Asensio. This post is based on a recent paper available in preprint.

In recent years, the surge of affordable connected sensors have allowed for a massive adoption of smart devices in many domains. One such domain is that of smart agriculture. From remote sensing to in-field sensors, sensors play a crucial role in smart agriculture. They enable farmers to collect accurate and timely data about their crops and livestock. This information is then used to make informed decisions about how to optimize the growth and health of their crops and animals.

A specific interest exists in soil moisture monitoring: by continuously monitoring soil moisture, farmers can make adjustments to their irrigation practices in real-time, which can help to improve the overall efficiency of their irrigation. Thanks to advanced analytical methods, we can even go one step further and forecast future soil moisture levels such that irrigation systems can be triggered before a stress-level is reached. Ultimately, this has the potential to save water while ensuring that crops receive the right amount of hydration, helping to ensure a sustainable and successful future for agriculture and our planet. As such, sensors combined with advanced analytics can supercharge smart agriculture, providing farmers with the information they need to make better decisions and optimize the growth and health of their crops.

The difficulty of forecasting soil moisture

Forecasting soil moisture is a challenging task for a number of reasons. One of the main reasons is the complex and varied nature of soil itself. Soil is made up of a mixture of organic matter, minerals, air, and water, and its composition can vary greatly depending on factors such as location, climate, …. Furthermore, a variety of other environmental factors can also influence soil moisture levels. For example, soil moisture can be affected by precipitation, evaporative demand, crop-type, and a host of other factors. These influences can be difficult to predict and model, making it challenging to accurately fuse all available information and translate it into a forecast of soil moisture levels.

On the hardware-side , the sensors used to measure soil moisture are not always accurate or precise. This can result in noisy datasets which can complicate model training. Finally, the data from a given growth season is often limited – depending on the crop. Even when data is available, it may be sparse or incomplete, further complicating the forecasting process.

Overall, forecasting soil moisture can be a difficult task due to the complex and varied nature of soil, the influence of many external factors on soil moisture levels, the limitations of measurement devices, and the quality of the resulting data. Despite these challenges, recent advances in deep learning are making it possible to more accurately forecast soil moisture levels, which can be valuable for a wide range of applications, including agriculture, hydrology, and climate modeling.

Temporal fusion transformers to the rescue

Recently, researchers at Google introduced the state-of-the-art Temporal Fusion Transformer (TFT). Temporal Fusion Transformers – as the name suggests – are capable of efficiently fusing various temporal information sources.  However, what truly distinguishes the temporal fusion transformers from their counterparts (e.g. LSTM) is their ability to condition on static information. Figure 1 shows the impressive architecture of the TFT as designed by the team at Google. In brief, from the bottom-up, we immediately notice the three types of input the TFT can take: static data, past information, and future information. This perfectly corresponds to the challenge of soil moisture forecasting where we wish to include static properties about e.g. the location of a field, the soil properties, and so on.

Figure 1: architecture of the temporal fusion transformer. Observe how the architecture allows for the inclusion of static data, historic data, and future information.

More so, the past inputs allow to include various historic information such as the historic values of soil moisture itself, the past rainfall, and more. Another interesting part of the TFT – though strictly speaking also viable in an LSTM – is the inclusion of known future inputs. In our case of soil moisture forecasting, this is pretty neat since it is a gateway for the inclusion of e.g. weather forecasts from weather services or forecasts of other environmental variables. Another nice feature of the TFT is the loss they use. Looking at the output of the network (top in Figure 1), we observe a quantile forecast. Basically, by using a quantile loss, the TFT is capable to predict “uncertainty regions” around its point forecasts, which can be useful in terms of irrigation decisions.

Lastly, the multi-headed attention allows for some degree of explainability. By investigating the output of the multi-headed attention, one can determine where the network pays attention in the historic information. Figure 2 (the gray line) aptly shows what this looks like in practice for a 5-day ahead forecast of soil moisture. For more details and an in-depth discussion of the results we refer to the original paper.

Beyond soil moisture forecasting

Accurately forecasting soil moisture levels is only one step in the process of providing real business value to the farmers. To actually make the forecast useful to farmers, we need to apply prescriptive analytics. In prescriptive analytics, we will provide actionable feedback based on the forecasts that can help the farmers in their irrigation scheduling. Such feedback can go anywhere from a simple rule-based to a full-fledged reinforcement learning system. This post demonstrated the strength of the state-of-the-art temporal fusion transformer to obtain a skillful forecaster for the complex task of soil moisture forecasting. The TFT has also shown promising results in other fields such as traffic prediction, air quality prediction, stock market forecasting, etc.

Figure 2: five-day ahead forecast of soil moisture (primary y-axis). The gray line (secondary y-axis) represents the historic attention of the model. Note how it peaks at a direction switch of soil moisture. The solid red line is the actual forecast, and the dotted lines represent the uncertainty of the model.