Abstract
This paper presents a detection method of Alternaria solani in tomatoes. Several machine learning models were used to detect the pathogen, such as the implementation of decision trees and ensemble learning methods. The use of these methods requires the acquisition of large volumes of data and adequate preprocessing of this data. For the presented study the dataset of hyperspectral measurements of two varieties of tomatoes was used. Measurements were split into two groups: one inoculated with the Alternaria solani pathogen and the other one was treated as the reference. Measurements were taken by the spectroradiometer in consecutive measurement series. The main part of the study was the evaluation of the decision trees and the popular ensemble learning algorithms to select the most accurate one. After subsequent iterations of the training process and adjustment of hyperparameters, satisfactory accuracy results, equal to 0.987 for random forest, were obtained. This paper also covers the examination of the spectral range required for Alternaria solani identification. From several variants, the accuracy of models based on VIS and NIR spectral range was the closest to the accuracy obtained with the whole spectrum of measured absolute reflectance.
Keywords
Introduction
Tomatoes (Solanum lycopersicum), a native species from South America, are one of the most grown vegetables in the world. It can be grown in various climate conditions from temperate to tropical. Tomatoes are the second most-consumed vegetable in the world [9]. Its annual worlds’ supply exceeds 160 million tons. China is the largest producer of tomatoes, ahead of India and the United States with a production of 59 million tons [8]. Tomatoes are a source of well-absorbed vitamin C and A [4].
However, tomatoes are very vulnerable to fungal, bacterial, and viral diseases such as late blight, powdery mildew, or early blight. Alternaria solani, the cause of early blight, is commonly referred to as the most dangerous tomato pathogen [21]. Symptoms of the early blight are pathogenic changes on the leaves, stems, petioles, and fruits. Under favorable conditions, this disease may result in premature leaf drying and fruits fall, causing 30–80% losses in crop yield [6,11]. Various methods are used to control Alternaria solani on tomatoes e.g. fungicide control and planting plants partially resistant to early blight. However, under a high disease pressure, these methods are not sufficient for the effective protection of tomato plants [18].
Currently, the diagnosis of this disease is based on the assessment of the symptoms of plant tissue damage or assessing the number of pathogen spores under a microscope. The main limitation of such an approach is that it requires individual plant inspection, including the presence of qualified personnel. Therefore, it is necessary to find fast and reliable methods for assessing the degree of damage to plants that could be later used remotely [3]. The main objective of the present study aims to show the possibilities of using ensemble learning methods for disease classification and crop non-destructive diagnosis. The other desirable factor is an early warning for the occurrence of the pathogen, but the present methodology does not provide such a feature. The information on suspected upcoming infection could let the farmers plan proper preventative measures, such as precise fungicide management.
The paper presents a detection method of Alternaria solani in tomatoes cultivated under foil tunnels. Hyperspectral measurements and ensemble learning methods were investigated for the detection purpose. The spectral range of measurements was 350–2500 nm and that allowed one to carry out the comparison of several different algorithms configurations with different spectral band sets. The last part of the described study was aimed to select the best performing detectors for the analyzed scenarios.
Background and related work
The issue of detecting plant diseases attracts the interest of many researchers, which is reflected in numerous publications [2,3,10,15,16,20,26]. This is also the case of research on tomato diseases [2,10,15,16,26]. Publications describe solutions based on standard digital camera (RGB color model) [2,20], multispectral imagery [7] and hyperspectral imagery [16,24–26]. Many authors propose solutions based on hyperspectral measurements with a spectrometer invisible (400–765 nm), near-infrared (900 ÷ 1700 nm), short wave (1000–2500 nm), and long-wave infrared wavelengths (2500–5000 nm), especially in the 350–2500 nm range [15,24,27]. Also, vegetation indices can be used for detecting the early stages of plant diseases [1,5,15,19].
The use of hyperspectral data and machine learning algorithms in disease detection appears to be a popular trend in research [10,24,25]. Research conducted by Moghadam et al. suggests that the analysis of hyperspectral data from 400–2500 nm spectrum gives better results than using various indices. 12 indices were taken to the research: NDVI, SR 800/670, SIPI, PSSRa 800/680, PSSRb 800/635, ARI, REP, mCAI, WBI, CAI, NDLI, NDNI. Researchers applied the Support Vector Machine with Radial Basis Function kernel [16]. They reported a final, best-performing model, using full-spectrum RBF SVM, with 0.936 and 0.915 accuracy on VNIR and SWIR imagery, which were higher than the same model used by Zhu et al. [28] who stated 0.817 accuracy with a full spectrum feature vector.
Xie et al. proposed to use feature ranking (FR) for selecting the most important bands, and then use kNN to classify the plant disease [26]. In his further research, Xie indicates the usefulness of using extreme learning machine (ELM) on the entire spectrum 380–1023 nm to classify early blight and late blight on tomatoes [25]. In the same research, Xie shows usage of successive projections algorithm (SPA) for a decreasing number of bands needed for classifications from 477 to 5 bands. As they reported such reduction allowed the process simplification.
To detect late blight in tomato crops, Wang et al. used an artificial neural network with backpropagation (BPNN) [24]. The 3-25-9-1 architecture was used in the study. Data was acquired by spectrometer GER-2600 (400–2500 nm of spectral range) and aerial hyperspectral imagery (AVIRIS). The authors reported that such a shallow neural network architecture provided proper accuracy with their dataset analysis.
Van De Vijver et al. proposed using PLS-DA method (partial least squares – discriminant analysis) and SIMCA (soft independent modeling of class analogy) [23], as well as PLS-DA and SVM based on PCA scores [22] to detect Alternaria solani in potato crops. Field research was conducted in conditions similar to natural conditions with a special measuring platform that limits the inflow of external light.
Despite various publications on the usage of machine learning algorithms for analysis of hyperspectral data for plant disease detection, there is a lack of research covering the usage of these methods and data in Alternaria solani detection for Benito and Polfast varieties crops growing under foil tunnels in natural conditions. Admittedly, Xie et al. published research on detecting Alternaria solani in tomato crops, however in his research ELM algorithm was used, and the dataset covers hyperspectral images in spectral range 380–1023 nm, taken from one variety (Zheza 809) of tomatoes grown in laboratory conditions [25]. For the comparison the present study covers the random forest algorithm usage on dataset consist of hyperspectral reflectance measurements in spectral range 350–2500 nm, taken from two varieties (Benito and Polfast) of tomatos grown in field conditions (foil tunnels).
The automated applications of machine learning techniques are entering the agriculture industry [13], and among them, the detection of tomato diseases seems to be an important task and is subject to plenty of studies. The intense usage of sensors [19], cameras, and UAVs [5] for that area is also increasing. Several methods already implement computer vision methods for tomato disease detection. The presented work is dedicated to collect information on how to better solve that issue, using an automated method, that could have the potential to address an early infection identification.
Methodology
The methodology of the research includes data collection from experimental fields with tomato crops and the data analysis description with detailed information on applied algorithms and the configuration of the conducted experiments.
Data collection
Data used for this study was acquired in experimental fields in Poznan (Greater Poland Voivodeship, Poland) by QZ Solutions for a project co-founded by The National Center for Research and Development (POIR.01.01.01-00-1317/17).
During the project, the observations of pathogens affecting two tomato varieties were performed on fields. For the following experiment, two fields (with those different varieties) were split into two sections: one inoculated with the Alternaria solani pathogen and the other treated as the reference (control). The reason for such split was to enable the measurement labeling process (the measurements that refer to the infected plants were labeled as Alternaria, the rest were marked as control), aimed to distinguish healthy plants and those with progressing infection. In Fig. 1 the plant and picked leaf are presented. The Alternaria solani symptoms can be spotted on the bottom image.

The tomato plant infected with Alternaria solani: under a foil tunnel (top), and a leaf collected for measurement (bottom).

The process of plants preparation, data collection, postprocessing, and final pathogen detection.
The whole process – from plant preparation and pathogen inoculation, through data collection and preprocessing, to the final modeling and detection has been depicted in Fig. 2. The leaves collected from the inoculated plants were later scanned separately, in a different session, to avoid the infection transmission. The measurements were described as healthy or infected as they were carried out in separate sessions, and that resulted in a precise category assignment for the final dataset.
Measurements were taken by spectrometer ASD FieldSpec 4 Hi-Res. For the purpose of the study, two tomato varieties were cultivated: Benito and Polfast. The reflectance was measured of the collected leaves. The leaves were scanned just after picking with no additional storing process, in separate sessions for healthy and inoculated plants, using the same setup – calibrated spectrophotometer, fixed scanning height (height of 5 cm resulting in 2.22 cm diameter of a leaf area and spectrometer field of view of 25 degrees) and calibrated halogen lighting set. Tomatoes were planted on experimental fields under foil tunnels and the experimental setup is presented in Table 1.
In order to stabilize the measurement system, ASD FieldSpec 4 Hi-Res was turned on 30 minutes before the data acquisition. Then the spectrometer was calibrated with white reference and the calibration was repeated after every series of measurements. Leaves were collected briefly before scanning to prevent any unexpected spectra changes.
The spectrophotometer during the whole process has been powered up each time at least 30 minutes before calibration and measurements. The integration time, that is essential to get the proper reflectance readouts has been set to maximize the spectrometer radiometric range. Each single recorded measurement was a result of five different spectrum reads.
The spectrometer calibration process has been carried out using the white reference spectralon as well as the dark current calibration, before each measurement session, and the reference spectral calibration curve was also recorded in separate files.
The pathogen has been marked on each leaf to avoid mistaken labeling. Each leaf has been pictured before collection, and later transported to the scanning scene.
Each measurement has been followed by the macroscopic analysis, pathogen isolation, and specie identification. The infected parts of the plant that has been carefully separated were fumigated, using a 2% Sodium hypochlorite solution in 3 minutes. Later the fragments were desiccated, cut into four smaller pieces, and placed into Potato Dextrose Agar (PDA) to grow the pathogen. After seven to 10 days the grow cultures has been taken into examination to assign the pathogen and to picture the results.
The dataset contains hyperspectral measurements of leaf reflectance for visible, near-infrared, and short-wave infrared wavelengths (350–2500 nm). The spectral resolution of the data is 3 nm at 700 nm and 8 nm at 1400/2100 nm. Both leaves with and without background were included in the dataset. Figure 3 depicts different measurements split into four subsets. As can easily be seen, the consecutive measurements have various spectral characteristics and the distinction of healthy and infected plants may not be obvious. A different perspective of the observed hyperspectral leaves characteristics is presented in Fig. 4 where the specific peaks and lows related to the investigated phenomena can be compared.
The experiment setup of plants observed for the study

The absolute reflectance diagram (with the consecutive number of the measurement set on the x-axis and the spectrum on the y-axis) for different experiment subsets – two tomato varieties: Benito and Polfast and two labeled sets: measured on infected leaves, inoculated with Alternaria solani, and set of the control group – measurements of leaves of not infected plants.

Hyperspectral representation of each group (Benito–inoculated, Benito–control, Polfast–inoculated, Polfast–control). The median of spectral data is presented as a solid line, the blue background is a visualization of minimum and maximum reflectance.
Random forest is one of the most popular ensemble learning methods. It consists of multiple decision trees. Each decision tree is a hierarchy of some true-or-false statements leading to the decision and the trees are different from each other [12]. Random forest, as an ensemble of decision trees, shares all benefits of decision trees from one hand and making up for some of their deficiencies [12].
Random forest maintains high accuracy on training data and generalization accuracy [14]. This method can be used for regression and classification problems as well. The main flaw of the random forest use is that its hyperparameters need to be tuned to reach high performance and the algorithm does not accept the missing data. Fortunately, the application of spectrophotometer measurement results with a dataset of proper quality.
This method is a powerful technique that usually works well without parameter tuning and does not require data scaling.
The problem presented in this study is based on learning from the measured leaf absolute reflectance values and classifying the pattern as a leaf inoculated with Alternaria solani or as a health leaf. The decision trees, random forest, and other ensemble learning models used for this study are prepared with sklearn framework.
Experiment configuration
The measurements acquired were converted to a data frame with a structure presented in Table 2 and visualized in Fig. 4. Each data sample consists of the reference information – attributes that describe the group, the variety, and the disease (the information if the sample indicates a tomato with Alternaria solani infection or the control group). Every measurement set has its number to allow its unambiguous identification, and it is presented in Table 3 in the ID column. The second group of attributes is the set of reflectance measurements, ranging from 350 to 2500 nanometers. Although every measurement provides 2151 inputs, and the dataset has 2151 columns with the results, the columns from 352.0 to 2498.0 were removed from Table 2 to improve its readability. The dataset consists of 50 samples per each group and each class. Each of those samples is a result of a set of 20 consecutive measurements taken on the field using the spectroradiometer. In the tested dataset, there are 200 samples (based on 1000 measurements in total). For the purpose of later model training the whole dataset was split into train and test sets in proportions 75:25, respectively.
Exemplary measurements extracted from the training set (10 randomly selected out of 1000 measurements). The columns from 350.0 to 2500.0 provide the measured reflectance for the consecutive spectra
Exemplary measurements extracted from the training set (10 randomly selected out of 1000 measurements). The columns from 350.0 to 2500.0 provide the measured reflectance for the consecutive spectra
Comparison of the Alternaria solani detection using decision trees and random forest
First of all, the decision tree was taken into consideration. The decision hierarchy was determined. The pre-pruning method was used to optimize the model. Moreover, various pre-pruning parameters were analyzed to determine the best value of the maximum depth parameter. Feature importance analysis was carried out as well. The method was applied to the individual decision trees, to improve the overall classifier performance. Such an approach allows finding the optimal maximum depth of a tree or the number of estimators.
The second approach was the random forest method. An analysis of various numbers of trees in the trained model was performed. As with the decision tree approach, the feature importance analysis was carried out.
Reflectance analysis
The spectra used in this study cover the range of 350–2500 nm wavelengths with a resolution of 3 nm @ 700 nm and 8 nm @ 1400/2100 nm. Reflectance measurements were taken for four classes based on the variety.
The diagram reflects the association between all measurements split across all studied spectra. It reveals also some strong relationships between some more distant band sets, those relations are also presented in the form of a correlogram in Fig. 5.

Measurements correlogram for observed reflectance spectra.
The first studied approach to the collected measurement classification was a single decision tree algorithm. A decision hierarchy was determined. For full-depth tree (max_depth=7) accuracy of train and test dataset was 1.00 and 0.78 respectively, what could mean the model is overfitted. As shown in Fig. 6, a depth higher than four does not increase accuracy with the test dataset in this particular case.
Accuracy for train and test dataset, for parameter max_depth=4, was ∼0.91 (for the train set) and 0.78 (for the test set) respectively, so the same result on test data can be achieved with the optimized tree.

Accuracy depends on decision tree max_depth.
The results of the classification using decision trees were insufficient, the accuracy of 0.78 and the precision related to Alternaria solani on the level of 0.25 were not promising and did not let to prepare the final detector.
Classification report comparison
The next approach to the problem was the application of several ensemble learning classifiers. The best results were obtained using the random forest algorithm.
The metrics for the classification report were calculated separately for each approach. The report consists of the most informative scores: accuracy, precision, recall, and F1-score.
The applied random forest algorithm achieved performance should be enough to correctly identify plants affected with the Alternaria solani. All: precision, accuracy, and re-call are high and are shown in Table 3 (all the metrics were obtained using the test set).

Normalized confusion matrix for the fitted decision tree (top) and random forest classifier (bottom).

Seven bands with the highest importance selected for the final decision trees model (left) and seven with the highest importance for the random forest classifier (right). The feature importance value was assigned to the x-axis.
The metrics for the classification report were calculated separately for each approach. The report consists of most informative scores: accuracy, precision, recall, and F1-score (which is a harmonic mean of both precision and recall and could be interpreted easier though). The applied random forest algorithm achieved performance should be enough to correctly identify plants affected with the Alternaria solani. All: precision, accuracy, and recall come with great numbers (the greater the result is the better performance is). The difference between both approaches is clearly visible on the normalized confusion matrices that are presented in Fig. 7.
High accuracy and F1 score were obtained, for the classifier implementing Random Forrest the accuracy reached 0.987 and F1-score 0.986. The method presented herein is not scalable, due to the use of specialized measuring equipment. However, the results encourage further research on the use of ensemble learning to detect Alternaria solani and other infections on tomatoes cultivated under foil tunnels. As a next stage of the research new measurements are going to be incorporated into the model to extend the detection to other diseases, such as Phytophthora infestans, as well as the use of other machine learning methods associated with ensemble learning.
Feature importance analysis
Feature importance analysis was performed for both decision trees and random forest approaches.
For the decision tree the most important bands in the decision process, with feature importance parameter higher than 0.1, had wavelengths 918 and 2353 nm. Only seven bands were determined as important in the decision process. All the bands of high importance are presented in Fig. 8.
The most important bands in the decision process for random forest approach, with feature importance parameter higher than 0.1, were bands 905 and 982, but in the decision process total number of 32 bands were found useful.
Results of classification using different spectral band ranges
Results of classification using different spectral band ranges
There are many hyperspectral measuring devices and hyperspectral cameras available. These devices have different specifications and parameters of registered reflectance. The analyzed dataset contained measurements in the spectra range 350–2500 nm, which allowed to separate it to a couple of subsets of the data to verify the accuracy metric of detecting Alternaria solani in a few narrower spectral ranges. Various tested channels sets correspond to the range of spectra recorded by the most popular devices (UV, VIS, VNIR, NIR, SWIR). The full list of analyzed ranges and the complete set of results is presented in Table 4.
Quite obviously, the best results were obtained for the data subset marked as UV+VIS+NIR, which refers to the whole spectral range (350–2500 nm). The achieved accuracy result was equal to 0.987. Surprisingly good results were achieved by models based on significantly limited data subset.
Results gained by models based on VIS and VNIR are similar to the best classificatory even though they use a limited range. Interestingly, the model using the VNIR range has achieved the best precision result of detecting Alternaria solani.
The only exception is the classifier using the UV range. This model was trained based on only 51 bands, which turned out to be too small a data subset for analysis and the results are unsatisfactory.
Results of classification using ensemble-based methods
Results of classification using ensemble-based methods
The results of the last experiment are presented in Table 5. It is the effect of several different ensemble learning algorithms comparison. During this study, the training with the cross-validation was performed as well as the number of the estimators fit using the grid search method.
The process was done using the same dataset and again among those methods, the random forest had the highest accuracy, re-call, and precision.
Surprisingly the lowest metrics were obtained for the gradient boosting method, with the accuracy equal to only 0.893. Even after the classifier hyperparameters re-fitting the Alternaria solani related re-call and F1-score were found less than 0.7.
Discussion
Random forest classifiers are successfully applied in agriculture e.g. crop classification [17] and early detection of TMV (tobacco mosaic virus) on tobacco leaves [28].
The initial analysis of measurements’ spectra was not sufficient to enable classification. To distinguish samples related to the infected plant more advanced classifier is needed. Even the selection of specific bands that could be more informative was not easy, as many of them present similar information. The smooth change of neighboring spectra could be observed on the correlogram presented in Fig. 5.
The study shows a comparison of decision tree and random forest approaches. Other ensemble learning methods, such as AdaBoost, Bagging, Extra Trees, Gradient Boosting, have been investigated to determine the most effective method for detecting Alternaria solani. An important stage of the study was also the review of the bands’ importance level in the decision process, which helps increase the classifier efficiency. It is purposefully worth expanding this study and looking for a set of bands that will allow for the construction of a device enabling remote detection of the pathogen.
The results of the research showed the high potential of the pathogen detection method using hyperspectral data. The use of ensemble learning methods turned out to be valuable in the in-depth study and enabled the selection of parameters of the algorithm and appropriate selection of the most significant bands in the decision process. It would be worth testing a simpler sensor, based only on selected bands, which could allow building an inexpensive device in the future work.
Conclusions
There is a real need to provide a non-destructive method of plant disease detection for tomato cultivators. The information about the type of infection can determine crop treatment methods and help farmers to prevent yield losses. In this work, a preliminary model for Alternaria solani detection was analyzed and constructed using a random forest. To check if the method is able to generalize it was tested against two different tomato varieties (Benito and Polfast) cultivated under foil tunnels. The model was trained using hyperspectral measurements from 350–2500 nm spectral range. The final model resulted in the accuracy and F1 score equal to 0.98 and was found satisfying, as it was able to correctly distinguish most presented cases (infected plants and control samples). In addition, feature importance analysis was performed and 32 bands were determined as most significant for the model.
In additional experiments, classifiers based on various measurement ranges were studied. Quite obviously the model with the full range of spectra measurements gained the highest results. However, models using absolute reflectance measured in VIS (from 400 to 765 nm) and VNIR (between 400 and 1000 nm) ranges had similar detection performance of studied pathogen. This may mean that a spectrometer working in narrower range (VIS and VNIR) can be used to observe this phenomenon, which, however, requires confirmation in subsequent experiments.
In the upcoming season, the presented study will be continued. Future works should result in new measurements, to let the incorporation of the updated model, which could detect other diseases, that will be planted there. The other possible way to extend the usability of the presented methodology is to test it with other tomato varieties and with other plants.
The described study covers the detection of Alternaria solani for two different tomato varieties cultivated under foil tunnels. The possible way to extend this study is to add some other pathogen detection trials. Another task that could be tackled is the detection of this pathogen but on the other species, for instance potatoes, that are also highly sensitive to Alternaria solani.
The application of the presented detection process to the regular fields could be impractical or even impossible. Most of the farmers do not have access to a spectrophotometer, the device is pricy, the measurement process is complex and gives only single point readouts and pathogen warnings. Therefore the development of the sensor that will be able to detect such pathogens has great potential. This requires the extended study of other sensors that could provide imagery in the identified band, such as multi spectra cameras or hyperspectral cameras, and some trails on an unmanned aerial vehicle supported data acquisition. However, that kind of remote measurement, from higher altitudes would result in a signal that could demand the band study reconsideration.
Footnotes
Acknowledgements
This work was partially supported by The National Centre of Research and Development of Poland under project POIR.01.01.01-00-1317/17.
