The main staple crop in Lesotho (a country in southern Africa) is maize, but its production is extremely susceptible to unpredictable rainfall, temperature fluctuations, deficiencies in soil moisture, and frequent foliar disease pressure. As a result, smallholder farming households have ongoing yield shortfalls and food insecurity. The design, implementation, and assessment of a web-based decision-support system that uses supervised machine learning to forecast maize production and categorize disease risk using soil and climate data are presented in this study. Eight environmental and agronomic predictors: rainfall, temperature, relative humidity, soil moisture, cultivated area, week number, year, and administrative district, were used to independently train two Ordinary Least Squares (OLS) linear regression models on historical agricultural and environmental data spanning 40 years. Because of its interpretability, computational efficiency, and adaptability for implementation in environments with limited resources, linear regression was chosen. The system supports both single-record and bulk CSV prediction workflows and was built using a Flask (Python) backend, a Bootstrap 5 responsive frontend, a SQLite database for permanent storage, and Chart.js for dashboard analytics. The illness risk model had an R² of 0.76 and an RMSE of 0.10 across three interpretable risk categories (low, medium, and high), but the yield prediction model obtained a coefficient of determination (R²) of 0.88 and an RMSE of 2.09. Functional testing verified dependable performance in dashboard, storage, reporting, and prediction processes. The findings show that in data-poor agricultural settings like Lesotho, interpretable machine learning models may provide affordable, easily accessible decision assistance for early disease risk awareness and maize production planning.
Introduction
This study develops a web-based machine-learning decision-support system for maize yield and disease-risk prediction in Lesotho. Agriculture is central to Lesotho's economy and food security, with maize being the country's main staple crop. However, maize production is largely rain-fed and affected by high-altitude conditions, soil degradation, unreliable rainfall, climate shocks, and fungal diseases such as northern corn leaf blight and gray leaf spot. Domestic production is insufficient to meet national demand, contributing to persistent food insecurity.
The main problem identified is the lack of a locally calibrated, data-driven forecasting system for maize yield and disease risk. Farmers and policymakers largely depend on expert judgment, generalized regional information, and retrospective surveys. The proposed system addresses this gap by using supervised linear regression to generate both quantitative maize-yield predictions and categorical disease-risk assessments.
Related Work
Previous studies have demonstrated the usefulness of machine learning for agricultural yield and disease prediction. Models combining climate, soil, and other environmental data generally perform better than models using a single data source. Studies have also shown that linear and regularized regression methods can provide a good balance between accuracy, interpretability, and computational efficiency, which is particularly important in data-scarce regions such as Lesotho.
Climate-based regression has also been successfully applied to crop disease forecasting. However, according to the study, there was no existing system specifically developed for Lesotho's maize sector that simultaneously predicts yield and disease risk and makes these predictions available through a deployable web platform.
Data and Input Variables
The research focuses on Lesotho's lowland agro-ecological zone, where maize is commonly cultivated. Historical agricultural and environmental data covering approximately 40 years were compiled and processed.
Eight input variables were selected:
Rainfall – cumulative rainfall in mm
Temperature – mean air temperature
Relative humidity – average humidity percentage
Soil moisture – volumetric soil moisture content
Cultivated area – land area used for maize production
Week number – agricultural week of the season
Year – calendar year
District – administrative district of observation
Both the yield and disease-risk models use the same feature set.
Model Development
Two independent Ordinary Least Squares (OLS) multiple linear regression models were developed:
A maize yield model predicting grain yield.
A disease-risk model predicting a continuous disease-risk score.
Linear regression was selected because it is simple, interpretable, computationally efficient, and suitable for environments with limited data and computing resources.
The disease-risk score is converted into a percentage and classified into three easily understandable categories:
Low risk
Medium risk
High risk
Model performance was evaluated using Root Mean Squared Error (RMSE) and R² (coefficient of determination).
Web-Based System
The prediction models were integrated into a full-stack web application using:
Python and Flask for the backend.
HTML5, CSS3, Bootstrap 5, and JavaScript for the responsive frontend.
SQLite for storing prediction data and metadata.
Chart.js for administrative dashboards and visualizations.
The platform provides two prediction modes:
Single-record prediction: Users manually enter the eight variables and immediately receive maize yield and disease-risk predictions.
Bulk prediction: Users upload a CSV file containing multiple observations. The system validates the data, applies both models, and generates a downloadable results file.
Predictions are stored in the database for historical analysis. Administrators can also view weekly, annual, and district-level trends through dashboards, while farmers and extension workers can access the prediction interface without logging in.
Results
The maize yield model performed strongly, achieving:
R² = 0.88
RMSE = 2.09
This means that the selected environmental and agricultural variables explain approximately 88% of the variation in observed maize yield.
The disease-risk model achieved:
R² = 0.76
RMSE = 0.10
Although its performance was lower than the yield model, it still provides useful predictive capability. The lower accuracy is attributed to the complexity of plant disease development. Important factors such as pathogen inoculum levels, crop variety susceptibility, and farm management practices were not included in the available dataset.
Conclusion
A web-based system for predicting maize yield and disease risk for Lesotho was designed, implemented, and evaluated in this work. It is based on two interpretable OLS linear regression models that use a common set of eight meteorological, soil, and agronomic factors. Using a tri-level risk categorization system, the illness risk model obtained good accuracy (R² = 0.76, RMSE = 0.10), while the yield model produced excellent predictive accuracy (R² = 0.88, RMSE = 2.09). Functional testing verified dependable functioning across all assessed processes. The system was constructed as a full-stack Flask, SQLite, and Bootstrap 5 application enabling both single-record and bulk CSV prediction, supported by an interactive Chart.js analytics dashboard.
The findings show that accessible, computationally light machine learning models can provide actionable predictive insights without requiring substantial computational resources or specialized end-user expertise when combined with appropriate web and database infrastructure. This directly addresses the needs of food security and agricultural productivity monitoring in a data-scarce environment like Lesotho.
Future research will concentrate on (i) assessing ensemble and non-linear methods, such as Random Forest, Gradient Boosting, and Artificial Neural Networks, to capture non-linear predictor interactions; (ii) integrating real-time
meteorological data through weather APIs to eliminate manual data on additional staple crops relevant to Lesotho\'s agricultural sector, such as wheat and sorghum entry; (iv) creating a companion mobile application to enhance accessibility for smallholder farmers in rural regions using spatially explicit Geographic Information System (GIS) capabilities; and (v) expanding the framework.
References
[1] CIMMYT, Maize in Sub-Saharan Africa: Opportunities and Challenges. Nairobi: International Maize and Wheat Improvement Center, 2019.
[2] J. Verschuur, S. Li, P. Wolski, and F. E. L. Otto, \"Climate change as a driver of food insecurity in the 2007 Lesotho–South Africa drought,\" Scientific Reports, vol. 11, p. 3032, 2021.
[3] J. E. Cairns et al., \"Maize production in a changing climate: Impacts, adaptation, and mitigation strategies,\" Advances in Agronomy, vol. 114, pp. 1–58, 2013.
[4] S. Zingore, H. K. Murwira, R. J. Delve, and K. E. Giller, \"Soil type, management history and current resource allocation: Three dimensions regulating variability of maize yields and nutrient use efficiencies on smallholder farms in Zimbabwe,\" Field Crops Research, vol. 101, no. 3, pp. 296–305, 2011.
[5] T. Van Klompenburg, A. Kassahun, and C. Catal, \"Crop yield prediction using machine learning: A systematic literature review,\" Computers and Electronics in Agriculture, vol. 177, p. 105709, 2020.
[6] J. H. Jeong et al., \"Random forests for global and regional crop yield predictions,\" PLOS ONE, vol. 11, no. 6, p. e0156571, 2016.
[7] Y. Cai et al., \"Integrating satellite and climate data to predict wheat yield in Australia using machine learning approaches,\" Agricultural and Forest Meteorology, vol. 274, pp. 144–159, 2019.
[8] J. M. J. Ward, F. W. Nutter, and P. D. Esker, \"Gray leaf spot of corn: A review,\" Plant Disease, vol. 96, no. 10, pp. 1369–1382, 2012.
[9] P. Battilani et al., \"Aflatoxin B1 contamination in maize in Europe increases due to climate change,\" Scientific Reports, vol. 6, p. 24328, 2016.
[10] A.-K. Mahlein, T. Rumpf, P. Welke, H.-W. Dählein, L. Plümer, U. Steiner, and E.-C. Oerke, \"Development of spectral indices for detecting and identifying plant diseases via hyperspectral imaging,\" Computers and Electronics in Agriculture, vol. 121, pp. 57–65, 2016.
[11] D. K. Ray, J. S. Gerber, G. K. MacDonald, and P. C. West, \"Climate variation explains a third of global crop yield variability,\" Nature Communications, vol. 6, p. 5989, 2015.
[12] K. Kuwata and R. Shibasaki, \"Estimating crop yields with deep learning and remotely sensed data,\" in Proc. IEEE Int. Geoscience and Remote Sensing Symp. (IGARSS), 2015, pp. 858–861.
[13] P. Roudier, B. Sultan, P. Quirion, and A. Berg, \"The impact of future climate change on West African crop yields: What does the recent literature say?,\" Global Environmental Change, vol. 21, no. 3, pp. 1073–1083, 2011.