Evaluating machine learning algorithms for predicting maize yield under conservation agriculture in Eastern and Southern Africa

Abstract

Crop simulation models are widely used as research tools to explore the impact of various technologies and compliment field experimentation. Machine learning (ML) approaches have emerged as promising artificial intelligence alternative and complimentary tools to the commonly used crop production models. The study was designed to answer the following questions: (a) Can machine learning techniques predict maize grain yields under conservation agriculture (CA)? (b) How close can ML algorithms predict maize grain yields under CA-based cropping systems in the highlands and lowlands of Eastern and Southern Africa (ESA)? Machine learning algorithms could predict maize grain yields from conventional and CA-based cropping systems under low and high potential conditions of the ESA region. Linear algorithms (LDA and LR) predicted maize yield more closely to the observed yields compared with nonlinear tools (NB, KNN, CART and SVM) under the conditions of the reported study. However, the KNN algorithm was comparable in its yield prediction to the linear tools tested in this study. Overall, the LDA algorithm was the best tool, and SVM was the worst algorithm in maize yield prediction. Evaluating the performance of different ML algorithms using different criteria is critical in order to get a more robust assessment of the tools before their application in the agriculture sector.

Introduction

Crop simulation models are widely used as research tools to explore the impact of various technologies under different biophysical and socio-economic conditions [18, 38]. The use of modelling tools complements field experiments conducted over a short period of time, saves time and financial resources and allows for extrapolation of experimental results to other biophysical and socio-economic conditions [22, 31]. Additionally, simulation models aid in identifying knowledge gaps, testing hypotheses, designing new experiments and determining the most influential factors in farming systems of interest [21, 40].

Various crop simulation models have been developed, tested and applied for different purposes in agricultural research and development of farming systems. Models widely used to better understand smallholder cropping systems in sub-Saharan Africa (SSA) include, among others, APSIM, DSSAT, Aqua-Crop, Patched-Thirst and SOYGRO [31]. These models have been used to increase understanding of the impacts of different management practices and climate change and variability on farm productivity and resilience, and resilience of smallholder farming systems [10]. The use of these tools has been constrained by several challenges including availability of data required to parameterize, calibrate and validate the models before their application, and lack of skills to fully include modelling tools in research and development of smallholder agriculture in SSA [30, 31]. Reliable climate and soil data are major limitations to the application of some of these tools in different parts of SSA [49, 52].

Machine learning (ML) approaches have emerged as promising alternative and complimentary tools to the commonly used crop production modelling [11, 27, 33]. The ML approaches are increasingly being applied in crop production research compared to other study areas such as soil and water management and livestock production in agriculture [27]. In crop production, ML tools have been applied predominantly for yield prediction and disease detection in cropping systems. The ML techniques can be used for crop yield prediction at different scales such as local, regional and country levels [25]. Machine learning is an application of artificial intelligence that enables a system to learn from examples and experience without explicit programming. Machine learning comprises of a category of algorithms that allows software applications to become more accurate in predicting outcomes from systems of interest in research [11, 43]. The basic premise of ML is to build algorithms that can receive input data and use statistical analysis to predict an output while updating outputs as new data become available. The advantages of ML include extracting/entangling more knowledge and picking/identifying trends from big data sets [50]. Additionally, ML algorithms can continuously be improved and hence increase prediction efficiency, and ML can be applied in different fields including agriculture [3]. Machine learning tools allow learning of useful complex relationships in a big data set [15]. Additionally, ML approach fills the gap when required data sets for biophysical modelling are not available [50], a situation which is often common in SSA [49, 52]. Given the increasing pressure from emerging pests such as the fall armyworm [5], ML techniques can play a critical role in forecasting pest attack incidences, giving farmers an opportunity to prepare control measures well in advance [1, 33].

Machine learning techniques available for use in agriculture include regression, fuzzy cognitive map learning, artificial neural networks, CART, KNN, random forest and SVM [6, 25, 33]. The different ML techniques vary in their accuracy levels, and selection of an algorithm to use is a critical first step. The performance of selected algorithms depends on various aspects including size of the data set used, experimental noise and errors in data collection, among others [13]. Comparing artificial neural network and multiple linear regression, [25] revealed that the former predicts maize (Zea mays L.) and soybean (Glycine max L.) yields better at local and regional levels compared with the regression approach.

This study was designed to explore the use of ML techniques in predicting maize yields from different CA-based cropping systems under highland and lowland conditions of Eastern and Southern Africa (ESA). The study questions were (a) Can ML techniques be used to predict maize grain yields? (b) How close can ML algorithms predict maize grain yields under CA-based cropping systems in the highlands and lowlands regions of ESA? (c) Which algorithm(s) predict(s) maize grain yields better than others? The specific objectives were to (a) derive a palpable ML-based system of differentiating maize grain yields according to cropping systems with respect to agro-ecology, (b) evaluate the accuracy and precision of ML algorithms in predicting maize yields from different cropping systems under two agro-ecological regions, and (c) evaluate the best ML algorithm for modelling the performance of CA-based cropping systems.

Materials and methods

Description of cropping systems simulated

Conservation agriculture-based maize-legume cropping systems were tested for seven years in five countries of the ESA region, namely Ethiopia, Kenya, Tanzania, Malawi and Mozambique. The maize-legume combinations included sole, intercropping and rotation systems where common bean (Phaseolus vulgaris (L.)), cowpea (Vigna unguiculata (L.) Walp), desmodium, groundnut (Arachis hypogaea L.), pigeon pea (Cajanus cajan (L.) Millsp) and soybean (Glycine max (L.) Merr.) were the legume species grown. The CA systems tested included planting basins, dibble stick, ripping and permanent ridges. The conventional ploughing system was used as the control treatment in all years at all sites. The experiments have been described in detail [28, 29, 32, 35, 39]. Table 1 summarizes experimental treatments and cropping systems used over the 7-year period of experimentation. The location and rainfall ranges of study countries in Eastern and Southern Africa are shown in Fig. 1.

Table 1 Conservation agriculture-based tillage techniques, cropping systems and legume species used in different project locations (2010–2017)
Fig. 1
figure1

Location and rainfall ranges of trial sites in the different project countries between 2010 and 2016

Creation of a validation data set and test harness

Cross-validation (rotation estimation) or out-of-sample testing is a model validation technique or procedure for assessing how the results of an algorithm or statistical analysis will generalize to an independent data set [19]. Maize yield data collected over seven years from multi-country and multi-site were used in this ML study. From this dataset, 80% of it was used for training the selected algorithms and 20% was used to validate the trained ML tools. The algorithms were given a set of known maize yield data on which training was run (training the dataset), and a dataset of unknown data (or first seen data) against which the algorithms were tested (called the validation dataset or testing set). Cross-validation was used to test the algorithms’ ability to predict new data that were not part of estimating it, in order to flag problems such as overfitting or selection bias [12] and to give an insight on how the algorithms will generalize to an independent dataset (an unknown dataset).

A tenfold cross-validation was used to estimate accuracy. The procedure separated the data set into 10 parts, train and test on 1, and the procedure was repeated for all the combinations of train–test splits. The metric of accuracy was used to evaluate the algorithms. This was a ratio of the number of correctly predicted instances divided by the total number of instances in the data set multiplied by 100 to give a percentage. Scoring variable was used to run, build and evaluate each model next [2].

Building algorithms

The data were labelled or classified into two agro-ecologies (highlands and lowlands), and this suggested the implementation of supervised linear and nonlinear class of ML algorithms [51]. The algorithms selected were linear algorithms (logistic regression (LR)) and linear discriminant analysis (LDA) as well as nonlinear algorithms [K-nearest neighbour (KNN), classification and regression trees (CART), Gaussian naive Bayes (NB) and support vector machine (SVM)]. The main analysis was done in Python version 3 using the sklearn package, and the plots were done in R version 3.6.1 using the ggplot2 package. The algorithm codes used are given in supplementary Table 1.

Six algorithms, which are divided into two major classes, linear and nonlinear, were selected. This was a good mixture of simple linear (LR and LDA) and nonlinear (KNN, CART, NB and SVM) algorithms. The random number seed was maintained at initial state before each run to ensure that the evaluation of each algorithm was performed using the same data splits. It ensured the results were directly comparable.

Description of the algorithms

  1. (a)

    Linear Algorithms

  2. 1.

    Logistic Regression (LR)

Logistic regression algorithm in ML was borrowed from the general logistic regression model in statistics [26]. In modelling yield from cropping systems based on agro-ecology (highlands and lowlands), the logistic function was evaluated as follows:

$$P(\text{agroecology}_\text{highlands}=\text{highlands|cropping systems (conventional,CA sole,CA intercrop and CA rotation)}$$
(1)
$$P({\text{agroecology}_\text{lowlands}})=\text{lowlands|cropping systems (conventional,CA sole,CA intercrop and CA rotation)}$$
(2)

In this case, we were modelling the probability that an input (X) (yield of four different cropping systems) belongs to the class \((Y=1(\mathrm{highlands})\), and we can write this formally as:

$$P(X) = P(Y=1|X).$$
(3)

Logistic regression algorithm (LR) was used as a classification method (linear method), but the predictions were transformed using the logistic function [26]. The function can be stated as follows:

$$p(X) = {e}^{\frac{{\beta }_{0}+{\beta }_{1}*X}{1+{e}^{{\beta }_{0}+{\beta }_{1}*X.}}}$$
(4)
  1. 2.

    Linear discriminant analysis (LDA)

LDA makes predictions by estimating the probability that a new set of inputs belongs to each class. The class that gets the highest probability is the output class, and a prediction is made. The model uses Bayes theorem to estimate the probabilities [42]. Briefly, Bayes’ theorem can be used to estimate the probability of the output class [k (agro-ecology)] given the input x [(cropping systems)] using the probability of each class and the probability of the data belonging to each class:

$$P(Y=x|X=x) = (PIk * fk(x))/{s}{u}{m}(PIl * fl(x)),$$
(5)

where \(PIk\) refers to the base probability of each class (k) observed in the training data (e.g. 0.5 for a 50–50 split in a two-class problem). In Bayes’ theorem, this is called the prior probability.

$$PIk = nk/n$$
(6)

The f(x) above is the estimated probability of x belonging to the class. A Gaussian distribution function is used for f(x). Plugging the Gaussian distribution function into Eq. 6 leads to Eq. 7. This is called a discriminate function, and the class is calculated as having the largest value will be the output classification (y):

$$Dk(x) = x * (muk/siga^{2} ) - (muk^{2} /(2 * sigma^{2} )) + {\text{ln}}(PIk)$$
(7)

\(Dk(x)\) is the discriminate function for class k given input x, the muk, sigma^2 and PIk are all estimated from the data.

  1. (b)

    (b) Nonlinear algorithms

    K-Nearest neighbour (KNN)

KNN makes predictions using the training dataset directly. Predictions are made for a new instance (x) by searching through the entire training data set for the K most similar instances (the neighbours) and summarizing the output variable for those K instances [46]. For regression, this might be the mean output variable, and in classification, this might be the mode (or most common) class value. To determine which of the K instances in the training dataset are most similar to a new input, a distance measure is used. For real-valued input variables, the most popular distance measure is the Euclidean distance [34]. Euclidean distance is calculated as the square root of the sum of the squared differences between a new point \((x)\) and an existing point \((xi)\) across all input attributes.

$${\text{Euclidean}}\, {\text{Distance}}(x,x_{i}) = \sqrt {(sum((x_{j} ,x_{ij})^{2}))}$$
(8)
  1. (c)

    Classification and Regression Trees (CART)

Classification and regression tree (CART) is a predictive algorithm used in machine learning. It explains how a target variable’s values can be predicted based on other values. The CART algorithm is an important decision tree algorithm that lies at the foundation of ML. Moreover, it is also the basis for other powerful ML algorithms like bagged decision trees, random forest and boosted decision trees [8].

  1. 3.

    Gaussian Naive Bayes (NB)

It is a probability ML algorithm which is used in multiple classification tasks [4]. Bayes rule determines the probability of \(Z\) (cropping systems) over given \(W (\text{Agroecology})\). Now when it comes to the independent feature, the naive Bayes algorithm becomes a better choice. The algorithm is called naive because it considers \(Ws\) are independent of one another. In the case of multiple \(Z\) variables, we will assume that \(Z's\) are independent. The Bayes rule will be

$$P(W=k | Z) = P(Z | W=k) * P(W=k) / P(Z)$$
(9)

K is a class of W. The naive Bayes will be:

$$P(W=k | Z1\dots .Zn) = P(Z1 |W=k )* P(Z2 |W=k )\dots * P(Zn |W=k ) * P(W=k) / P(Z1)* P(Z2)\dots .*P(Zn)$$
(10)

which we can say:

$$P (\text{Outcome | Evidence}) = \text{Likelihood probability of evidence * prior / Evidence probability}$$
(11)
  1. 4.

    Support Vector Machine Algorithm

A support vector machine (SVM) is a classifier that is defined using a separating hyperplane between the classes (highland and lowland). This hyperplane is the N-dimensional version of a line. Given the labelled training data and the binary classification problem [23], the SVM finds the optimal hyperplane that separates the training data set into two classes. This can easily be extended to the problem with N classes. In the study, two-dimensional case with two classes of points was considered. Given the 2D, the points were dealt with in a 2D plane. This was easier to visualize then vectors and hyperplanes in a high-dimensional space.

Selection of the best algorithms

The six algorithms estimation and accuracy were evaluated in order to select the most accurate one. A population of accuracy measures were obtained for each algorithm as they were evaluated 10 times (tenfold cross-validation). Two major statistics, accuracy and kappa statistic, for selecting the best algorithm were traced.

Accuracy

The set of data points is said to be precise if the values are close to each other, while the set is regarded as accurate if its average is close to the true value of the quantity being measured [34]. In the first more common definition above, the two concepts are independent of each other, so a particular data set is said to be either accurate or precise, or both, or neither.

Cohen’s Kappa statistic

Cohen’s kappa statistic measures inter-rater reliability (sometimes called inter-observer agreement). The kappa statistic varies from 0 to 1, where.

  1. (a)

    0 = agreement equivalent to chance.

  2. (b)

    0.1–0.20 = slight agreement.

  3. (c)

    0.21–0.40 = fair agreement.

  4. (d)

    0.41–0.60 = moderate agreement.

  5. (e)

    0.61–0.80 = substantial agreement.

  6. (f)

    0.81–0.99 = near perfect agreement

  7. (g)

    1 = perfect agreement.

Predictions

This was used as an independent final check on the accuracy of the ideal model. It was valuable to keep a validation set just in case of making a slip during training, such as overfitting to the training set or a data leak. Both may result in an overly optimistic result [20]. The best algorithm was run directly on the validation data set and summarizes the results as a final accuracy score, a confusion matrix and a classification report. The accuracy of the algorithm was investigated, with a value of above 60% regarded as ‘good’, an indication of the three errors made. Finally, the classification report provided a breakdown of each class by precision, recall, f1-score and support, showing excellent results (granted the validation dataset was small).

A confusion matrix is a figure or a table that was used to describe the performance of a classifier [24]. It was extracted from a test dataset for which the ground truth was known. Each class was compared with every other class and investigated how many samples were misclassified. The agro-ecology was considered as a binary classification case with the output 0 (lowlands) and 1 (highlands). The performance of a classifier was investigated using the confusion matrix. Classifier report was presented in matrix form; the first diagonal entries represent true positives (the samples for which the algorithm predicted 1 as the output and the ground truth was 1 too) and true negatives, respectively, the samples for which the algorithms predicted 0 as the output and the ground truth was 0 too.

  • True positives These were the samples for which the algorithm predicted 1 as the output and the ground truth was 1 too.

  • True negatives These were the samples for which the algorithms predicted 0 as the output and the ground truth was 0 too.

  • False positives These were the samples for which the algorithms predicted 1 as the output, but the ground truth was 0. This is also known as a Type I error.

  • False negatives These were the samples for which the algorithms predicted 0 as the output, but the ground truth was 1. This is also known as a Type II error.

Results

Performance of different cropping systems in lowlands and highlands

The effects of different cropping systems on maize grain yield are summarized in Table 2. In highlands, CA-sole, CA-intercrop and CA-rotation had 3 655, 2 755 and 3 545 kg ha−1 maize yield than 2 509 kg ha−1 from the conventional practice. In the lowlands, CA-sole, CA-intercrop and CA-rotation had 2 421, 3 062 and 3 209 kg ha−1 compared with 2 421 kg ha−1 of the conventional practice.

Table 2 Descriptive statistics for the effects of different cropping systems on maize grain yield (kg ha−1) under highlands and lowlands of ESA

Mean differences of cropping systems were assessed using the t test (Table 3). Conventional systems’ yield in both agro-ecologies was insignificant (P = 0.567). The mean yield difference of CA-rotation and CA-sole was significant (P = 0.000 and P = 0.046, respectively) as the cropping systems performed better in high-rainfall areas compared to the lowland areas. The results also indicated that CA intercrop performed better in lowlands than highlands as the mean difference was negative and the probability value was not significant (P = 0.067).

Table 3 Maize yield differences from different cropping systems in highlands and lowlands of ESA

Maize yield prediction by linear and nonlinear algorithms

The regression classification tree was used to extract more information about which cropping system was predicted to yield better in both agro-ecologies (Fig. 2). Cropping systems were categorized into 17 nodes with respect to agro-ecologies. In node 1, most of the CA intercrop yields were predicted to be from highlands compared to the lowlands. Conservation agriculture with sole maize (CA-sole) was categorized in node 6 which was further divided into node 7 and node 8 (n = 44 and n = 7, respectively), and most of the yields were classified under highlands in node 7. However, 60% of the predicted yields under node 8 were classified as lowland yields. Conservation agriculture with (CA-rotation) was classified at node 17 which was split into node 17 with most of the predicted yields (65%) identified as lowland yields. The conventional system had most of its predicted yield classified as from the lowlands (60%) compared to the highlands. Overall, the regression tree classification model managed to allocate the predicted yields to their respective agro-ecologies.

Fig. 2
figure2

Prediction of maize yields in different cropping systems in the highlands and lowlands of ESA. CA_sole: Conservation agriculture sole maize cropping, CA_inter: conservation agriculture maize-legume intercropping, CA_rot: conservation agriculture maize-legume rotation, Conv: conventional practice

Prediction power of algorithms in predicting maize yield

Linear discriminant algorithm (LDA) had the highest prediction power compared to the other algorithms (Fig. 3). The naïve Bayes and logistic regression algorithms had similar prediction power. The KNN and CART had the lowest accuracy compared with the other algorithms, while the SVM algorithm had the lowest prediction power. In general, the linear algorithms performed better in predicting maize yield under different cropping systems (LDA and LR) than the nonlinear tools. For the nonlinear algorithms, the naïve Bayes (NB), which is a parametric model, was better than the regression tree algorithm (CART) and neighbour classifier (KNN).

Fig. 3
figure3

Comparison of linear and nonlinear algorithms in predicting maize yield across four cropping systems in ESA. LR = Logistic regression algorithm, LDA = linear discriminant analysis algorithm, kNN = neighbour classifier algorithm, CART = regression tree algorithm, NB = naïve Bayes algorithm and SVM = support vector machine algorithm

Accuracy and precision of different algorithms in predicting maize yield

The algorithms accuracy was further investigated using the accuracy statistic and the Cohen kappa statistic which measures the reliability of the prediction power (Table 4). The accuracy confirmed the trend observed in Fig. 3. Linear discriminant algorithm had an accuracy of 61% which was greater than all the other algorithms. Its corresponding kappa statistic suggested a fair accuracy as it was approximately equal to 0.1 and falls in the range 0.1–0.2. The LR and NB algorithms also scored better accuracy, and their corresponding kappa statistics were approximately equal to 0.1. The KNN and CART had a fair performance which was better than the SVM. In general, all the linear algorithms accurately predicted the maize yield from cropping systems with respect to agro-ecologies. The nonlinear algorithms also performed well except the SVM algorithm which indicated an accuracy of less than 50%. The LR, LDA and NB recorded better final accuracy compared to the other algorithms (KNN, CART and SVM) (Table 5).

Table 4 Algorithms evaluation based on accuracy and kappa statistic
Table 5 Final algorithm accuracy for maize yield prediction under highlands and lowlands in ESA

Randomness was used to facilitate the learning of algorithms to be more robust and ultimately results in better predictions and more accurate models (Table 6). The LR, LDA and KNN had good final accuracy in the highlands. In lowlands, they were better with precisions increased for LR, LDA and KNN algorithms compared with the highlands. The CART and NB also had significant improvement in precision in lowlands compared to the SVM which had zero precision in lowlands.

Table 6 Final accuracy score for maize yield prediction from highlands and lowlands in ESA
Table 7 Comparison of the different algorithms using the confusion matrix

The cross-validation percentages were increased to 100%, and the accuracy of the algorithms was traced. An algorithm which gives better precision under the lowest percentage of cross-validation data set is considered good. Results in Fig. 4 showed the estimated accuracy trend of the six algorithms. When less than 25% of cross-validation data set was used, the LDA, LR and NB had an excellent accuracy power, and as the cross-validation increased, the accuracy of the three algorithms fluctuated between 50 and 65%. As cross-validation was increased to 100%, some algorithms which were poor when only less than 25% was used for the cross-validation data set, started to give better accuracy. The corresponding kappa statistic of the algorithm was improving significantly as the cross-validation data set improved to 90%, but when it reached 100%, it dropped significantly. The LDA, LR and NB maintained the same trend under the kappa statistic as they were showing better improvements under the kappa statistic compared to other algorithms.

Fig. 4
figure4

Accuracy and precision of different algorithms in predicting maize yield as cross-validation is increased to 100%. LR = Logistic regression algorithm, LDA = linear discriminant analysis algorithm, KNN = neighbours classifier algorithm, CART = regression tree algorithm, NB = naïve Bayes algorithm and SVM = support vector machine algorithm

Incorrect predictions were shown in the second diagonal entries (false positives or type one error and false negatives, respectively, or type two error). Linear discriminant algorithm had 28 true positives and 33 true negatives, and the committed errors were less than the predicted truth. The KNN classified 30 true positives and 35 true negatives, and only 19 were classified as type one and two errors. The SVM identified only 49 true positives, and nothing was determined as true negatives. Logistic regression algorithm had 28 predictions recognized as true positives and the corresponding 32 predictions which were accurately predicted as true negatives. Naïve Bayes algorithm accurately predicted 24 as true positives and 34 as true negatives with 25 false positives and 20 false negatives. The CART algorithm made 23 predictions which were recognized as true positives and 32 which were recognized as true negatives. However, the algorithm committed type one and type two errors in the prediction process as 26 predictions were false positives and 22 were false negatives. In general, the highest number of correct predictions was recorded with LDA, KNN and LR algorithms (Table 7).

Discussion

Maize yield prediction by linear and nonlinear algorithms

Linear and nonlinear algorithms could predict maize yield from different cropping systems across the agro-ecologies, though with varying degrees of accuracy and precision. Yield distribution patterns showed the lack of normality across the two agro-ecologies. Picking the variability trends in the yield data is critical as it highlights the presence of issues that require attention when applying the ML prediction outputs. However, this prediction capability of the algorithms indicates that the tools can be relied on to generate information that can be incorporated into future planning of cropping systems under the low and high potential agro-ecologies of ESA. Picking variability in yield could allow for future exploration of cropping systems effects on maize productivity under varying climatic scenarios in low and high potential parts of ESA [11]. The picked yield variability by the algorithms informs future designing, selection of appropriate sites and management practices suited to cropping systems that were tested in the reported study. Despite the presence of underlying issues in maize yield under the two agro-ecologies, the algorithms were capable of predicting the observed yield under such conditions, further highlighting their usefulness in generating information from big data sets for future decision making.

There is need for enough data to be subjected to analysis to enable determination of the nature of the yield distribution. Positive or negative skewness is attributed to stochastic resource availability [16]. Resource available for crop growth and development has a notable impact on the degree of skewness of the yields. Similarly, resources differ on the degree of availability under different cropping systems. Conservation agriculture and sustainable intensification-based practices improve resource availability for sufficient crop growth and development, thus affecting the skewness [17]. This therefore explains why CA-sole and CA-intercrop systems’ yield distribution was skewed to the right. On the contrary, conventional system-based yields were skewed to the left, which is attributed to inadequate availability of resources.

Critical decisions requiring information need to be made at various levels for the benefit of smallholder farming systems in the ESA region. At farm level, a smallholder farmer needs information to aid in selection of the cropping systems tested in this study under the prevailing biophysical environments of low and high potential areas in the five countries where data were collected. This also entails appropriate planning on inputs required and additional support needed to maximize production in the selected cropping systems. For extension agents, the information generated aids in packaging of extension messages to farmers under different agro-ecological conditions of their extension domains. Similarly, for research agents, prediction output of the algorithms forms the foundation of future designs of cropping systems tailored for the conditions of low and high potential parts of ESA region. The private sector and funding agencies involved in the agri-food sector are informed on areas to focus on developing the smallholder agriculture sector in ESA and beyond. Crucially, policy makers in ESA countries get information on necessary supportive systems that are required for the development and transformation of smallholder agriculture.

Prediction power of algorithms in simulating maize yield

Prediction performance of ML algorithms varies because each algorithm takes into consideration different aspects of the attributes being predicted [27]. The LDA was the best algorithm based on the overall rating. The LDA algorithm works better with binary classifications [47], and this involved separation of maize yield data from different cropping systems into lowland and highland categories. Additionally, the LDA algorithm generates the boundary between classes using the training data input into the model [36]; hence, its predictions can be quite close to the observed data. Between the two linear algorithms, LDA outperformed LR. Chetty et al. [9] highlighted that LR is a good predictor in dichotomous classifications where only two attributes (e.g. cropping systems) are being compared, contrary to the four systems that were compared under each agro-ecology in our study. Additionally, LR algorithm assumes training data residuals are normally distributed and this was not the case in our study, hence the weaker prediction compared to LDA. Saritha et al. [41] mentioned that the efficiency of ML algorithms depends largely on the distribution of the training data used.

The SVM was the worst predictor of maize yields, and this can be attributed to its flexibility in taking as many parameters as possible in its formulation, resulting in low prediction accuracy [27]. Previous studies have shown that the SVM is a better predictor when more than two classifiers are involved in the prediction [44]. Our study involved just two classifiers, either lowland or highland maize yield derived from the four cropping systems that acted as the attributes in the prediction exercise. The linear algorithms performed better in predicting maize yield under different cropping systems (LDA and LR) than the nonlinear tools. This could be attributed to the fact that parametric algorithms such as LDA and LR are relatively restrictive in the parameters that they accommodate in the prediction process [14, 45]. This restriction could lead to better output compared to the non-restrictive nonlinear tools [41]. For the nonlinear algorithms, the naïve Bayes (NB), which is a parametric model, was better than the regression tree algorithm (CART) and neighbour classifier (KNN) which are nonparametric [14, 45]. This is largely attributed to the dynamics involving parametric and nonparametric-based models. Restriction of parameters to pre-assumed values, which are mostly based on reality and experience, increases the likelihood of attaining realistic and outputs of high quality. Such assumptions may include following a normal distribution. In contrast, nonparametric tests do not make assumptions about the model parameters. The range of random inputs is of greater variation even to unrealistic values, thus leading to poor quality outputs [8, 33, 37].

Accuracy and precision of different algorithms in predicting maize yield

In general, a better algorithm is selected or determined in terms of its accuracy consistence. In most cases, better algorithms must give good accuracy under less than 25% of the cross-validation data set. Using less than 50% of the cross-validation data set justifies which algorithm must be used for maize yield prediction and give better precision and accuracy. Therefore, the LDA, LR and NB were better in giving accurate maize yield predictions. The LDA algorithm had high final accuracy in predicting maize yields (Table 4), and this can be attributed to the fact that the model uses training data to generate the boundary between highland and lowland, which were the two classifiers used in the study. The prediction of yields from the four cropping systems under two agro-ecologies was more accurate compared to the other algorithms. Such performance result is consistent with observations made on the prediction power of the algorithms, which further reinforces the driving factors behind the capability of LDA in predicting yields in the study. As observed with the prediction power assessment, the SVM algorithm performed poorly, and this further reinforces the fact that this tool is not suitable for yield predictions when only two classifiers are taken into consideration.

Based on the precision, F-score, recall and confusion matrix, KNN, which is nonparametric, performed better than the other algorithms. This is attributed to the use of nearest neighbours of the current vector as well as sampling from the neighbours, thus ultimately increasing the performance and reliability of the algorithm. Such aspects improve prediction accuracy and reduce Type I and II errors [37]. This strength of KNN in other performance indices highlights its potential as a possible model for yield prediction under the conditions of the reported study. In addition to the indices widely used in these and other studies, there is need to evaluate the performance of the KNN using multiple indices. Such indices may include statistical parameters such as root mean square error (RMSE), coefficient of determination (R2) and mean absolute error (MAE) [48]. Generally, the linear algorithms had better prediction accuracy compared with the nonlinear models, a result which is consistent with yield prediction capability and power. However, the performance of linear and nonlinear algorithms using precision, F-score and recall varies, and this further highlights that selection of an appropriate algorithm for maize yield prediction needs to be based on more than one index. Additional performance indices include the integral of the absolute magnitude of the error (IAE) criterion, which assesses the stability of the system under consideration.

Conclusion

Machine learning algorithms could predict maize grain yields from conventional and CA-based cropping systems under lowlands and highlands of the ESA region. Linear algorithms (LDA and LR) predicted maize yield more closely to the observed yields compared with nonlinear tools (NB, KNN, CART and SVM) under the conditions of the reported study. However, the KNN algorithm was comparable in its yield prediction to the linear tools tested in this study. Overall, the LDA algorithm was the best tool, and SVM was the worst algorithm in maize yield prediction. Evaluating the performance of different machine learning algorithms using different criteria is critical in order to get a more robust assessment of the tools before their application in the agriculture sector. Additionally, comparison of the performance of the tested ML algorithms with modelling tools commonly used is critical in order to further generate evidence of their applicability in agriculture.

References

  1. 1.

    Agrawal R, Mehta SC (2007) Weather based forecasting of crop yields, pests and diseases-IASRI models. Indian Soc Agric Stat 62:1–12

    MathSciNet  MATH  Google Scholar 

  2. 2.

    André P, Mottu JM, Ardourel G (2013) Building test harness from service-based component models. In: Boulanger F, Famelis M, Ratiu D (eds) 10th International workshop on model driven engineering, verification and validation. Florida, Miami, pp 11–20

    Google Scholar 

  3. 3.

    Balducci F, Impedovo D, Pirlo G (2018) Machine learning applications on agricultural datasets for smart farm enhancement. Machines. https://doi.org/10.3390/machines6030038

    Article  Google Scholar 

  4. 4.

    Barber D (2012) Bayesian reasoning and machine learning. Bayesian Reasoning and Machine Learning. https://doi.org/10.1017/cbo9780511804779

    Article  MATH  Google Scholar 

  5. 5.

    Baudron F, Zaman-Allah MA, Chaipa I, Chari N, Chinwada P (2019) Understanding the factors influencing fall armyworm (Spodoptera frugiperda J.E. Smith) damage in African smallholder maize fields and quantifying its impact on yield. A case study in Eastern Zimbabwe. Crop Prot 120:141–150. https://doi.org/10.1016/j.cropro.2019.01.028

    Article  Google Scholar 

  6. 6.

    Cai CJ, Jongejan J, Holbrook J (2019) The effects of example-based explanations in a machine learning interface. Int. Conf. Intell. User Interfaces. Proc IUI Part F1476:258–262. https://doi.org/10.1145/3301275.3302289

    Article  Google Scholar 

  7. 7.

    Chen C, Mcnairn H (2006) A neutral network integrated approach for rice crop monitoring. Int J Remote Sens 27:1367–1393

    Article  Google Scholar 

  8. 8.

    Cheng Z, Nakatsugawa M, Hu C, Robertson SP, Hui X, Moore JA, Bowers MR, Kiess AP, Page BR, Burns L, Muse M, Choflet A, Sakaue K, Sugiyama S, Utsunomiya K, Wong JW, McNutt TR, Quon H (2018) Evaluation of classification and regression tree (CART) model in weight loss prediction following head and neck cancer radiation therapy. Adv Radiat Oncol 3:346–355. https://doi.org/10.1016/j.adro.2017.11.006

    Article  Google Scholar 

  9. 9.

    Chetty R, Grusky D, Hell M, Hendren N, Manduca R, Narang J (2017) Mobility Since 1940(406):398–406. https://doi.org/10.1007/s11356-012-1456-1

    Article  Google Scholar 

  10. 10.

    Ciscar JC, Fisher-Vanden K, Lobell DB (2018) Synthesis and review: an inter-method comparison of climate change impacts on agriculture. Environ Res Lett. https://doi.org/10.1088/1748-9326/aac7cb

    Article  Google Scholar 

  11. 11.

    Crane-Droesch A (2018) Machine learning methods for crop yield prediction and climate change impact assessment in agriculture. Environ Res Lett. https://doi.org/10.1088/1748-9326/aae159

    Article  Google Scholar 

  12. 12.

    Dangeti P (2017) Statistics for Machine Learning: Techniques for exploring supervised, unsupervised, and reinforcement learning models with Python and R. Packt Publishing

  13. 13.

    Enke D, Mehdiyev N (2012) A new hybrid approach for forecasting interest rates. Procedia Comput Sci 12:259–264. https://doi.org/10.1016/j.procs.2012.09.066

    Article  Google Scholar 

  14. 14.

    Gonzalez-Sanchez A, Frausto-Solis J, Ojeda-Bustamante W (2014) Attribute selection impact on linear and nonlinear regression models for crop yield prediction. Sci World J. https://doi.org/10.1155/2014/509429

    Article  Google Scholar 

  15. 15.

    Gorni G, Augusto A (2008) The application of neutral networks in the modelling of plate rolling processes. Miner Met Mater Soc 49:1–4

    Google Scholar 

  16. 16.

    Hennessy DA (2009) Crop yield skewness and the normal distribution. J Agric Resour Econ 34:34–52

    Google Scholar 

  17. 17.

    Hennessy DA (2009) Crop yield skewness under law of the minimum technology. Am J Agric Econ 91:197–208. https://doi.org/10.1111/j.1467-8276.2008.01181.x

    Article  Google Scholar 

  18. 18.

    Holzworth DP, Huth NI, Peter G, Zurcher EJ, Herrmann NI, Mclean G, Chenu K, Oosterom EJV, Snow V, Murphy C, Moore AD, Brown H, Whish JPM, Verrall S, Fainges J, Bell LW, Peake AS, Poulton PL, Hochman Z, Thorburn PJ, Gaydon DS, Dalgliesh NP, Rodriguez D, Cox H, Chapman S, Doherty A, Teixeira E, Sharp J, Cichota R, Vogeler I, Li FY, Wang E, Hammer GL, Robertson MJ, Dimes JP, Whitbread AM, Hunt J, Rees HV, Mcclelland T, Carberry PS, Hargreaves JNG, Macleod N, Mcdonald C, Harsdorf J, Wedgwood S, Keating BA (2014) Environmental modelling and software APSIM evolution towards a new generation of agricultural systems simulation. Environ Model Softw. https://doi.org/10.1016/j.envsoft.2014.07.009

    Article  Google Scholar 

  19. 19.

    https://www.reddit.com/r/MachineLearning/comments/2fxi6v/ama_michael_i_jordan/ckelmtt/?context=3. Accessed 20 Aug 2019

  20. 20.

    Huddleston SH, Brown GG (2018) Machine learning, in: Informs analytics body of knowledge. https://doi.org/10.1002/9781119505914.ch7

  21. 21.

    Hussain J, Khaliq T, Ahmad A, Akhtar J (2018) Performance of four crop model for simulations of wheat phenology, leaf growth, biomass and yield across planting dates. PLoS ONE 13:1–14. https://doi.org/10.1371/journal.pone.0197546

    Article  Google Scholar 

  22. 22.

    Jones JW, Hoogenboom G, Porter CH, Boote KJ, Batchelor WD, Hunt LA, Wilkens PW, Singh U, Gijsman AJ, Ritchie JT (2003) The DSSAT cropping system model. Eur J Agron 18:235–265

    Article  Google Scholar 

  23. 23.

    Joshi P (2017) Artificial Intelligence with Python. Artif Intell Uncertain. https://doi.org/10.1201/9781315366951

    Article  Google Scholar 

  24. 24.

    Karatzoglou A (2013) Machine learning in R (mlr) — mlr - Machine Learning in R

  25. 25.

    Kaul M, Hill L, Charles Walthall R (2005) Artificial neural networks for corn and soybean yield prediction. Agric Syst 85:1–18

    Article  Google Scholar 

  26. 26.

    Learning M (2002) Programming Exercise 1: linear regression. Learn Mach. https://doi.org/10.1023/A:1012422931930

  27. 27.

    Liakos KG, Busato P, Moshou D, Pearson S, Bochtis D (2018) Machine learning in agriculture: a review. Sensors (Switzerland) 18:1–29. https://doi.org/10.3390/s18082674

    Article  Google Scholar 

  28. 28.

    Liben FM, Hassen SJ, Weyesa BT, Wortmann CS, Kim HK, Kidane MS, Yeda GG, Beshir B (2017) Conservation agriculture for maize and bean production in the central rift valley of Ethiopia. Agron J 109:2988–2997. https://doi.org/10.2134/agronj2017.02.0072

    Article  Google Scholar 

  29. 29.

    Liben FM, Tadesse B, Tola YT, Wortmann CS, Kim HK, Mupangwa W (2018) Conservation agriculture effects on crop productivity and soil properties in Ethiopia. Agron J 758–767

  30. 30.

    Luedeling E, Smethurst PJ, Baudron F, Bayala J, Huth NI, van Noordwijk M, Ong CK, Mulia R, Lusiana B, Muthuri C, Sinclair FL (2016) Field-scale modeling of tree-crop interactions: challenges and development needs. Agric Syst 142:51–69. https://doi.org/10.1016/j.agsy.2015.11.005

    Article  Google Scholar 

  31. 31.

    Matthews R, Stephens W, Hess T, Middleton T, Graves A (2002) Applications of crop/soil simulation models in tropical agricultural systems. Adv Agron 76:31–124

    Article  Google Scholar 

  32. 32.

    Micheni AN, Kanampiu F, Kitonyo O, Mburu DM, Mugai EN, Makumbi D, Kassie M (2016) On-farm experimentation on conservation agriculture in maize-legume based cropping systems in Kenya: water use efficiency and economic impacts. Exp Agric 52:51–68. https://doi.org/10.1017/S0014479714000556

    Article  Google Scholar 

  33. 33.

    Mishra S, Mishra D, Santra GH (2016) Applications of machine learning techniques in agricultural crop production: A review paper. Indian J Sci Technol. https://doi.org/10.17485/ijst/2016/v9i38/95032

    Article  Google Scholar 

  34. 34.

    Mohammed M, Khan MB, Bashie EBM (2016) Machine learning: algorithms and applications, machine learning: algorithms and applications. https://doi.org/10.1201/9781315371658

  35. 35.

    Nyagumbo I, Mkuhlani S, Pisa C, Kamalongo D, Dias D, Mekuria M (2015) Maize yield effects of conservation agriculture based maize–legume cropping systems in contrasting agro-ecologies of Malawi and Mozambique. Nutr Cycl Agroecosyst. https://doi.org/10.1007/s10705-015-9733-2

    Article  Google Scholar 

  36. 36.

    Raj MP, Swaminarayan PR, Saini JR, Parmar DK (2015) Applications of pattern recognition algorithms in agriculture: a review. Int J 2502:2495–2502

    Google Scholar 

  37. 37.

    Rajagopalan B, Lall U (1999) A k-nearest-neighbor simulator for daily precipitation and other weather variables. Water Resour Res 35:3089–3101. https://doi.org/10.1029/1999WR900028

    Article  Google Scholar 

  38. 38.

    Rosenzweig C, Elliott J, Deryng D, Ruane AC, Müller C, Arneth A, Boote KJ, Folberth C, Glotter M, Khabarov N, Neumann K, Piontek F, Pugh TAM, Schmid E, Stehfest E, Yang H, Jones JW (2014) Assessing agricultural risks of climate change in the 21st century in a global gridded crop model intercomparison. Proc Natl Acad Sci USA 111:3268–3273. https://doi.org/10.1073/pnas.1222463110

    Article  Google Scholar 

  39. 39.

    Rusinamhodzi L, Makoko B, Sariah J (2017) Ratooning pigeonpea in maize-pigeonpea intercropping: productivity and seed cost reduction in eastern Tanzania. Field Crops Res 203:24–32. https://doi.org/10.1016/j.fcr.2016.12.001

  40. 40.

    Salo TJ, Palosuo T, Kersebaum KC, Nendel C, Angulo C, Ewert F, Bindi M, Calanca P, Klein T, Moriondo M, Ferrise R, Olesen JE, Patil RH, Ruget F, Takáč J, Hlavinka P, Trnka M, Rötter RP (2016) Comparing the performance of 11 crop simulation models in predicting yield response to nitrogen fertilization. J Agric Sci 154:1218–1240

    Article  Google Scholar 

  41. 41.

    Saritha RR, Paul V, Kumar PG (2018) Content based image retrieval using deep learning process. Cluster Comput. https://doi.org/10.1007/s10586-018-1731-0

    Article  Google Scholar 

  42. 42.

    Shalev-Shwartz S, Ben-David S (2013) Understanding machine learning: from theory to algorithms. From theory to algorithms, understanding machine learning. https://doi.org/10.1017/CBO9781107298019

  43. 43.

    Silsbee PL, Bovik AC, Chen D (1959) Some studies in machine learning using the gameof checkers. IBM J 3:291–301. https://doi.org/10.1109/76.257218

    Article  Google Scholar 

  44. 44.

    Su Y, Xu H, Yan L (2017) Support vector machine-based open crop model (SBOCM): case of rice production in China. Saudi J Biol Sci 24:537–547. https://doi.org/10.1016/j.sjbs.2017.01.024

    Article  Google Scholar 

  45. 45.

    Tapamo H, Mfopou A, Ngonmang B, Couteron P, Monga O (2014) Linear vs non-linear learning methods A comparative study for forest above ground biomass, estimation from texture analysis of satellite images. Arima J 18:114–131

    Google Scholar 

  46. 46.

    Tzanis G et al. (2006) Modern applications of machine learning. In: The 1st Annual SEERC Doctoral Student Conference, pp 1–10

  47. 47.

    Tharwat A, Gaber T, Ibrahim A, Hassanien AE (2017) Linear discriminant analysis: a detailed tutorial. AI Commun 30:169–190. https://doi.org/10.3233/AIC-170729

    MathSciNet  Article  Google Scholar 

  48. 48.

    Wang T, Xiao Z, Liu Z (2017) Performance evaluation of machine learning methods for leaf area index retrieval from time-series MODIS reflectance data. Sensors (Switzerland). https://doi.org/10.3390/s17010081

    Article  Google Scholar 

  49. 49.

    Waongo M, Laux P, Traoré SB, Sanon M, Kunstmann H (2014) A crop model and fuzzy rule based approach for optimizing maize planting dates in Burkina Faso, West Africa. J Appl Meteorol Climatol 53:598–613. https://doi.org/10.1175/JAMC-D-13-0116.1

    Article  Google Scholar 

  50. 50.

    Wolfert S, Ge L, Verdouw C, Bogaardt MJ (2017) Big Data in Smart Farming – A review. Agric Syst 153:69–80. https://doi.org/10.1016/j.agsy.2017.01.023

    Article  Google Scholar 

  51. 51.

    Zhou D-X (2015) Machine learning algorithms. Encycl Appl Comput Math. https://doi.org/10.1007/978-3-540-70529-1_301

    Article  Google Scholar 

  52. 52.

    Zinyengere N, Crespo O, Hachigonta S, Tadross M (2015) Crop model usefulness in drylands of southern Africa: an application of DSSAT. South African J Plant Soil 32:95–104. https://doi.org/10.1080/02571862.2015.1006271

    Article  Google Scholar 

Download references

Acknowledgements

The research was funded by the Australian Centre for International Agricultural Research (ACIAR) under the Sustainable Intensification of Maize-Legume Cropping Systems for Food Security in Eastern and Southern Africa (SIMLESA) which was managed by the International Maize and Wheat Improvement Centre (CIMMYT). This study has been embedded into the CGIAR Research Program MAIZE, Flagship Sustainable intensification of smallholder farming systems. The authors acknowledge the long-term efforts invested into making this work a success by many smallholder farmers from the five SIMLESA project countries. We also acknowledge the contributions made by national and agronomy objective coordinators of each of the respective five countries, namely Bedru Beshir and Tadesse Birhanu Atomsa for Ethiopia; Charles Nkonge, Alfred Micheni and George Ayaga for Kenya; Rama Ngatokuwa, Bashir Makoko and John Sariah for Tanzania; Donwell Kamalongo, Amos Ngwira and Donald Siyeni for Malawi, and Domingos Dias, Angelo Cumbane and Custodio Jorge for Mozambique. We also thank the various NGOs and Extension staff that contributed to generating the data used in this study.

Author information

Affiliations

Authors

Corresponding author

Correspondence to W. Mupangwa.

Ethics declarations

Conflict of interest

The authors declare that they have no competing interests.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Electronic supplementary material

Below is the link to the electronic supplementary material.

Supplementary file1 (DOCX 91 kb)

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Mupangwa, W., Chipindu, L., Nyagumbo, I. et al. Evaluating machine learning algorithms for predicting maize yield under conservation agriculture in Eastern and Southern Africa. SN Appl. Sci. 2, 952 (2020). https://doi.org/10.1007/s42452-020-2711-6

Download citation

Keywords

  • Agro-ecology
  • Big data
  • Data-driven value creation
  • Cropping systems
  • Smallholder agriculture