MACHINE LEARNING BASED CROP PRICE PREDICTION AND MARKET TREND ANALYSIS USING PYTHON
DOI:
https://doi.org/10.64751/ee4ans24Abstract
Agricultural commodity prices in Indian markets change from day to day and from one market yard to another, and these changes directly affect the income of farmers, the cost of food for consumers, and the planning of traders and storage operators. A farmer who sells tomatoes or onions on the wrong day can receive a price far below what was available a week earlier or later. This paper presents a machine learning based crop price prediction and market trend analysis system developed in Python that forecasts short-term modal prices for selected crops and presents market trends in a form that can be understood without technical training. The system uses historical daily arrival and price records published for regulated agricultural markets, covering the minimum, maximum, and modal price along with the quantity of produce that arrived on each day. These records are combined with rainfall and temperature data for the growing districts and with a calendar of festivals and harvest seasons. The raw data contains missing days, market holidays, spelling differences in crop and variety names, and occasional entry errors, so a preprocessing stage standardises names, removes impossible values, fills short gaps, and aligns all sources to a common daily index. Feature engineering converts the cleaned data into inputs that describe recent market behaviour. Lagged prices, rolling averages over one, two, and four weeks, arrival volume and its change, month and week of the year, and rainfall accumulated over the growing period are computed for each crop and market. Several regression models are then trained and compared, including Linear Regression, Random Forest, Gradient Boosting, XGBoost, and a seasonal ARIMA baseline. The models are evaluated with a time-ordered split so that the test period always lies after the training period, and performance is measured using RMSE, MAE, MAPE, and the coefficient of determination. The results show that tree-based ensemble models, particularly Gradient Boosting and XGBoost, predict next-week modal prices more accurately than the linear and ARIMA baselines, with arrival quantity and recent price lags being the most influential features. A web dashboard built with Streamlit allows the user to select a crop and market, view past prices with seasonal patterns highlighted, see the forecast for the coming days with an uncertainty band, and compare prices across nearby markets to identify where selling may be more profitable.
Downloads
Published
Issue
Section
License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.







