Skip to content
Data Science · Agribusiness · Freelance

Yerba Mate Intelligence

Market intelligence platform for a yerba mate industry client: data that isn't estimated, it's verified.

Client project · private access1/7
Yerba Mate Intelligence — mapa gis (screenshot 1 of 7)
19

ETL pipelines across INYM, INDEC and the central bank

6.3%

Mean error of the domestic consumption model

87

Export destinations analysed

Context

A client in the Argentine yerba mate industry needed a consolidated view of the market: production, consumption, exports, imports, prices, competition and the supply chain. The public data exists, but it is scattered across INYM, INDEC, the central bank and retail price surveys — monthly PDFs, geoservers and spreadsheets with incompatible breakdowns.

The Challenge

Build a single trustworthy source without falling into the usual trap of filling gaps so the charts look complete. The pitfalls were concrete: INYM doesn't publish production by department, only by zone; per-capita consumption is an annual figure even though it's published monthly; and exports are so concentrated that three destinations account for 86.3% of volume.

My Role

End-to-end freelance work, solo: source research, PostGIS schema design, 19 ETL pipelines (including a scraper for INYM's PDF reports), a FastAPI backend, a Next.js frontend with 12 views and a GIS map, ML models, and automated data auditing in CI.

Approach

Three layers: (1) Ingestion — scrapers and APIs load time series and geospatial layers into PostgreSQL/PostGIS, with the source recorded per table and shown on every view; (2) Auditing — a CI script validates every new series before merge: a missing value stays NULL, never a fill-in, and every estimated value is visually flagged; (3) Analysis — three models developed and validated (SARIMA for production by zone, SARIMA for domestic consumption, and a gravity model for exports) plus a K-means segmentation of municipalities by production profile.

Stack — why each technology

Next.js + TypeScript12 views with shared filters and Server Components that read the API without exposing the database to the browser
FastAPIA data API decoupled from the frontend, so the client can consume it from other tools
PostgreSQL + PostGIS (Supabase)Time series and INYM geospatial layers in one database, with spatial queries such as ST_Contains
MapLibre GLChoropleth maps, clusters of 203 drying plants and topographic or satellite basemaps with no licensing cost
statsmodels + scikit-learnSARIMA and panel regression for forecasting; K-means with silhouette scoring for municipality segmentation
GitHub ActionsThe data audit runs automatically on every change to an ETL: no invented value reaches production

Key Decisions

"No data" over a fill-in

Interpolating or copying the previous period makes a chart look complete, but it lies. I set a non-negotiable rule: if the value is missing, the cell says "no data". Genuinely estimated values carry a visual flag, and every view states its source.

Change the model's target when the data doesn't exist

Production by department isn't published, so the model works by zone (6 zones), after verifying that each of the 19 departments falls entirely within a single zone. Per-capita consumption is annual, so the consumption model uses mill output to the domestic market — the only real monthly series on that side of the chain.

Keep the simple model

I tested adding satellite NDVI, rainfall, the exchange rate and real wages as explanatory variables. None improved the forecast. Instead of forcing a more complex model, I kept the simplest one and documented the negative results so nobody repeats them.

K-means with 4 clusters, not 3

Three clusters scored a marginally higher silhouette (0.48 vs 0.47) but lumped together municipalities with different production profiles. I chose 4 because every cluster can be explained and acted on, which is what the client needs.

Results

A 12-view platform built on 24 years of real data, plus three models developed and validated. The domestic consumption model forecasts with a 6.3% mean error. Production by zone lands between 20% and 30% error depending on the zone — reasonable for a purely seasonal baseline. The gravity model explains 42% of the variation in trade across 20 destinations: useful for understanding market structure, not for projecting volumes. Producing municipalities were segmented into 4 profiles.

What I Learned

With public data, the most valuable thing is stating precisely what isn't known. Negative results are results too: knowing that weather doesn't improve the monthly forecast saves the client months of searching. And trust in a dashboard is earned by showing the source and the level of certainty behind every number.

A project like this for your organization?

Tell me the problem and we'll work out how to solve it with data.

Let's talk

Next case

ATLAS-YPF →

View case