Mandi-Chronos / README.md
sakasurya's picture
Access note: verified organisation email
5daab46 verified
|
Raw History Blame Contribute Delete
9.42 kB
---
license: cc-by-nc-sa-4.0
base_model: amazon/chronos-2
pipeline_tag: time-series-forecasting
library_name: chronos-forecasting
language:
- en
tags:
- time-series
- forecasting
- chronos
- agriculture
- india
- mandi
- prices
datasets:
- judicialmind/MandiBench
extra_gated_prompt: 'This model is released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 licence (CC BY-NC-SA 4.0): research, academic, personal and other non-commercial use is permitted with attribution; adaptations must be shared under the same licence; commercial use is not permitted. The original public source data remains under the Government Open Data License - India (GODL-India). Commercial use: contact surya@judicialmind.ai or hello@judicialmind.ai.'
extra_gated_fields:
Name: text
Email: text
Organization: text
I accept the CC BY-NC-SA licence terms (research and non-commercial use only): checkbox
extra_gated_button_content: Accept and request access
---
# Mandi-Chronos
<!-- jm:top -->
Licence: CC BY-NC-SA 4.0 — research and non-commercial use only; derivatives must be shared under the same licence. Commercial use: contact surya@judicialmind.ai or hello@judicialmind.ai
Access is approved automatically when the email you enter matches your Hugging Face account email and belongs to the organisation you name; other requests are reviewed manually.
<!-- /jm:top -->
Mandi-Chronos is [Chronos-2](https://huggingface.co/amazon/chronos-2) fine-tuned to forecast daily wholesale (mandi)
prices in India. Given a market's daily modal price history for one commodity variety (Rs per quintal, with gaps on
days without trade), it returns probabilistic forecasts (quantiles) for the next days. It was fine-tuned on the
[MandiBench](https://huggingface.co/datasets/judicialmind/MandiBench) series before 2025-06-01, leaving out the nine
benchmark held-out states and union territories, and on MandiBench it beats zero-shot Chronos-2 at every horizon,
both overall and in the held-out states. Architecture and API are those of Chronos-2 (about 120M parameters).
## Quickstart
```bash
pip install -r requirements.txt # chronos-forecasting, torch, transformers, pandas, ...
```
```python
import pandas as pd
import torch
from chronos import Chronos2Pipeline
from huggingface_hub import hf_hub_download
repo = "judicialmind/Mandi-Chronos"
pipe = Chronos2Pipeline.from_pretrained(repo, device_map="cpu") # device_map="cuda" on a GPU
# daily modal prices (Rs per quintal) of three Agmarknet series over the 512 days before 2025-06-01
df = pd.read_csv(hf_hub_download(repo, "example.csv"), parse_dates=["ts"])
origin = pd.Timestamp("2025-06-01")
days = pd.date_range(origin - pd.Timedelta(days=512), periods=512, freq="D")
ids, contexts = [], []
for sid, g in df.groupby("series_id"):
ids.append(sid)
contexts.append(torch.tensor(g.set_index("ts")["target"].reindex(days).to_numpy(), dtype=torch.float32))
quantiles, mean = pipe.predict_quantiles(contexts, prediction_length=30, quantile_levels=[0.1, 0.5, 0.9])
for sid, q in zip(ids, quantiles): # q: (1 variate, 30 days, 3 quantiles)
print(" | ".join(sid.split("|")[1:5]))
print(" day 1 :", [round(v) for v in q[0, 0].tolist()], " day 30:", [round(v) for v in q[0, -1].tolist()])
```
**Forecast quantiles, Rs per quintal (CPU, float32)**
| state | district | market | commodity | day 1 q0.1 | day 1 median | day 1 q0.9 | day 30 q0.1 | day 30 median | day 30 q0.9 |
|---|---|---|---|---:|---:|---:|---:|---:|---:|
| Odisha | Dhenkanal | Hindol | Tomato | 2,496 | 2,798 | 3,116 | 2,440 | 3,491 | 5,174 |
| Uttar Pradesh | Prayagraj | Ajuha | Onion | 1,163 | 1,208 | 1,262 | 1,496 | 1,805 | 2,121 |
| Uttar Pradesh | Raebarelli | Raibareilly | Wheat | 2,425 | 2,436 | 2,445 | 2,392 | 2,458 | 2,516 |
**Input:** one 1-D float tensor per series, the daily price on a calendar-day grid ending the day before the first
forecast day, with `NaN` for days without trade. The MandiBench protocol uses the last 512 days. **Output:**
`predict_quantiles` returns, per series, a tensor of shape (1, prediction_length, len(quantile_levels)) in the
input's unit, and the mean forecast. `pipe.predict_df(df, prediction_length=30, id_column=..., timestamp_column=...,
target=...)` takes a long pandas table instead.
### Command line
`mandi_chronos.py` builds the daily contexts from a long table (`series_id, ts, target`, csv or parquet) and writes
forecasts in the MandiBench submission format (`series_id, origin, h, ts, q0.1 ... q0.9`):
```bash
python mandi_chronos.py example.csv --origin 2025-06-01 --out forecasts.csv
# 3 series x 30 days -> forecasts.csv
```
In Python: `from mandi_chronos import load, forecast; forecast(load(), df, "2025-06-01")`. On a GPU it loads in
bfloat16 (the precision used for the benchmark forecasts); float32 on CPU agrees with them to about 0.1% (median
relative difference of the quantiles).
## Results
[MandiBench](https://huggingface.co/datasets/judicialmind/MandiBench) test windows: 11 monthly origins from
2025-06-01 to 2026-04-01, horizons of 7, 14 and 30 days. WQL (weighted quantile loss): lower is better; dir_acc_7d:
share of windows where the median forecast moves in the same direction as the price within the first week. Mandi-Chronos is `chronos2_ft_a` in the
MandiBench files.
**All series** (windows: 88,899 at h=7, 92,776 at h=14, 96,341 at h=30)
| model | WQL h7 | WQL h14 | WQL h30 | dir_acc_7d |
|---|---|---|---|---|
| **Mandi-Chronos** | **0.0665** | **0.0778** | **0.0990** | 0.6271 |
| Chronos-2 (zero-shot) | 0.0677 | 0.0799 | 0.1025 | 0.6156 |
| TimesFM 2.5 (zero-shot) | 0.0672 | 0.0793 | 0.1012 | 0.6109 |
| TiRex (zero-shot) | 0.0709 | 0.0827 | 0.1038 | 0.6204 |
| LightGBM (global) | 0.0700 | 0.0831 | 0.1087 | 0.6025 |
| ETS (damped trend) | 0.0708 | 0.0862 | 0.1153 | 0.6109 |
| Seasonal naive (7 days) | 0.0845 | 0.0957 | 0.1193 | 0.1037 |
**Held-out states** (Chandigarh, Himachal Pradesh, Madhya Pradesh, Manipur, Meghalaya, Odisha, Rajasthan, Tamil Nadu,
West Bengal; not seen in fine-tuning; windows: 13,176 / 13,875 / 14,479)
| model | WQL h7 | WQL h14 | WQL h30 | dir_acc_7d |
|---|---|---|---|---|
| **Mandi-Chronos** | **0.0532** | **0.0641** | **0.0847** | 0.6150 |
| Chronos-2 (zero-shot) | 0.0541 | 0.0652 | 0.0858 | 0.6008 |
| TimesFM 2.5 (zero-shot) | 0.0541 | 0.0653 | 0.0869 | 0.5955 |
| TiRex (zero-shot) | 0.0559 | 0.0665 | 0.0863 | 0.6137 |
| LightGBM (global) | 0.0551 | 0.0666 | 0.0894 | 0.6002 |
| ETS (damped trend) | 0.0569 | 0.0703 | 0.0947 | 0.6014 |
| Seasonal naive (7 days) | 0.0682 | 0.0783 | 0.0990 | 0.1106 |
Bold: lowest WQL in the table. Mandi-Chronos also has the highest dir_acc_7d in both tables. It needs only the price
history. The full leaderboard (MASE and interval coverage included), all forecasts and the scoring script are in the
MandiBench dataset.
## Files
| file | content |
|---|---|
| `model.safetensors`, `config.json` | Chronos-2 weights and configuration (float32) |
| `mandi_chronos.py` | `load`, `daily_contexts`, `predict`, `forecast` and the command line above |
| `example.csv` | three MandiBench series (`series_id, ts, target`), 2024-01-06 to 2025-05-31 |
| `requirements.txt` | pinned runtime dependencies |
## Coverage
Fine-tuned and evaluated on 12,863 MandiBench series: daily modal prices of 176 food commodities in 2,126 Agmarknet
markets in 24 states and union territories. The fine-tuning data ends before 2025-06-01; the test windows run from
2025-06-01 to 2026-04-30.
## Source data
Training and example data: Directorate of Marketing and Inspection (Agmarknet), Ministry of Agriculture and Farmers
Welfare, "Variety-wise Daily Market Prices Data of Commodity", data.gov.in resource
35985678-0d79-46b4-9ed6-6f13308a1d24, https://api.data.gov.in/resource/35985678-0d79-46b4-9ed6-6f13308a1d24.
Snapshot: May 2026.
<!-- jm:source -->
Original data: published by Directorate of Marketing and Inspection (Agmarknet), Ministry of Agriculture and Farmers Welfare on the Open Government Data Platform India ([data.gov.in](https://data.gov.in)) and, where marked, NITI Aayog's National Data and Analytics Platform ([NDAP](https://ndap.niti.gov.in)), under the [Government Open Data License - India](https://data.gov.in/government-open-data-license-india) (GODL-India). The original public data remains under GODL-India; the CC BY-NC-SA 4.0 licence of this repository covers JudicialMind's compilation, derived fields, annotations, benchmarks and models.
<!-- /jm:source -->
## Citation
```bibtex
@misc{judicialmind2026mandichronos,
title = {Mandi-Chronos: Chronos-2 fine-tuned for daily mandi price forecasting in India},
author = {JudicialMind},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/judicialmind/Mandi-Chronos}}
}
```
<!-- jm:license -->
## License
[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) (see `LICENSE`): research, academic, personal and other non-commercial use, with attribution to JudicialMind and to the original data publishers; adaptations must be shared under the same licence. Commercial use requires a separate licence.
Commercial use: contact surya@judicialmind.ai or hello@judicialmind.ai.
Base model(s): `amazon/chronos-2` (apache-2.0). Their licence terms and notices continue to apply to the upstream components; see `THIRD_PARTY_NOTICES.md`.
<!-- /jm:license -->