Forecasting Agricultural Output Using Machine Learning Approach Based on Random Forest Algorithm: How Important are Environmental and Climate Variables?

Samuel Chibuzor Umeh*, Olushina Olawale Awe & Kehinde Blessing Faloni

*Faculty of Economics and Business, Universidad del País Vasco/Euskal Herriko Unibertsitatea, Bilbao, Spain.

Many researchers have worked on the nexus between agricultural output, climate, and environmental variables in recent times due to the high importance of food security. However, many of the traditional econometric models used are unable to forecast agricultural output with high accuracy. In this study, we examine the forecasting performance of the random forest machine learning algorithm and compare its predictive performance with other machine learning algorithms like K Nearest Neighbourhood (KNN), Support Vector Machine (SVM), Decision Tree (DT), Robust Linear Model (RLM), Random Forest (RF), and Least Angle Regression (LARS) using data from Africa´s largest economy, Nigeria. The result shows that the random forest machine learning algorithm outperforms other machine learning algorithms because it has the lowest Root Mean Square Error (RMSE) of 3500.989 followed by LARS with an RMSE of 3524.157, SVM with RMSE of 3756.603, DT with RMSE of 3863.969, RLM with RMSE of 4032.575 and KNN algorithm with RMSE of 5524.410. Variable importance result shows that temperature is the best predictor of agricultural output in Nigeria followed by CO2 emissions while rainfall has no effect on agricultural output. The correlation plot shows that agricultural output has a strong positive relationship with temperature, a weak positive relationship with rainfall, and a strong negative relationship with CO2 emissions. Therefore, climate-smart agricultural practices, climate education especially for farmers, and carbon neutrality or reduction policies together with research and development should be adopted by the government and policymakers to ensure agricultural sustainability and food security in Nigeria and other developing countries.

Keywords: Forecasting, Machine learning, Random Forest, Climate change, Agricultural Output, Food security