📄 Causal Inference in Plants - Reader

I have built a yield forecasting model using LightGBM. It was working surprisingly well, way more accurate than agriculture experts who are physically in the farm.

It predicts strawberry and tomato yields based on growing conditions like temperature, light, CO₂, and humidity.
The model performs well in forecasting, but I realized it only learns correlations, not causal relationships.
So even if it predicts yield accurately, it cannot explain what will actually happen if the farm operator changes temperature or light in a real greenhouse over a period of time.

To go beyond prediction, I started building a simulation system that recommends growing conditions to meet customer demand. Knowing the impact of each growing condition lets a farm reduce its energy cost per kg of produce. For that, I needed causal inference — a way to estimate how much yield changes when I intervene on variables (like raising temperature by +2°C). Imagine what it costs to heat a 10 ha facility 2°C warmer.

1. Setting up causal modeling

I began by drawing a simple causal graph (DAG) that represents how different factors affect yield:

  • Temperature and light directly influence yield.
  • CO₂, humidity (VPD), irrigation, and cultivar also affect yield. Where they also influence the temperature or light the farm runs, they are confounders and must be adjusted for.
  • Some variables, like energy usage, are side effects and should not be adjusted for.

This step helped me define what needs to be controlled to get valid causal effects.

2. Integrating with DoWhy

I used DoWhy, a causal inference library, to wrap around my LightGBM model.
DoWhy helps connect the model to causal concepts:

  1. Model — define the DAG fully based on plant science. This is where I had to be a plant scientist.
  2. Identify — find which variables to adjust for (backdoor criterion).
  3. Estimate — use LightGBM as the outcome and treatment model.
  4. Refute — test how stable and believable the effect is.

My LightGBM still does the heavy lifting for nonlinear relationships, while DoWhy handles the logic of “what if” changes.

3. Checking trustworthiness

A big question was: can I trust these causal effects?

I tested this with:

  • Placebo refuters — replace temperature with random noise.
    → The estimated effect disappeared (good sign).
  • Subset refuters — re-run the model on random data splits.
    → Results stayed consistent.
  • Sensitivity tests — check how strong a hidden confounder must be to change conclusions.
    → Effects were robust unless confounding was extreme.

Refuters cannot prove that the DAG is right; they test the estimate given the DAG. But they gave me confidence that the effect is not an artifact of noise or of one particular data split.

4. Results and next steps

Now, the system can simulate different environmental settings and show expected yield changes under those interventions.
For example, “if I increase PAR by 15% by turning on LED while keeping CO₂ constant, yield increases by ~6%.”
This gives a foundation for growing condition recommendations.

Next step would be:

  • Combine multiple cultivars to learn condition-specific responses.
  • Validate the system with controlled greenhouse trials.

5. Reflection

This process taught me that causal inference is not just a statistical trick — it’s a framework for thinking.
The key was translating plant science knowledge into a graph of cause and effect, then testing those assumptions systematically.
Thanks to this work, farmers can not only predict yield, but also simulate what happens if we change the environment — a step closer to autonomous, data-driven cultivation.

Keep reading

More in Machine Learning

  1. How Modern LLMs Rebuilt Attention

    · 12 min read

    GQA, MLA, SWA, MoE, Gated DeltaNet, DSA, KV sharing — and which model actually ships each one.

  2. Attention has four matrices, not three

    · 13 min read

    AI-researched

    Q, K, V, and the output projection the name leaves out. What each weight does to the same input, and why the differences between them decide what an inference server has to cache.

  3. VAE, Practically — What I Got Wrong

    · 6 min read

    AI-researched

    A corrected mental model for VAEs, written as 'mis-belief → correction' notes after re-reading Rezende & Mohamed (2015) and reframing the encoder/decoder as variational inference rather than autoencoding.

  4. KL Divergence, Practically — What I Got Wrong

    · 5 min read

    AI-researched

    Why treating KL as 'just cross-entropy' breaks down inside variational inference, and what its asymmetry actually does to optimization (mode-covering vs mode-seeking).

📂 All 25 posts in Machine Learning