Skip to content
OnlyProjects
MCA · Data Science & AnalyticsFor educational purposes only
Code included

Tomato & Onion Mandi Price Analytics and Short-Horizon Forecasting for Karnataka (Agmarknet Data)

Agmarknet arrivals and prices, volatility diagnostics, SARIMA and gradient-boosting forecasts, and a crash-alert dashboard

Mapped to your syllabusVTU MCA 2022 Scheme · 22MCA44 Project Phase-2 · Semester 4

Overview

1 min read

MandiLens is an applied data-science project on one of India's most consequential public datasets: the daily wholesale prices and arrivals of tomato and onion reported by APMC yards across Karnataka and published on Agmarknet, the Directorate of Marketing & Inspection's price portal. Tomato and onion are the crops whose price crashes and spikes dominate farm-distress headlines in the state — Kolar's tomato growers have repeatedly sold below cost while retail prices stayed high — and both have enough public daily data to support serious analysis.

The project builds a reproducible pipeline: an ingestion layer for Agmarknet price reports (data.gov.in mandi API as a secondary channel), a cleaning layer that harmonises varieties, checks ₹/quintal sanity, handles missing mandi-days and caps outliers, a warehouse (SQLite or MySQL) with date, market and commodity dimensions around a daily fact table, and an analytics layer covering decomposition, volatility, arrivals–price links and festival/monsoon effects. Two models are compared honestly — SARIMA and gradient boosting with lag, rolling and calendar features — under rolling-origin time-series cross-validation, never random k-fold, with RMSE, MAE and MAPE per market. Forecasts carry quantile risk bands (P10/P50/P90), and a rule raises a crash alert when the median forecast falls below a trailing-quantile threshold. A Streamlit dashboard shows history, forecast, bands and alerts per market, commodity and horizon.

It is scoped as a 16-week, two-member VTU MCA Project Phase-2 (22MCA44, Semester 4, 16 credits), with Phase-1 (22MCAL35) covering the literature survey, dataset acquisition and preliminary analysis.

Relevant for
Karnataka
Level
Advanced · 16 weeks · team of 2
Common at
Visvesvaraya Technological University, Anna University, Chennai, Osmania University
Updated
Nov 2026

Syllabus alignment

VTU · MCA 2022 Scheme

22MCA44 · Project Phase-2 · Semester 4 · 16 credits · CIE 100 + SEE 100

Subjects this project applies
  • Data Analytics with Python (22MCA31 / 22MCAL36) — pandas EDA, modelling, visualisation
  • Python (22MCA31) — pipeline, engine and dashboard code
  • DBMS (22MCA21) — the price warehouse and analytical SQL
  • Web Technologies (22MCA24) — the Streamlit dashboard layer
How it is evaluated

50 : 25 : 25 (report : presentation : Q&A); plagiarism check mandatory

Also fits: Anna University MCA Regulation 2021, JNTUH MCA R22, Osmania University 2-year MCA 2022-23.

What's in the box

11 parts · 5 free · 2 previewed · 4 unlock for ₹2,000

Problem & synopsis

6 min read

Problem statement

Tomato and onion are Karnataka's most volatility-prone crops: within a single season, Kolar's tomato price can collapse below the cost of harvesting while retail prices in Bengaluru remain high, and onion can reverse the same way. The daily wholesale price and arrival of every APMC yard is published on Agmarknet, but as per-commodity report tables — there is no cleaned, continuous history for a market, no volatility summary, no validated forecast, and no alert before a crash or spike. A farmer or student who wants to understand or anticipate these movements must scrape tables, fix variety and unit noise by hand, and somehow decide which of the many possible models to trust.

The problem is to build a reproducible data-science pipeline and dashboard that turns Karnataka's public Agmarknet tomato and onion data into a curated warehouse, quantifies seasonality and volatility, compares a statistical and a machine-learning forecasting model under rolling-origin validation, expresses uncertainty with quantile bands, and raises threshold-based crash/spike alerts — with every modelling choice documented and defensible in the viva.

Synopsis

Abstract

Tomato and onion prices swing violently in Karnataka's APMC yards: Kolar's tomato auctions have repeatedly collapsed below cultivation cost, while Hubballi's onion market has seen equally sudden spikes. The Directorate of Marketing & Inspection publishes every yard's daily price and arrival on Agmarknet, yet it reaches farmers late, as tables, and nobody as a warning. This project builds MandiLens — an ingestion pipeline for Agmarknet prices, a clean analytical warehouse, a volatility study, and a validated two-model forecasting system with quantile bands and crash alerts in a Streamlit dashboard. It demonstrates the full data-science lifecycle on a real, messy, public dataset.

Introduction

India's horticulture markets punish the uninformed: a farmer seeing yesterday's ₹400/quintal at Kolar has no trend view across yards, no sense of arrivals pressure, and no quantitative warning before a crash. Researchers have studied mandi integration and price transmission, but a reproducible market-level forecasting exercise on Karnataka's tomato and onion data is rare — most coursework stops at plots. This project treats cleaning as a first-class phase, evaluates models the way forecasters should, and ships an interface where analysis is usable, not just displayed.

Existing system and its limitations

  • Agmarknet reports are daily tables per commodity/market — excellent data, no analytics, no alerts.
  • data.gov.in's mandi price API offers current-day prices in bulk, but only a rolling recent window, not a curated history.
  • Commercial price dashboards exist for traders, are closed, and rarely reach farmers.
  • Academic papers on Indian vegetable prices typically stop at one commodity, method or split; the validation discipline is what this adds.
  • Farmers' own signals are local, not quantitative, and arrive after the price move.

Proposed system

  • Ingestion: Agmarknet downloads per market/commodity, cross-checked with the data.gov.in API; raw files archived.
  • Cleaning: variety harmonisation, ₹/quintal bounds, missing-day handling, IQR outlier capping — every rule logged as a data-quality metric.
  • Warehouse: a star schema (dim_date, dim_market, dim_commodity, fact_price_daily) in SQLite/MySQL with weekly and monthly SQL views.
  • Analytics: seasonal-trend decomposition, coefficient of variation by market, arrivals-vs-price lag correlation, festival/monsoon overlays.
  • Modelling: SARIMA vs gradient boosting with lag, rolling-mean, arrivals and calendar features; rolling-origin CV; RMSE/MAE/MAPE and a seasonal-naive baseline no model may lose to.
  • Risk layer: P10/P50/P90 bands; a crash alert when P50 falls below the trailing 90-day 25th percentile, spike alerts symmetrically.
  • Dashboard: Streamlit pages for history, forecast, bands, alerts, metrics and a model card.

Feasibility study

  • Technical: Python (22MCA31) and Data Analytics with Python (22MCA31/22MCAL36) cover pandas, statsmodels and scikit-learn; DBMS (22MCA21) covers the warehouse; all open-source, all on a laptop.
  • Data: Agmarknet is public and the data.gov.in API is free with registration; only public aggregate data is used — no personal data, no authenticated scraping.
  • Economic: ₹0 — public data, open-source stack, no paid APIs.
  • Operational: the dashboard needs no installation for a viewer; the pipeline re-runs with one command.
  • Schedule: fits the 16-week Phase-2 window, Phase-1 having completed in Semester 3.

Objectives

  1. 01Acquire Agmarknet daily price and arrival reports for tomato and onion across at least five Karnataka APMC markets, with the data.gov.in mandi API as a secondary channel.
  2. 02Clean and harmonise the data — varieties, ₹/quintal bounds, missing mandi-days, outlier capping — and log every rule as a data-quality metric.
  3. 03Design a small star-schema warehouse (date, market, commodity dimensions around a daily price fact) in SQLite/MySQL with analytical SQL views.
  4. 04Quantify seasonality, volatility (coefficient of variation) and the arrivals–price relationship per market and commodity.
  5. 05Implement and compare a SARIMA baseline and a gradient-boosting model with lag, rolling and calendar features using rolling-origin cross-validation.
  6. 06Publish quantile risk bands (P10/P50/P90) and threshold-based crash and spike alerts with a documented rationale.
  7. 07Deliver a Streamlit dashboard with history, forecast, alerts, model metrics and a written model card, fully reproducible via pytest-covered scripts.

Scope

In scope

  • Tomato and onion daily mandi prices/arrivals for ≥ 5 Karnataka markets (e.g. Kolar, Chintamani, Mysuru, Hubballi, Bengaluru) over at least 3 years of Agmarknet history.
  • Public government data only (Agmarknet, data.gov.in); no personal data, no authenticated scraping, no government ID numbers anywhere.
  • Per market-commodity modelling: SARIMA, gradient boosting, seasonal-naive baseline; rolling-origin CV; RMSE/MAE/MAPE; P10/P50/P90 bands; crash/spike alert rules.
  • SQLite default warehouse (MySQL optional for the DBMS course link), Streamlit dashboard, pytest suite, data-quality report.

Out of scope (v1)

  • Real-time intra-day prices or farmer-level transaction data (not public).
  • Multivariate models with weather/remote-sensing inputs (candidate future work; weather datasets differ in licensing).
  • Price transmission/econometric modelling across states, farm-gate vs retail spread analysis, and crop-yield forecasting.
  • A public web deployment with user accounts — the dashboard runs locally or on a lab machine.

Methodology

The project follows CRISP-DM as its research design, adapted to the two-phase VTU MCA structure: Phase-1 (22MCAL35, Semester 3) covered business understanding, data understanding and a preliminary analysis; Phase-2 (22MCA44, Semester 4) completes deployment-grade build, evaluation and documentation across 16 weeks.

PhaseWeeksActivitiesDeliverable
Data acquisition1–2Download Agmarknet reports for 5 markets × 2 commodities; register for the data.gov.in API; archive raw filesRaw dataset + provenance log
Cleaning & warehouse3–4Variety harmonisation, unit checks, outlier capping, missing-day handling; build star schemaClean warehouse + data-quality report
Exploratory analysis5–6Decomposition, volatility by market, arrivals–price correlation, festival/monsoon overlaysEDA notebook + report chapter
Modelling7–10SARIMA per series; gradient boosting with lag/rolling/calendar features; seasonal-naive baseline; rolling-origin CVModel comparison table
Risk & alerts11–12Quantile bands, alert thresholds, backtested alert precisionAlert rules + backtest report
Dashboard13–14Streamlit app, model card, seed and run scripts, pytest suiteWorking dashboard
Documentation & viva prep15–16Final report, PPT, plagiarism check, demo rehearsalSubmission

Team split: Member 1 owns ingestion, cleaning and the warehouse; Member 2 owns modelling, validation and the dashboard; both own the EDA and the report chapters of their parts and can each defend the full pipeline at the viva.

Validation discipline: rolling-origin (expanding-window) cross-validation with a fixed 7-day horizon — never random k-fold, which leaks the future into training. Every model must beat the seasonal-naive baseline to be reported; per-market metrics are shown, not just pooled averages, so a model that wins on one yard and loses on another is visible.

Architecture & tech stack

2 diagrams · 10 technologies · 2 min read

  • Python 3.11
  • pandas
  • NumPy
  • statsmodels (SARIMA)
  • scikit-learn (HistGradientBoosting)
  • Matplotlib
  • SQLite / MySQL (SQLAlchemy)
  • requests (data.gov.in API)
  • Streamlit
  • pytest

MandiLens is a pipeline-plus-dashboard architecture with an analytical warehouse at its centre:

  1. Ingestion layer — Python scripts that download Agmarknet price reports per market/commodity into an immutable data/raw/ archive, with the data.gov.in mandi API as a secondary channel; each run writes a provenance record (source, date range, row counts).
  2. Processing layer — pandas cleaning rules (variety harmonisation, unit bounds, outlier capping, missing-day policy) that produce tidy daily series and load the warehouse through SQLAlchemy.
  3. Warehouse — SQLite by default (MySQL optional): dim_date, dim_market, dim_commodity and fact_price_daily, plus SQL views for weekly/monthly aggregates.
  4. Modelling & risk layer — statsmodels SARIMA and scikit-learn HistGradientBoosting behind one common fit/forecast interface; a metrics module computes rolling-origin CV scores; a risk module derives quantile bands and alert states.
  5. Presentation layer — a Streamlit dashboard (22MCA24's web layer applied to analytics) reading the same warehouse, plus a written model card.
flowchart TD
  A[Agmarknet reports] --> ING[Ingestion scripts]
  B[data.gov.in mandi API] --> ING
  ING --> RAW[(data/raw archive + provenance)]
  RAW --> CLN[pandas cleaning rules]
  CLN --> WH[(Warehouse: dim_date, dim_market, dim_commodity, fact_price_daily)]
  WH --> EDA[EDA: decomposition, volatility, arrivals vs price]
  WH --> MOD[Modelling: SARIMA vs gradient boosting]
  MOD --> CV[Rolling-origin cross-validation]
  MOD --> RISK[Quantile bands P10/P50/P90 + alert rules]
  WH --> DASH[Streamlit dashboard]
  CV --> DASH
  RISK --> DASH
  EDA --> DASH

Warehouse ER diagram

erDiagram
  DIM_DATE ||--o{ FACT_PRICE_DAILY : "keys"
  DIM_MARKET ||--o{ FACT_PRICE_DAILY : "keys"
  DIM_COMMODITY ||--o{ FACT_PRICE_DAILY : "keys"
  DIM_COMMODITY ||--o{ DIM_VARIETY : "has"
  DIM_VARIETY ||--o{ FACT_PRICE_DAILY : "keys"

  DIM_DATE {
    int dateKey PK
    date fullDate
    int month
    int week
    string festivalFlag
  }
  DIM_MARKET {
    int marketKey PK
    string marketName
    string district
    string state
  }
  DIM_COMMODITY {
    int commodityKey PK
    string commodity
    string group
  }
  DIM_VARIETY {
    int varietyKey PK
    int commodityKey FK
    string variety
  }
  FACT_PRICE_DAILY {
    int dateKey FK
    int marketKey FK
    int varietyKey FK
    decimal minPrice
    decimal maxPrice
    decimal modalPrice
    real arrivalsTonnes
  }

Modules

6 modules

  1. Module 01

    Ingestion & Provenance (Member 1)

    Python scripts that download Agmarknet price/arrival reports for each market-commodity into an immutable raw archive, normalise column names and encodings, and write a provenance record per run (source URL, date range, row counts, checksum) so every analysis is reproducible from named raw files.

  2. Module 02

    Cleaning & Data-Quality Report (Member 1)

    Pandas rules that harmonise variety labels, enforce ₹/quintal sanity bounds, cap IQR outliers with a logged cap value, and apply a documented missing-mandi-day policy (gap flagging, not silent interpolation). Every rule emits counts to a data-quality report table — the first exhibit in the final report.

  3. Module 03

    Warehouse & Analytical SQL (Member 1)

    A star schema — dim_date, dim_market, dim_commodity, dim_variety, fact_price_daily — in SQLite (MySQL optional), loaded via SQLAlchemy, with SQL views for weekly/monthly modal-price averages and arrivals totals that the dashboard and notebooks both read.

  4. Module 04

    Exploratory Analysis (Member 2, shared)

    Seasonal-trend decomposition per series, coefficient of variation by market and month, arrivals-versus-price scatter with lag correlation, and festival/monsoon overlays. Outputs are publication-style charts and the volatility findings that justify the alert thresholds.

  5. Module 05

    Modelling & Validation Engine (Member 2)

    One fit/forecast interface over statsmodels SARIMA and scikit-learn HistGradientBoosting (lag, rolling-mean, arrivals and calendar features), a seasonal-naive baseline, and rolling-origin cross-validation with a 7-day horizon. Metrics (RMSE, MAE, MAPE) are computed per market-commodity and persisted with the run.

  6. Module 06

    Risk Bands, Alerts & Dashboard (Member 2)

    Quantile forecasts (P10/P50/P90) from the selected model; crash alerts when the P50 median forecast falls below the trailing 90-day 25th-percentile price, spike alerts symmetrically above the 75th; backtested alert precision. The Streamlit dashboard shows history, forecast with bands, alert states, model metrics and the model card.

Slides

13 slides · titles free · bullets, notes and the .pptx unlock

  1. Slide 1

    MandiLens — Tomato & Onion Mandi Price Analytics for Karnataka

  2. Slide 2

    Domain: Karnataka's Most Volatile Crops

  3. Slide 3

    Problem Statement

  4. Slide 4

    Objectives

  5. Slide 5

    Data Pipeline

  6. Slide 6

    Technology Stack

  7. Slide 7

    Exploratory Findings

  8. Slide 8

    Modelling & Validation

  9. Slide 9

    Results

  10. Slide 10

    Crash & Spike Alerts

  11. Slide 11

    Dashboard Demo

  12. Slide 12

    Limitations

  13. Slide 13

    Conclusion & Future Scope

Bullets, speaker notes and the .pptx · ₹2,000

The titles above are the real outline. The rest is what you present from.

Unlock for ₹2,000

Viva questions & answers

3 of 16 answered free · 13 unlock

Read each answer, close it, and say it in your own words. Your viva will ask. Now you'll know.

  1. 01Concept

    What is your project's novelty — isn't price forecasting a solved problem?

    Forecasting methods are known; what is rarely done in student work is the disciplined application to Karnataka's tomato and onion mandi data: a reproducible ingestion pipeline from Agmarknet, a logged cleaning layer for the specific mess in this dataset, per-market model comparison under rolling-origin validation, quantile risk bands and a backtested alert rule. The contribution is the pipeline, the validation discipline and the alert design — not a new algorithm.

  2. 02Concept

    Why compare SARIMA with gradient boosting instead of using deep learning?

    With roughly three years of daily data per series, deep models overfit easily and add little interpretability, while SARIMA handles the strong annual seasonality and gradient boosting exploits lag, rolling and arrivals features with far less data hunger. We also cite the forecasting literature's consistent finding that simple, well-validated baselines are hard to beat on such series; an LSTM comparison is future work under the same validation protocol.

  3. 03Concept

    Explain SARIMA and why it suits this data.

    SARIMA models a series with autoregressive and moving-average terms plus seasonal differencing and seasonal AR/MA components. Mandi prices show weekly trading-pattern effects and a strong annual crop-cycle seasonality, so a seasonal order captures the recurring harvest-time lows and lean-season highs while differencing stabilises the trend — exactly the structure SARIMA was designed for.

+13 more questions, with answers

Try the free ones out loud first. Your examiner will not accept “it's in the PPT”.

Source code & how to run

6 steps · complete source code · unlocks with the project

Unlocks with the project · ₹2,000

6 steps · source code zip

Prerequisites, install, seed data and tests, written for demo day. Plus the complete source.

Unlock for ₹2,000

READMEFIRST

290 words · unlocks with the project

What to change before it goes anywhere near a submission. Skipping it is how the demo fails live.

Unlocks with the project · ₹2,000

290 words · ~1 min read

The checklist of things to rename, re-seed and re-think so the project reads as yours.

Unlock for ₹2,000

Instructions

357 words · unlocks with the project

How to study it, adapt it and walk your examiner through it, step by step.

Unlocks with the project · ₹2,000

357 words · ~2 min read

Report structure, formatting rules and the submission checklist your department will grade.

Unlock for ₹2,000

References

8 sources

  1. Agmarknet — Market Intelligence Portal, Directorate of Marketing & Inspection, Ministry of Agriculture & Farmers Welfare
  2. data.gov.in — Current Daily Price of Various Commodities from Various Markets (Mandi), Open Government Data Platform India
  3. eNAM — National Agriculture Market, Government of India
  4. Rob J. Hyndman & George Athanasopoulos, Forecasting: Principles and Practice, 3rd ed., OTexts (rolling-origin evaluation, seasonal methods)
  5. statsmodels — Time Series Analysis (SARIMAX) documentation
  6. scikit-learn — Machine Learning in Python (HistGradientBoosting) documentation
  7. pandas — Python Data Analysis Library documentation
  8. Streamlit Documentation

Cite this bundle

OnlyProjects. (2026). Tomato & Onion Mandi Price Analytics and Short-Horizon Forecasting for Karnataka (Agmarknet Data): MCA Data Science & Analytics project bundle [Educational resource]. https://onlyprojects.online/projects/mca-ds-mandi-price-analytics-karnataka

Future scope

1 min read

  • Weather overlay — IMD gridded rainfall as a model feature for rain-shocked weeks, with proper lag handling.
  • More commodities and states — potato, green chilli; Maharashtra and Andhra Pradesh yards for cross-state comparison.
  • Price-transmission analysis — farm-gate vs retail spread and market-integration tests between yards.
  • Alert delivery — scheduled digest via email/SMS through a free gateway, for a Krishi Vigyan Kendra or FPO pilot.
  • Sequence models — an LSTM comparison row, honestly reported against the same rolling-origin protocol.

Keep browsing

Same degree, same syllabus slot, different idea. Pick the one your guide will actually approve.