Project 03 · Regression

When weather meets produce prices

Joining UK weather and weekly produce-price records to test whether a few weather variables explain price movement.

Download notebook ↓ · All projects

Data: 9,647 produce-price rows · 2,191 daily weather rows
Period: 2017–2022
Tools: Python, pandas, scikit-learn, Seaborn, Matplotlib

Question

Do temperature, humidity, or wind speed help explain weekly fruit and vegetable prices in the UK?

Approach

I converted weather records to weekly observations, aligned dates, joined them with produce prices, then tested K-nearest-neighbor and linear-regression models on selected products and weather features.

  1. Align the timelines

    Price data is weekly while weather data is daily. The notebook samples the weather series by week and joins on matching dates.

  2. Fit simple baselines

    KNN is used for a pear-price exercise; linear regression tests temperature, humidity, and wind speed for selected products.

  3. Read the score with context

    R² and mean squared error are useful diagnostics, but they do not show that weather causes the price changes.

Findings and limitations

Observed finding

Weather alone was a weak predictor for apples in the saved runs (R² around 0.02–0.04). Carrot prices had a stronger relationship with temperature in one model (R² 0.33), while humidity was weaker (0.13) and wind speed offered little explanatory value. These are exploratory associations, not causal effects.

What to keep in mind

The two sources have different collection frequencies and are aligned through sampled dates. The simple models omit many potential drivers of price; an apparent change after 2020 cannot be attributed to COVID-19 from this analysis alone.

Next iteration: A stronger model would use a time-aware validation split and add seasonality, variety, supply, and market variables. I would also report uncertainty and compare against a time-series baseline.

Selected figures

Weekly produce prices over time, separated by variety.
The price series varies by both date and variety.
Actual and predicted pear prices on the held-out test dates.
A K-nearest-neighbor model compares predicted and observed pear prices.
Actual versus predicted produce prices for apples using a weather variable.
The apple models explain little of the price variation in the notebook’s held-out splits.
Actual versus predicted produce prices for carrots using weather inputs.
Temperature showed the strongest tested relationship for carrots, but this does not establish causality.

Notebook and source data

The notebook preserves the analysis code with saved outputs removed and data paths normalized to a local data folder. Dataset files are not bundled; consult the notebook README and obtain appropriately licensed source data before running it.

Download notebook · Notebook README