# Automatic Identification of Peanut-Leaf Diseases Based on Stack Ensemble
## 3 Results
### Accuracy and Confusion Matrix of the Model after Stacking Ensemble  
The confusion matrix was used to compare the performance of the classifier. Each row of the confusion matrix represents examples of unpredicted peanut-leaf disease, and each column represents actual peanut-leaf disease. Based on the confusion matrix, three indicators--recall, precision, and weighted average score (\(F1\) score) of recall accuracy--were used to evaluate the performance of the model. In this experiment, \(F1_{(i)}\) was used to evaluate the performance of model corresponding to each class, and \(F1\) used the \(F1_{(i)}\) of each class to weigh the performance of the whole model. Equations (2)-(5) given the calculation of these indicators. \[precision_{(i)}=\frac{TP}{TP+FP} \tag{2}\]  
where \(precision_{(i)}\) is the precision corresponding to class I, \(TP\) is the number of correct answers to the prediction, and \(FP\) is the number of other classes predicted as this class by error. \[recall_{(i)}=\frac{TP}{TP+FN} \tag{3}\]  
where \(recall_{(i)}\) is the recall rate corresponding to class I, and \(FN\) is the number of classes that are predicted to be other classes. \[F1_{(i)}=2\times\frac{precision\times recall}{precision+recall} \tag{4}\]  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Model**} & \multicolumn{8}{c}{**Data Augmentation**} & \multicolumn{8}{c}{**Without Data Augmentation**} \\ \cline{2-13}  & **M1** & **M2** & **M3** & **M4** & **M5** & **Mean** & **M1** & **M2** & **M3** & **M4** & **M5** & **Mean** \\ \hline AlexNet & 91.61 & 91.40 & 92.02 & 92.33 & 91.61 & **91.79** & 90.36 & 89.95 & 92.33 & 90.78 & 91.50 & 90.38 \\ VGG16 & 93.78 & 93.89 & 95.34 & 92.54 & 91.19 & **93.35** & 92.64 & 93.26 & 92.64 & 94.09 & 93.06 & 93.14 \\ ResNet50 & 96.58 & 94.92 & 94.61 & 94.92 & 95.23 & **95.25** & 94.40 & 93.78 & 94.20 & 94.30 & 95.13 & 94.36 \\ DenseNet121 & 96.68 & 96.68 & 95.85 & 95.85 & 94.82 & **95.98** & 92.64 & 95.44 & 93.37 & 93.58 & 95.03 & 94.01 \\ InceptionV3 & 95.03 & 95.75 & 94.51 & 93.68 & 96.37 & **95.07** & 91.92 & 91.72 & 91.71 & 90.26 & 93.68 & 91.90 \\ \hline SVM & 73.56 & 73.44 & 72.98 & 72.55 & 73.48 & **73.20** & 70.76 & 70.43 & 70.27 & 69.68 & 70.51 & 70.33 \\ RF & 72.33 & 71.98 & 72.05 & 72.16 & 71.95 & **72.09** & 69.52 & 69.35 & 69.93 & 70.18 where \(F1_{(i)}\) is the weighted average score of the recall accuracy corresponding to each class. \[F1=\frac{1}{n_{n}}\sum\limits_{i=1}^{n_{n}}F1_{(i)}^{2} \tag{5}\]  
where \(F1\) is the weighting of the recall accuracy of the entire model's average score. As shown in Figure 6, Tables 3 and 4, the accuracy and \(F1\) score of each model were improved after using the stacking ensemble. In this experiment, the highest accuracy of the models reached 97.59%, and there were two ways to achieve this accuracy. One was to use ResNet50 as the base-model for extracting the features of the images, and then use LR to ensemble the five M models. Compared with the accuracy before the ensemble, the accuracy of the models improved by 2.37%. Another way to achieve the same accuracy was to use DenseNet121 to extract image features and then ensemble the model with RF. As shown in Table 2, without the use of out-of-fold predictions, the deep-learning methods were all very effective in the identification of peanut-leaf diseases. Each of the five base-models used in this experiment achieved an accuracy of more than 90% for the dataset. In the image-classification problem, a higher classification accuracy meant that it was harder to improve the accuracy any further. However, after using out-of-fold prediction, the accuracy of the five models was improved. Even when the accuracy was already high without using out-of-fold prediction, the accuracy was still improved by 1-3%. By training the meta-model using out-of-fold predictions from the base-model, the meta-model could view and exploit the expected behavior of each base-model when run on unseen data, as was the case in practice when using ensembles to make predictions on new data.