Crop Yield Prediction Using Machine Learning and Weather Data: A Python-Based Approach
Abstract
Agriculture remains a critical sector for global food security, yet crop productivity is increasingly influenced by volatile climatic conditions and resource constraints. Accurate crop yield prediction plays a vital role in enhancing decision-making for farmers, agronomists, and policymakers. This paper presents a machine learning-based approach for crop yield prediction using historical weather patterns, soil data, and crop-specific variables. Leveraging publicly available datasets, various regression models—including Linear Regression, Random Forest Regressor, and XGBoost—were implemented and evaluated using Python. Feature engineering was employed to extract meaningful insights from variables such as rainfall, temperature, soil type, fertilizer usage, and crop type. The models were trained and tested to predict yield with respect to specific crops across multiple seasons. Performance metrics such as R² score, RMSE, and MAE were used to compare model effectiveness. Among the models evaluated, ensemble-based methods demonstrated superior accuracy and robustness. The proposed system showcases the potential of machine learning techniques to provide actionable insights in agricultural planning and risk management, especially in resource-constrained environments.
Fields of Study & Subjects
Smart Agriculture and AI
Climate change impacts on agriculture
Remote Sensing in Agriculture
Publication details
- Journal / source
- Zenodo (CERN European Organization for Nuclear Research)
- Publication date
- 27 January 2026