MACHINE LEARNING-BASED CLASSIFICATION OF AGRICULTURAL COMMODITY PRICES: A COMPARATIVE STUDY OF RANDOM FOREST, LOGISTIC REGRESSION AND SUPPORT VECTOR MACHINE USING PAKISTANI MARKET DATA

Authors

  • Haroon Khan
  • Muhammad Ismail

Keywords:

Agricultural Economics, Crop Price Classification, Machine Learning, Random Forest, Support Vector Machine, Logistic Regression, Pakistan

Abstract

The price of crops and farm products depends on the time, market conditions, the volume of food produced, and the nature of the food purchased. An understanding of these prices is valuable for farmers, crop buyers and sellers, and the government and other students of farm economics when making decisions. The agricultural commodity prices are indeed significant. What farmers, traders, policy makers and agricultural economists need to know are these prices? The idea of this study is to determine agricultural commodity prices into 3 classes (Low, Medium and High) using machine learning technique considering the historical price data of the market in Pakistan. The data set includes over 411,000 valid observations from the Mango and Apple (Golden) markets in 138 cities over a 15-year period (2007-2022). First, continuous price values were converted into three balanced classes by using a quantile-based approach in order to formulate the classification task. Feature engineering techniques were used to create temporal features (year, month, and season) and numerical features for categorical features (crop type and city). Three supervised machine learning algorithms were trained and tested, namely: Random Forest, Logistic  Regression and Support Vector Machine (SVM). The data set was split into 80% training and 20% testing. The performance of the model was evaluated based on the standard evaluation metrics such as accuracy, precision, recall, F1-score and confusion matrix analysis. The results indicated that the Random Forest model performed better than the other models, with an accuracy of 81.78% and an F1 score of 0.8189. SVM and Logistic Regression had comparatively low predictive accuracy. The results show that using ensemble learning techniques to capture temporal and spatial changes in agricultural market data is more suitable. The agriculture sector can greatly benefit from machine learning applications in price analysis and market prediction, as shown in this study that demonstrates its applications in agriculture as proof of concept. The suggested framework offers valuable lessons in the designing of Data-driven Decision Support Systems (DDSS) to enhance the monitoring of crop prices, market intelligence and agricultural policy making in Pakistan.

Downloads

Published

2026-06-20

How to Cite

Haroon Khan, & Muhammad Ismail. (2026). MACHINE LEARNING-BASED CLASSIFICATION OF AGRICULTURAL COMMODITY PRICES: A COMPARATIVE STUDY OF RANDOM FOREST, LOGISTIC REGRESSION AND SUPPORT VECTOR MACHINE USING PAKISTANI MARKET DATA. Spectrum of Engineering Sciences, 4(6), 2030–2039. Retrieved from https://thesesjournal.com/index.php/1/article/view/3280