TFSMAG / README.md
Viharikvs's picture
v2: global temporal split (train<=2023-12-31, validation=2024, test>=2025-01-01) + explicit split YAML for all configs
24585f9 verified
|
Raw
History Blame Contribute Delete
12.7 kB
metadata
license: other
license_name: mixed-public-domain
language:
  - en
tags:
  - agriculture
  - time-series
  - commodities
  - crop-production
  - weather
  - climate
  - USDA
  - FAOSTAT
  - foundation-model
  - pretraining
  - fertilizer
  - crop-insurance
pretty_name: 'TFSMAG: Time-series Foundation Model for Agriculture'
size_categories:
  - 10M<n<100M
configs:
  - config_name: calendar_spreads
    data_files:
      - split: train
        path: calendar_spreads/train-*
      - split: validation
        path: calendar_spreads/validation-*
      - split: test
        path: calendar_spreads/test-*
  - config_name: calendar_spreads_deep
    data_files:
      - split: train
        path: calendar_spreads_deep/train-*
  - config_name: cftc_cot
    data_files:
      - split: train
        path: cftc_cot/train-*
      - split: validation
        path: cftc_cot/validation-*
      - split: test
        path: cftc_cot/test-*
  - config_name: climate_indices
    data_files:
      - split: train
        path: climate_indices/train-*
      - split: validation
        path: climate_indices/validation-*
      - split: test
        path: climate_indices/test-*
  - config_name: commodity_futures
    data_files:
      - split: train
        path: commodity_futures/train-*
      - split: validation
        path: commodity_futures/validation-*
      - split: test
        path: commodity_futures/test-*
  - config_name: faostat
    data_files:
      - split: train
        path: faostat/train-*
      - split: validation
        path: faostat/validation-*
      - split: test
        path: faostat/test-*
  - config_name: india_mandi
    data_files:
      - split: train
        path: india_mandi/train-*
      - split: validation
        path: india_mandi/validation-*
      - split: test
        path: india_mandi/test-*
  - config_name: nass_prices
    data_files:
      - split: train
        path: nass_prices/train-*
      - split: validation
        path: nass_prices/validation-*
      - split: test
        path: nass_prices/test-*
  - config_name: usda_nass_production
    data_files:
      - split: train
        path: usda_nass_production/train-*
      - split: validation
        path: usda_nass_production/validation-*
      - split: test
        path: usda_nass_production/test-*
  - config_name: usda_nass_progress
    data_files:
      - split: train
        path: usda_nass_progress/train-*
      - split: validation
        path: usda_nass_progress/validation-*
      - split: test
        path: usda_nass_progress/test-*
  - config_name: usda_psd
    data_files:
      - split: train
        path: usda_psd/train-*
      - split: validation
        path: usda_psd/validation-*
      - split: test
        path: usda_psd/test-*
  - config_name: usda_rma_insurance
    data_files:
      - split: train
        path: usda_rma_insurance/train-*
      - split: validation
        path: usda_rma_insurance/validation-*
  - config_name: wb_commodities
    data_files:
      - split: train
        path: wb_commodities/train-*
      - split: validation
        path: wb_commodities/validation-*
  - config_name: weather_power
    data_files:
      - split: train
        path: weather_power/train-*
      - split: validation
        path: weather_power/validation-*
      - split: test
        path: weather_power/test-*

TFSMAG: Time-Series Foundation Model for Agriculture

The largest open agricultural time-series corpus. ~547,000 series totaling ~38 million observations across 14 configs spanning commodity markets, global supply/demand, crop phenology, agroclimatology, soil moisture, climate teleconnections, wholesale mandi prices, fertilizer prices, and crop insurance.

No existing TSFM pretraining corpus (LOTSA, Chronos KernelSynth, TimesFM) contains agricultural data. TFSMAG fills that gap.

Split protocol (v2)

All configs share one global temporal cutoff so that no training observation postdates any evaluation observation, in any series, in any config:

  • train: observations through 2023-12-31
  • validation: calendar year 2024
  • test: observations from 2025-01-01 onward

A series appears in a split only if it has at least one observation in that window; n_obs, start_date, and end_date are recomputed per split. Configs whose history ends before a window simply have no rows there (e.g. calendar_spreads_deep ends in 2004 and is train-only; wb_commodities and usda_rma_insurance end in 2024 and have no test rows). At evaluation time, condition on everything before the window you are scoring (train for validation; train + validation for test). For short annual series, filter n_obs in eval to taste.

v1 of this dataset used a per-series chronological 80/20 split, which put every series' boundary at a different date (median train cutoff ranged from 1999 to 2026 across configs), leaked each series' holdout period into other series' training windows, and withheld the most recent regimes from training. The v1 files remain available under the v1-per-series-split tag:

load_dataset("Viharikvs/TFSMAG", "faostat", revision="v1-per-series-split")

Dataset summary

Config Train (series / obs) Validation (series / obs) Test (series / obs) Freq Date Range
faostat 488,456 / 21,035,524 406,169 / 406,169 14,206 / 14,206 A 1961-2024
weather_power 528 / 8,244,042 528 / 193,248 528 / 192,720 D 1981-2025
calendar_spreads_deep 550 / 3,030,408 -- -- B 1959-2004
usda_psd 22,683 / 1,012,314 16,636 / 16,636 16,636 / 17,553 A 1960-2025
usda_nass_progress 2,756 / 798,078 2,440 / 37,621 2,437 / 34,987 W 1979-2026
usda_nass_production 8,079 / 533,531 3,322 / 3,322 3,255 / 3,661 A 1866-2025
cftc_cot 430 / 391,575 420 / 21,611 399 / 25,746 W 1995-2026
commodity_futures 51 / 323,853 51 / 12,892 51 / 16,566 B 1971-2026
nass_prices 924 / 273,102 334 / 3,435 328 / 3,967 M 1970-2026
usda_rma_insurance 19,816 / 254,933 8,497 / 8,497 -- A 1989-2025
india_mandi 2,244 / 239,538 1,954 / 282,759 1,552 / 142,085 D 2023-2025
wb_commodities 51 / 34,517 48 / 576 -- M 1960-2024
climate_indices 17 / 16,861 16 / 192 16 / 233 M 1854-2026
calendar_spreads 88 / 5,721 284 / 34,441 370 / 108,115 B 2021-2026
Total 546,673 / 36,193,997 440,699 / 1,021,399 39,778 / 559,839

Grand total: 37,775,235 observations across train + validation + test.

Schema

Every config uses a uniform 14-column schema. Each row is one time series stored as parallel arrays. len(timestamps) == len(values) == n_obs is guaranteed. All timestamps are in YYYY-MM-DD format, strictly increasing within a series. Zero NaN, zero Inf across all values.

series_id (unique key per config), ticker, name, field, domain, category, exchange, unit, freq, n_obs, start_date, end_date, timestamps (list[str]), values (list[float64]).

Usage

from datasets import load_dataset

train = load_dataset("Viharikvs/TFSMAG", "commodity_futures", split="train")
val = load_dataset("Viharikvs/TFSMAG", "commodity_futures", split="validation")
test = load_dataset("Viharikvs/TFSMAG", "commodity_futures", split="test")

series = train[0]
print(series["name"], len(series["values"]), "observations")

Configs

commodity_futures (51 series, daily) -- 9/10

28 instruments: 13 ag futures (corn, soybeans, wheat HRW/SRW, soybean meal/oil, cotton, coffee, sugar, cocoa, cattle, hogs, feeder cattle), 4 energy, 5 FX, 6 ag equities. Source: Yahoo Finance. As-of: 2026-04-17.

usda_psd (22,683 series, annual) -- 10/10

Complete USDA FAS PSD. All 5 commodity groups, 44 commodities, 209 countries, 12 S&D attributes. Source: apps.fas.usda.gov/psdonline. As-of: 2025-04-09.

usda_nass_progress (2,761 series, weekly) -- 9/10

Crop progress + condition. 9 crops, 49 states, 28 phenological stages + condition ratings. Source: NASS Quick Stats bulk. As-of: 2026-04-18.

usda_nass_production (8,079 series, annual) -- 8/10

Production, yield, area, prices. 16 major crops, 52 states. Goes back to 1866. Source: NASS Quick Stats bulk. As-of: 2026-04-18.

faostat (488,456 series, annual) -- 10/10

COMPLETE UNFILTERED FAO data. 301 production items, 616 trade items, 235 price items. 283 countries. Production (74,873), Trade (391,262), Prices (52,751). Source: fenixservices.fao.org bulk downloads. As-of: 2024-12-23.

climate_indices (17 series, monthly) -- 9/10

ONI, MEI, SOI, PDO, NAO, AMO, IOD, PNA, AO, and 4 Nino SST regions (absolute + anomaly). Source: NOAA CPC/PSL/NCEI. As-of: 2026-03.

india_mandi (2,680 series, daily) -- 4/10

AGMARKNET modal prices. 5 commodities (Potato, Onion, Wheat, Tomato, Rice), 1,598 mandis, 30 states. Source: Kaggle scrape. As-of: 2025-06-11.

weather_power (528 series, daily) -- 8/10

NASA POWER agroclimatology. 12 parameters (temp mean/max/min, precip, solar, humidity, wind, root-zone soil moisture, profile soil moisture, dewpoint, surface pressure, evapotranspiration). 44 global ag regions spanning US, Brazil, Argentina, India, Ukraine, Russia, China, Australia, France, South Africa, Thailand, Indonesia, Canada, Pakistan, Bangladesh, Myanmar, Philippines, Kenya, Ethiopia. Source: power.larc.nasa.gov. As-of: 2025-12-31.

wb_commodities (51 series, monthly) -- 9/10

World Bank Pink Sheet. 5 fertilizers (DAP, TSP, Phosphate rock, Potassium chloride, Urea), grains, oilseeds, edible oils, softs, livestock, energy, fruits. 1960-2024. Source: worldbank.org CMO Historical Data. As-of: 2024-12.

usda_rma_insurance (19,816 series, annual) -- 8/10

USDA RMA Summary of Business. Premium, indemnity, liability, loss ratio, insured acres, policies. 246 crops, all states, 1989-2024. Source: pubfs-rma.fpac.usda.gov. As-of: 2024.

cftc_cot (430 series, weekly) -- 9/10

CFTC Commitments of Traders disaggregated + legacy. 21 agricultural markets (grains, oilseeds, softs, livestock, dairy, OJ, lumber). 21 position fields per market: commercial/non-commercial long/short/spread (legacy, 1995+), plus PMPU / Swap dealer / Managed money / Other reportable long/short/spread (disaggregated, 2010+). Source: CFTC bulk COT zips. As-of: 2026-04-14.

nass_prices (925 series, monthly) -- 8/10

USDA NASS Prices Received. Farm-gate monthly prices for 19 commodities (corn, soybeans, wheat, cotton, sorghum, oats, barley, rice, sunflower, peanuts, canola, hay, rye, flaxseed, milk, cattle, hogs, eggs, turkeys) at national and state level. 1970-2026. Source: NASS Quick Stats API. As-of: 2026-02-27.

calendar_spreads (370 series, daily) -- 7/10

Calendar spreads reconstructed from Yahoo individual contract months. 10 commodities (corn, soybeans, wheat SRW, soy meal, soy oil, cotton, coffee, sugar, live cattle, lean hogs). All valid front-vs-deferred pairs within rolling 15-month window per commodity, not just adjacent. History limited to 2021-2026 by Yahoo contract retention. Source: Yahoo Finance via yfinance. As-of: 2026-04-17.

calendar_spreads_deep (550 series, daily) -- 9/10

Deep historical calendar spreads from TurtleTrader free individual contract archive. 16 commodities (corn, soybeans, wheat SRW, cotton, coffee, sugar, oats, OJ, feeder cattle, lean hogs, pork bellies, crude oil, gold, silver, copper, heating oil). All valid spread pairs, 1959-2004. 3M+ observations. Complements calendar_spreads (2021-2026) with 45 years of deep history. Source: turtletrader.com/hpd. As-of: 2002-2004 (static archive, no longer updated).

Data quality

  • Zero NaN, zero Inf across all values
  • Zero duplicate series_ids within any config/split (26 colliding spread-pair ids in v1 calendar_spreads were disambiguated with _2 suffixes)
  • All timestamps normalized to YYYY-MM-DD, strictly increasing within each series
  • Global temporal split: train <= 2023-12-31 < validation <= 2024-12-31 < test (see Split protocol)
  • ~40k duplicated (series, timestamp) pairs at the v1 faostat train/test seam were deduplicated (first occurrence kept)
  • All-zero and constant series dropped
  • SOI climate index: timestamps sorted and deduplicated
  • Indian mandi: series with 60+ constant-price days dropped

Licensing

  • USDA (NASS, FAS PSD, RMA): US Government, public domain
  • NOAA: US Government, public domain
  • NASA POWER: US Government, public domain
  • FAOSTAT: CC BY-NC-SA 3.0 IGO
  • World Bank: CC BY 4.0
  • AGMARKNET: Indian Government open data (NDSAP)
  • Yahoo Finance: Verify terms for commercial redistribution
  • TurtleTrader: Free public archive, verify terms for redistribution

Citation

@misc{tfsmag2026,
  title={TFSMAG: Time-Series Foundation Model for Agriculture},
  author={Vihari Kanukollu},
  year={2026},
  url={https://huggingface.co/datasets/Viharikvs/TFSMAG},
}