Skip to content
OnlyProjects
MCA · AI & Machine LearningFor educational purposes only
Code included

Mandi Price Forecasting & Selling-Day Advisory for APMC Markets (Python/ML)

Turn Agmarknet's daily wholesale prices into a seven-day forecast and a when-and-where-to-sell advisory

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

Overview

1 min read

Mandi Price Forecasting & Selling-Day Advisory is an applied data-analytics application built for the way farmers and small traders actually sell perishable produce in India. Prices of onion, tomato and potato in APMC (Agricultural Produce Market Committee) mandis swing widely day to day, yet most growers still decide when and where to sell on hearsay, agent advice or yesterday's rate board. This project turns the free daily wholesale price data published on Agmarknet — the Government of India's agricultural marketing portal — and its data.gov.in mirror into a practical decision aid: a seven-day forecast of the modal wholesale price for each commodity–mandi pair, and a comparison of nearby mandis paying more on the same day.

The pipeline fetches daily prices (minimum, maximum, modal and arrivals), cleans and stores them in MySQL, and builds lag, rolling-mean and calendar features. Four forecasting approaches are trained and compared — naive and moving-average baselines, SARIMA (statsmodels), gradient-boosted trees (scikit-learn) and an LSTM network (Keras) — and evaluated with time-ordered backtests using MAE, RMSE and MAPE so that no future information leaks into training. An advisory engine converts forecasts into sell today / hold suggestions and a best-mandi recommendation, presented through a Flask dashboard with Matplotlib and Chart.js charts.

Aligned to the VTU MCA 2022 scheme's Project Phase-2 (22MCA44), the project exercises Python Programming and Data Analytics with Python (22MCA31/22MCAL36), DBMS (22MCA21), Artificial Intelligence (22MCA262) and Deep Learning (22MCA411); scikit-learn, statsmodels, Keras and Flask are industry-standard Python libraries used alongside the syllabus tools.

Relevant for
Karnataka
Level
Advanced · 16 weeks · team of 3
Common at
Visvesvaraya Technological University, Jawaharlal Nehru Technological University Hyderabad, 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
  • 22MCA31 Python Programming
  • 22MCAL36 Data Analytics with Python (Lab)
  • 22MCA262 Artificial Intelligence
  • 22MCA21 Database Management Systems
  • 22MCA411 Deep Learning
  • 22MCA24 Web Technologies
How it is evaluated

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

Also fits: JNTUH MCA R22, Osmania University 2-year MCA 2022-23, IGNOU MCA_NEW — MCSP-232 guidelines (2025).

What's in the box

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

Problem & synopsis

5 min read

Problem statement

Farmers selling perishable produce in Indian APMC mandis face high day-to-day price volatility with almost no decision support. They typically sell on the day the produce is ready, at the nearest mandi, guided by the previous day's rate board or an agent's word. Selling two or three days earlier or later, or trucking the load to a mandi twenty kilometres away, often changes the realisation by a large margin — but the farmer has no way to quantify this. Existing portals publish current prices but provide no forecast, no comparison across mandis and no advice, so the information asymmetry stays with the trader.

There is a need for a forecasting and advisory system built entirely on public government data that (a) predicts the next week's wholesale price per commodity and mandi with honest, time-ordered accuracy measures, (b) compares nearby mandis net of transport cost, and (c) presents a conservative, explainable sell/hold recommendation that a non-technical user can act on — without promising guaranteed prices.

Synopsis

Abstract

This project builds a data-driven advisory system for farmers and traders selling perishable produce in Indian APMC mandis. It forecasts the next seven days of wholesale modal prices for selected commodity–mandi pairs from the public Agmarknet dataset, compares nearby mandis, and recommends whether to sell now or hold, and where. Four model families — naive baselines, SARIMA, gradient-boosted trees and an LSTM — are compared with strict time-ordered validation and served through a Flask dashboard over MySQL.

Introduction

India's farm trade runs through thousands of regulated APMC mandis that record daily arrivals and prices. For volatile commodities such as onion and tomato, selling on a good day rather than a bad one — or at a nearby mandi instead of the nearest one — can decide whether a season is profitable. Small growers lack analytical tools: they sell when the produce is ready, not when the price is right. Meanwhile the Government of India publishes every mandi's daily prices openly on Agmarknet — real, large, messy public data.

Existing System and Literature Gap

  • Traders and farmers rely on the mandi rate board, phone calls and commission agents — none of whom is accountable for a wrong call.
  • The eNAM portal and Agmarknet publish current and historical prices but stop at displaying data; nothing tells a farmer what next week holds.
  • Published research on Indian vegetable price forecasting usually stops at accuracy tables for one series, rarely packaged with cross-mandi comparison, an explainable rule and a usable interface.
  • Gap: a reproducible system combining per-mandi forecasting, cross-mandi comparison and a conservative sell/hold rule on fully public data.

Proposed System

  • A scheduled fetcher downloads daily prices from the data.gov.in Agmarknet feed into a normalised MySQL schema.
  • A feature builder creates lag, 7/30-day rolling-mean and month/season features per commodity–mandi series.
  • A model suite trains naive, 7-day moving-average, SARIMA, gradient-boosting and LSTM models; a walk-forward backtest with time-ordered splits selects the best per series and reports MAE, RMSE and MAPE against the naive baseline.
  • An advisory engine applies a conservative rule — sell when the coming days' forecast stays within a small band of today's price and volatility is low, otherwise hold with a confidence note — and ranks nearby mandis by predicted price minus transport cost.
  • A Flask dashboard shows price history, forecasts with error bands, model comparison and the advisory, with CSV export.

Feasibility Study

  • Technical: The dataset is public and free (Agmarknet via data.gov.in; CSV bulk files also exist). All libraries are open-source and run on an 8 GB RAM laptop; LSTM training takes minutes, not hours.
  • Economic: Zero licence cost; hosting on a free tier or a college server.
  • Operational: Farmers reach the dashboard on a phone through a lightweight, large-font page; the advisory is a sentence, not a chart. The backtest protocol allows evaluation at the college itself, with a local Krishi Vigyan Kendra available for feedback.

Objectives

  1. 01Acquire and normalise public daily wholesale price data for onion, tomato and potato from the Agmarknet feed on data.gov.in into a 3NF MySQL schema.
  2. 02Perform exploratory data analysis of seasonality, trend, festival and arrival-volume effects for selected Karnataka mandi series.
  3. 03Build lag, rolling-mean and calendar features per commodity–mandi series with strict prevention of look-ahead leakage.
  4. 04Implement and compare naive, moving-average, SARIMA, gradient-boosting and LSTM forecasters for a 7-day horizon.
  5. 05Evaluate all models with walk-forward, time-ordered backtests and report MAE, RMSE and MAPE against the naive baseline.
  6. 06Design a conservative, explainable advisory rule for sell/hold and cross-mandi comparison net of transport cost.
  7. 07Deliver a Flask dashboard with price history, forecast charts, model comparison and CSV export, usable on a phone.
  8. 08Document the full pipeline so that another student can reproduce results with a different state or commodity.

Scope

In scope

  • Commodities: onion, tomato, potato; mandis from two or three districts of one state (e.g. Kolar, Bengaluru and Hubballi in Karnataka) so cross-mandi comparison stays meaningful.
  • Daily wholesale (modal) price and arrival volume; 7-day forecast horizon; retraining by command, scheduled weekly.
  • Advisory for the coming days with a confidence note, plus a mandi ranking table.
  • Role-based access: public viewer (read-only) and admin (data fetch, retrain, advisory configuration).

Out of scope (v1)

  • Retail prices, futures prices and farm-gate negotiations.
  • Payment, trading or e-auction features; the system advises, it does not transact.
  • Weather-driven models (rainfall covariates are listed under future scope).
  • Native mobile apps and SMS delivery; the dashboard is a responsive web page.

Methodology

The project follows an incremental SDLC model mapped onto CRISP-DM (Cross-Industry Standard Process for Data Mining): business understanding, data understanding, data preparation, modelling, evaluation and deployment are iterated three times, with a working pipeline demo at the end of every iteration. This suits a forecasting project because model quality is discovered only by iterating on real data.

PhaseWeeksActivitiesDeliverable
1. Understanding & acquisition1–2Study APMC pricing terms (modal price, arrivals); register a data.gov.in API key; build and test the fetcher for Agmarknet dataWorking fetcher + project plan
2. Data understanding3–4Clean the data (duplicate market-day rows, unit errors, missing days); EDA with seasonal decomposition; design the MySQL schemaCleaned dataset + EDA report
3. Preparation & modelling I5–8Feature builder; baselines and SARIMA; first walk-forward backtestBaseline results notebook
4. Modelling II9–11Gradient boosting and LSTM; hyperparameter tuning; model-per-series selectionModel comparison table
5. Evaluation & advisory12–13Backtest protocol review; advisory rules with confidence notes; cross-mandi rankingEvaluation report
6. Deployment & documentation14–16Flask dashboard; CSV export; final testing; report, PPT and demo preparationFinal submission

Testing approach: unit tests (pytest) for the cleaner, feature builder and advisory rules with fixture data; statistical validation through walk-forward backtesting (never random splits, which leak the future); acceptance checks that every dashboard number can be traced to a stored forecast run.

Architecture & tech stack

3 diagrams · 8 technologies · 2 min read

  • Python (22MCA31)
  • MySQL (22MCA21)
  • pandas / NumPy
  • scikit-learn
  • statsmodels (SARIMA)
  • TensorFlow / Keras (LSTM)
  • Flask
  • Matplotlib / Chart.js

The system is a pipeline of small Python stages around a MySQL store, served by a Flask application.

  1. Acquisition layer — a scheduled fetch job downloads daily mandi prices from the data.gov.in API (Agmarknet feed) with a CSV bulk-file fallback, and stages raw responses.
  2. Preparation layer — the cleaner normalises units, removes duplicate market-day rows and imputes or flags missing days; the feature builder writes lag, rolling-mean and calendar features per commodity–mandi series.
  3. Modelling layer — baseline, SARIMA, gradient-boosting and LSTM trainers write forecasts and per-run metrics into the database, so every dashboard number is reproducible from a stored run.
  4. Serving layer — a Flask app exposes the dashboard, advisory endpoint and CSV export; SQLAlchemy handles queries and the HTML/Chart.js front end stays stateless.
flowchart TD
  SRC[("Agmarknet via data.gov.in")] --> FET["Fetch job: API with CSV fallback"]
  FET --> CLN["Cleaner: dedupe, units, missing days"]
  CLN --> DB[("MySQL: commodities, mandis, daily_prices")]
  DB --> FE["Feature builder: lags, rolling means, calendar"]
  FE --> M1["Baselines: naive, 7-day moving average"]
  FE --> M2["SARIMA (statsmodels)"]
  FE --> M3["Gradient boosting (scikit-learn)"]
  FE --> M4["LSTM (Keras)"]
  M1 --> EV["Walk-forward backtest: MAE / RMSE / MAPE"]
  M2 --> EV
  M3 --> EV
  M4 --> EV
  EV --> ADV["Advisory engine: sell or hold + mandi ranking"]
  ADV --> APP["Flask dashboard + CSV export"]
  APP --> USR["Browser: farmer, trader, evaluator"]

Database design (ER)

erDiagram
  COMMODITY ||--o{ DAILY_PRICE : has
  MANDI ||--o{ DAILY_PRICE : reports
  COMMODITY ||--o{ FORECAST : has
  MANDI ||--o{ FORECAST : has
  FORECAST ||--o{ ADVISORY : drives

  COMMODITY {
    int commodity_id PK
    string name UK
    string variety
    string unit
  }
  MANDI {
    int mandi_id PK
    string name
    string district
    string state
  }
  DAILY_PRICE {
    int id PK
    int commodity_id FK
    int mandi_id FK
    date price_date
    decimal min_price
    decimal max_price
    decimal modal_price
    decimal arrivals_tonnes
  }
  FORECAST {
    int run_id PK
    int commodity_id FK
    int mandi_id FK
    date target_date
    string model_name
    decimal predicted_price
    decimal mae
    decimal mape
  }
  ADVISORY {
    int id PK
    int commodity_id FK
    date generated_on
    string recommendation
    string best_mandi
    string confidence_note
  }

Data flow (DFD Level 1)

flowchart TD
  ADM([Admin]) --> P1["1.0 Fetch and clean prices"]
  P1 --> D1[("D1 daily_prices")]
  D1 --> P2["2.0 Build features and train models"]
  P2 --> D2[("D2 forecast runs")]
  D2 --> P3["3.0 Generate advisory"]
  P3 --> D3[("D3 advisories")]
  USR([Farmer / trader]) --> P4["4.0 View dashboard"]
  D3 --> P4
  P4 -- "forecast, mandi ranking, advisory" --> USR

Modules

6 modules

  1. Module 01

    Data Acquisition & Storage (Member 1)

    A scheduled Python job calls the data.gov.in API for the Agmarknet mandi-price feed, with a CSV bulk-file fallback, validates schema and units, and upserts into normalised MySQL tables for commodities, mandis and daily prices. Idempotent re-runs and a fetch log make failures diagnosable.

  2. Module 02

    Cleaning & Exploratory Analysis (Member 2)

    Handles duplicate market-day rows, unit errors and missing days (flag or interpolate by a documented rule), then produces the EDA pack: seasonal decomposition, festival-month effects, arrival-price scatter plots and per-mandi volatility summaries used to justify modelling choices in the report.

  3. Module 03

    Feature Builder (Member 2)

    Creates, per commodity–mandi series, the lag features (1, 7, 14 days), 7/30-day rolling means and standard deviations, month and season dummies, and arrival-volume features — computed only from past values so that no look-ahead leakage enters training.

  4. Module 04

    Forecasting Model Suite (Member 3)

    Implements four trainers behind one interface: naive and 7-day moving-average baselines, SARIMA with seasonal order search, gradient-boosted trees on engineered features, and an LSTM on scaled windows; each trainer stores forecasts and hyperparameters as a versioned run in the database.

  5. Module 05

    Evaluation & Advisory Engine (Member 3, with Member 1)

    Runs walk-forward backtests with time-ordered splits, computes MAE, RMSE and MAPE per model and horizon, selects the best model per series, and applies the conservative sell/hold rule with a confidence note plus a mandi ranking that subtracts estimated transport cost per quintal.

  6. Module 06

    Flask Dashboard & Reports (Member 1)

    A responsive Flask application with role-checked admin pages (trigger fetch, retrain, edit advisory thresholds), public forecast charts with error bands, mandi comparison tables, model-metric pages and CSV export; Chart.js renders forecasts and Matplotlib PNGs feed the report.

Slides

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

  1. Slide 1

    Mandi Price Forecasting & Selling-Day Advisory

  2. Slide 2

    Introduction & Motivation

  3. Slide 3

    Problem Statement

  4. Slide 4

    Existing System vs Proposed System

  5. Slide 5

    Objectives

  6. Slide 6

    Dataset & Technology Stack

  7. Slide 7

    System Architecture

  8. Slide 8

    Database Design

  9. Slide 9

    Forecasting Models & Validation

  10. Slide 10

    Advisory Logic

  11. Slide 11

    Demo — Dashboard

  12. Slide 12

    Results Summary

  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 new in your project compared to just using Agmarknet or eNAM?

    Agmarknet and eNAM display current and historical prices but make no prediction and give no comparison. Our system adds a seven-day forecast per commodity–mandi series, a cross-mandi ranking net of transport cost, and a conservative advisory rule — all reproducible on public data with stored, versioned forecast runs, which is what a rate board cannot do.

  2. 02Concept

    Why is modal price your forecasting target instead of minimum or maximum price?

    The modal price is the price at which the largest traded volume happened on that market day, so it represents what a typical seller actually realises, whereas minimum and maximum are extremes driven by quality variation within the day. Forecasting the modal price therefore answers the farmer's real question better than the range would.

  3. 03Concept

    What is stationarity and why does it matter for SARIMA?

    A stationary series has a stable mean and variance over time, and ARIMA-family models assume it. We check it with the ADF test and apply differencing where needed, and SARIMA additionally removes a repeating seasonal pattern. Our price series are usually non-stationary, so we difference them and let the seasonal component capture weekly and monthly cycles before fitting.

+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

8 steps · complete source code · unlocks with the project

Unlocks with the project · ₹2,000

8 steps · source code zip

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

Unlock for ₹2,000

READMEFIRST

222 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

222 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

335 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

335 words · ~2 min read

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

Unlock for ₹2,000

References

9 sources

  1. Agmarknet — Directorate of Marketing & Inspection, Ministry of Agriculture & Farmers Welfare (daily mandi price portal)
  2. data.gov.in — Current Daily Price of Various Commodities from Various Markets (Mandi) dataset
  3. Hyndman, R.J. & Athanasopoulos, G., Forecasting: Principles and Practice, 3rd ed. (time-series cross-validation, ARIMA/SARIMA)
  4. scikit-learn Documentation — gradient boosting, pipelines and model evaluation
  5. statsmodels Documentation — SARIMAX and seasonal decomposition
  6. Keras Documentation — LSTM layers, windowed sequences and callbacks
  7. pandas Documentation — time-series indexing, resampling and rolling windows
  8. Flask Documentation — application factory, blueprints and configuration
  9. MySQL 8.0 Reference Manual — schema design, indexes and transactions

Cite this bundle

OnlyProjects. (2026). Mandi Price Forecasting & Selling-Day Advisory for APMC Markets (Python/ML): MCA AI & Machine Learning project bundle [Educational resource]. https://onlyprojects.online/projects/mca-aiml-mandi-price-forecasting

Future scope

1 min read

  • Add IMD rainfall and festival-calendar covariates, which are strong known seasonal drivers of vegetable prices.
  • Extend to more states and to eNAM data, and publish the advisory as a simple SMS or missed-call service for feature-phone users.
  • Weekly automated retraining with a job scheduler and model-drift alerts when MAPE degrades.
  • Prediction intervals instead of point forecasts, so the advisory can quote a price band.
  • A small trader module tracking actual realisations against advisory calls to measure real-world usefulness.

Keep browsing

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