Predicting soil temperature dynamics with deep learning
How neural networks can model the way soil heats and cools — and why that matters on the farm.
Soil temperature is one of those quiet variables that controls almost everything happening below the surface. It decides when seeds germinate, how fast roots grow, how quickly organic matter breaks down, and how well water moves through the profile. Yet, in practice, it's rarely measured continuously — most growers and researchers only have occasional, spot measurements.
For my MSc research in Data Science, I set out to change that. The goal was simple to state but harder to build: given a handful of soil and weather inputs, can we predict soil temperature at different depths over time?
Why deep learning?
Soil temperature is governed by physics — heat flows down from the surface and back out again, with a daily and seasonal rhythm. But the real system is messy. It depends on soil texture, moisture, organic matter, canopy cover, and a host of weather drivers. Classical models exist, but they often need parameters that are hard to measure.
Deep learning offered a different route: let the model learn the relationships directly from data. Using TensorFlow and Keras, I trained neural networks on soil property inputs plus weather variables to predict temperature profiles over time.
Turning the model into a tool
A model that only lives in a notebook isn't very useful to an agronomist. So I wrapped it in a FastAPI web application. A user can enter basic soil properties, and the app returns predicted soil temperature at different depths across a time window.
The API-first design keeps the machine-learning side separate from the interface, which made it easier to test and to deploy. It also means the same model can later power a mobile app or a dashboard without rework.
What I learned
- Cleaning and aligning soil and weather data is most of the work — the modeling is the fun part.
- A simple, well-explained model often beats a complicated one that no one can trust.
- Packaging a model behind an API makes it something real people can actually use.
This project sits at the intersection I care about most: taking data science and putting it to work in agriculture.