# Environmental Impact on Predicting Olive Fruit Fly Population Using Trap Measurements

Romanos Kalamatianos, Katia Kermanidis, Markos Avlonitis, Ioannis Karydis

► To cite this version:

Romanos Kalamatianos, Katia Kermanidis, Markos Avlonitis, Ioannis Karydis. Environmental Impact on Predicting Olive Fruit Fly Population Using Trap Measurements. 12th IFIP International Conference on Artificial Intelligence Applications and Innovations (AIAI), Sep 2016, Thessaloniki, Greece. pp.180-190, 10.1007/978-3-319-44944-9_16 . hal-01557647

HAL Id: hal-01557647

https://inria.hal.science/hal-01557647

Submitted on 6 Jul 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Environmental Impact on Predicting Olive Fruit Fly Population Using Trap Measurements

Romanos Kalamatianos, Katia Kermanidis, Markos Avlonitis, Ioannis Karydis

Department of Informatics

Ionian University

Corfu, Greece 49100

{c14kala, kerman, avlon, karydis}@ionio.gr

**Abstract.** Olive fruit fly trap measurements are used as one of the indicators for ol-ive grove infestation, and therefore, as a consultation tool on spraying parameters. In this paper, machine learning techniques are used to predict the next olive fruit fly trap measurement, given as input environmental parameters and knowledge of previous trap measurements. Various classification algorithms are employed and applied to different environmental settings, in extensive comparative experiments, in order to detect the impact of the latter on olive fruit fly population prediction.

**Keywords:** olive fruit fly, machine learning, population prediction, classification, Naive Bayes, Nearest Neighbors, Decision trees, Random forests, Support Vector Machines

## 1 Introduction

The olive fruit fly is a pest that has been recorded to infest solely the olive fruits since at least the third century BC [1]. Such infestations cause great damage to the production of both olive oil or table olives [2] in many olive oil producing countries, including Greece. The olive fruit fly is active during the summer and reaches its population peak during au-tumn, while during the winter and in the first months of spring it hibernates, until environ-mental conditions are favorable for it to reemerge [1].

The population growth of the olive fruit fly and, by extension, the level of infestation of an olive grove are affected by various environmental factors. However, the two primary factors that affect the activity of the olive fruit fly are temperature [3] and relative humidity [4, 5].

Population control of the olive fruit fly can be achieved through spraying of the olive trees, either with bait or universal [1][6]. However, in order for the spraying to have any effect, it has to be applied when conditions are appropriate. Two factors indicate when spraying should commence [6]: (a) the ripeness level of the olive fruit, as the fruit needs to be ripe in order for it to be susceptible to the olive fruit fly and (b) the population of the fly, i.e. when a certain population threshold (recorded via sampling) is exceeded. Sampling is achieved through McPhail traps or yellow sticky traps [1][6]. The threshold is set to seven olive fruit flies per trap per week during the summer and is decreased to five olive fruit flies per trap per week during autumn [6].

Machine learning techniques have been used to detect oil spills on the surface of the sea by scanning radar images [7], to automatically identify species by sound [8] and to monitor flood protection systems [9]. Machine learning techniques have also been applied in nu-merous agriculture processes such as the prediction of when a cow should be culled in a dairy herd [10], the estimation of soil moisture [11], the estimation of a cow's oestrus [12] and the prediction of olive fruit fly infestation using information about olive tree health as well as trap measurements [13].

The aim of this paper is to predict future olive fruit fly trap measurements, and by exten-sion olive fruit fly infestations/outbreaks, using machine learning algorithms. Our approach differentiates from previous work [13] by constructing a feature vector that consists of
environmental factors e.g. temperature, instead of the olive tree health, as well as trap measurements.

# 2 Data Collection

## 2.1 Environmental Data

The data used in the experiments were collected from environmental sensors and olive fruit fly traps that were installed at 16 locations on the north-western side of the island of Corfu, Greece. Readings on the olive fruit fly traps show the total number of olive fruit flies caught by the trap. Each reading was conducted every five days for the period from 10th June 2015 to 29th September 2015, at all locations. All sensors at all locations logged temperature values at a 15 minutes interval, while a few of these also logged relative humidity values.

## 2.2 Feature Selection

In order to perform classification experiments, the aforementioned environmental data were transformed into the following set of attributes (in order to represent readings as feature-value learning vectors):

* Mean temperature of the last five days before next trap reading

* Mean maximum temperature of the last five days before next trap reading

* Mean minimum temperature of the last five days before next trap reading

* Day 1 Mean Temperature

* Day 1 Maximum Temperature

* Day 1 Minimum Temperature

* Day 2 Mean Temperature

* Day 2 Maximum Temperature

* Day 2 Minimum Temperature

* Day 3 Mean Temperature

* Day 3 Maximum Temperature

* Day 3 Minimum Temperature

* Day 4 Mean Temperature

* Day 4 Maximum Temperature

* Day 4 Minimum Temperature

* Day 5 Mean Temperature

* Day 5 Maximum Temperature

* Day 5 Minimum Temperature

Apart from the environmental attributes, one more attribute, namely the trap measurement of the last reading (number of flies caught), was used as input. All aforementioned attributes are numeric. Finally another attribute, denoting the next trap reading was used as the classification class.

## 2.3 Feature Vector Extraction

The process of extracting the attributes for the feature vectors from the sensor data was automated by use of a script. The script was written in Python that automatically computes the mean, mean maximum and mean minimum temperature for the five day period before the next trap reading, as well as the mean, maximum and minimum temperature for each day in the aforementioned five day period. The script exports all vectors in a CSV (Comma Separated Values) file. Finally trap readings are added manually at each corresponding vector instance.

The temperature-related attributes, initially numeric, were discretized into the following three bins:

* <15, temperature is lower than 15 °C,
* 15 to 32, temperature is between 15 °C and 32 °C,

* >32, temperature is greater than 32 °C.

The discretization of the temperature values was based on the temperature range (between 15 oC and 32 oC [14]), in which the olive fruit fly is active. If the temperature of the environment is below the lower or exceeds the upper threshold, then the olive fruit fly is motionless due to extreme cold or heat. Accordingly, herein we assume that outside the optimal temperature range of the olive fruit fly, the traps will not capture any olive fruit flies.

Trap reading related attributes have also been discretized into the following bins:

* 0 to 4, none or up to 4 olive fruit flies inside the trap,

* 5 to 6, five or six olive fruit flies inside the trap,

* >=7, greater than or equal to seven olive fruit flies inside the trap.

The use of a ternary quantisation of the number of olive fruit flies is based on trap measurements analysis, i.e. the infestation threshold depends on the season the measurements are made. Specifically, in the summer months the infestation threshold is set to seven olive fruit flies per trap per week. On the other hand, from September onwards the infestation threshold is decreased to five olive fruit flies per trap per week, due to cooler weather [6]. Therefore, although the last bin value would always indicate infestation, the second bin value would be depended on the season.

## 3 Machine Learning Algorithms

The WEKA machine learning workbench1 was used for running the classification experiments. In the sequel, a number of classification algorithms that were selected for experimentation are shortly presented.

J48 [15] is a decision tree induction algorithm and it is a version of C4.5, an earlier algorithm developed by J. Ross Quinlan [16]. C4.5 generates a decision tree based on information gain of the attributes in the available training data. More specifically, the attribute whose values discriminate most clearly the training examples according to their class label is identified in each iteration. The algorithm stops when there are no further attributes to explore or when all the training examples are separated according to their class label. Additionally, J48 incorporates two tree pruning methodologies: The first one is known as subtree replacement and it replaces a node in a decision tree with the corresponding leaf, if the given subtree does not help classification accuracy. This pruning process starts from the leaves of the fully formed tree, and moves bottom up toward the root. The second methodology is known as subtree raising in which a node may replace other nodes while it is moved towards the root. This type of pruning most of the times has insignificant effect on decision tree models.

<table><caption>**Table 1.** J48 parameter values</caption><tr><td>Binary Splits</td><td>No</td></tr><tr><td>Confidence Factor</td><td>0.25</td></tr><tr><td>Minimum Instances per Leaf</td><td>2</td></tr><tr><td>Reduced Error Pruning</td><td>No</td></tr><tr><td>Subtree raising</td><td>Yes</td></tr><tr><td>Pruned</td><td>Yes</td></tr><tr><td>Laplace smoothing</td><td>No</td></tr></table>

Sequential Minimal Optimization or SMO [17] is an ameliorated algorithm for training support vector machines. SMO cuts in pieces a large quadratic programming optimization problem converting it into smaller problems (sub-problems of quadratic programming).

<footnote n="1">¹ http://www.cs.waikato.ac.nz/ml/weka/</footnote>
The sub-problems are solved quickly because they are solved analytically which means that SMO avoids to use extra time for arithmetical quadratic programming optimization as an inner loop. So SMO manages to reduce computation time significantly.

<table><caption>**Table 2.** SMO parameter values</caption><tr><td>Complexity parameter</td><td>1.0</td></tr><tr><td>Round-off error</td><td>1.0E-12</td></tr><tr><td>Filter Type</td><td>Normalize training data</td></tr><tr><td>Kernel</td><td>PolyKernel</td></tr><tr><td>Random seed for cross validation</td><td>1</td></tr><tr><td>Tolerance parameter</td><td>0.001</td></tr></table>

Naïve Bayes [15] is a probabilistic classifier based on the assumption of conditional independence [18], which assumes that the appearance of a specific feature given the class value is unrelated to the appearance of any other feature in the dataset. Though not valid in reality, this assumption has been proven to cope well with several classification problems. Additionally, this algorithm needs a small amount of training data to determine the parameters necessary for classification. Due to the hypothesis of independent variables; there is no need to estimate the entire covariance matrix but only the differentiations of the variables for each class.

<table><caption>**Table 3.** Naïve Bayes parameter values</caption><tr><td>Use kernel estimator</td><td>No</td></tr><tr><td>Use supervised discretization</td><td>No</td></tr></table>

The RandomForest [19] is a meta-learning classification algorithm that runs iteratively. In each iteration a decision tree is induced from a randomly selected subset of the features. The number of iterations is pre-defined. The final classification error is the mean error over all iterations.

<table><caption>**Table 4.** RandomForest parameter values</caption><tr><td>Maximum Depth</td><td>Unlimited</td></tr><tr><td>Number of Attributes</td><td>0</td></tr><tr><td>Number of trees to be generated</td><td>100</td></tr><tr><td>Seed</td><td>1</td></tr></table>

AdaBoost [20] is another meta-learning algorithm, that iteratively changes instance weights, based on whether they were classified correctly (or not) in a previous iteration. Thereby, the learner is forced to focus on instances that are hard to classify. The final classification is derived from the weighting of the models induced after every iteration.

<table><caption>**Table 5.** AdaBoost parameter values</caption><tr><td>Classifier</td><td>SMO</td></tr><tr><td>Number of Iterations</td><td>10</td></tr><tr><td>Seed</td><td>1</td></tr><tr><td>Use resampling</td><td>No</td></tr><tr><td>Weight Threshold</td><td>100</td></tr></table>

The IBk algorithm [15] is an alternate version of the k-nearest neighbor algorithm. Using the Euclidean distance as a distance metric, it identifies the k training examples that are closest to a given test instance, and, via majority voting selects its class label. The value of k can be explicitly pre-defined, or estimated optimally using cross validation. In our exper-
iments, the number of nearest neighbors ranged from 1 to 33 neighbors, where only odd values were selected.

<table><caption>**Table 6.** IBk parameter values</caption><tr><td>Cross Validate</td><td>No</td></tr><tr><td>Distance Weighting</td><td>No</td></tr><tr><td>Use of Mean Squared Error</td><td>No</td></tr><tr><td>Nearest Neighbor Search Algorithm</td><td>LinearNNSearch</td></tr><tr><td>Window Size</td><td>0</td></tr></table>

The Multilayer Perceptron is an artificial neural network [21], where each of the multi-layer nodes is fully connected to the following one. Multilayer perceptrons are able to distinguish data that are not linearly separable. Experiments were conducted for one hidden layer with the number of nodes ranging from 1 to 10.

<table><caption>**Table 7.** Multilayer Perceptron parameter values</caption><tr><td>Decrease learning rate</td><td>No</td></tr><tr><td>Hidden layers</td><td>1</td></tr><tr><td>Learning rate</td><td>0.3</td></tr><tr><td>Momentum</td><td>0.2</td></tr><tr><td>Nominal to binary filter</td><td>Yes</td></tr><tr><td>Normalize attributes</td><td>Yes</td></tr><tr><td>Normalize numeric class</td><td>Yes</td></tr><tr><td>Reset</td><td>Yes</td></tr><tr><td>Seed</td><td>0</td></tr><tr><td>Training time</td><td>500</td></tr><tr><td>Validation set size</td><td>0</td></tr><tr><td>Validation threshold</td><td>20</td></tr></table>

# 4 Experimental Process

184 training instances were supplied. Due to the small size of the training data, no test set could be supplied for the validation of the results. Therefore the 10-fold cross-validation method was used. The original sample is randomly partitioned into ten subsamples. One out of ten subsamples is kept as validation data for testing the model, and the remaining nine subsamples are used as training data. The cross-validation process is then repeated ten times, with each of the ten subsamples being used only once as validation data. Results are averaged across the ten experiments.

# 5 Evaluation

Figure 1 displays the classification results of the five aforementioned machine learning algorithms. The SMO algorithm produces the best results in both precision and recall, with the J48 algorithm being close by. AdaBoostM1 produces the same results with SMO using as a base learner the SMO algorithm. On the other hand, NaiveBayes produces the worst results in comparison with the other algorithms, with a significant decrease in precision and a quite noteworthy low recall.
<figure><img src="image_2.png" /><figcaption>**Fig. 1.** Precision and recall comparison for five classification algorithms</figcaption></figure>

Figure 2 presents the pruned tree constructed by the J48 algorithm. It is clear that the algorithm considers the “previous reading” as the most important attribute for classification. With the minimum temperature of day 3 being used when the previous reading has a value of “5 to 6”.

<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Tree view constructed by J48</figcaption></figure>

The next experiment is using the IBk algorithm, as shown in Figure 3, with maximum recall for one and for five nearest neighbors. The best results in both recall and precision are achieved when using one nearest neighbor. From three nearest neighbors and onwards the precision of the algorithm decreases, with a significant drop after nine nearest neighbors. After eleven nearest neighbors, precision and recall stay stable.
<figure><img src="image_4.png" /><figcaption>**Fig. 3.** IBk classification results for different number of k neighbours</figcaption></figure>

Finally, the Multilayer Perceptron algorithm, shown in Figure 4, exhibits a great difference between recall and precision values for any number of nodes in the perceptron. The best results for both precision and recall are reported for three nodes in the hidden layer.

<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Multilayer Perceptron classification results for different number of nodes</figcaption></figure>

Comparing all machine learning algorithms that were used in the experiments, the best performance was achieved by SMO and AdaBoostM1, using SMO as a base learner.

It is important to note that the values of the classification attribute are not balanced. Figure 5 depicts the distribution of the three values among the 184 instances. Over 80% of the instances have a value of “0 to 4”, while the value “5 to 6” is the least encountered value, with nine instances. This fact explains why the J48 algorithm, as shown by the constructed tree in Figure 2, can't classify any instance to the value “5 to 6”.
<figure><img src="image_6.png" /><figcaption>Fig. 5. Value distribution of the “next trap reading” classification attribute</figcaption></figure>

Figure 6 shows the comparison of the best classifier presented herein against the best clas-
sifier of [13] in terms of recall. It is obvious that the Classification Trees (CT) have a far
better recall compared to the SMO algorithm by almost 10%. This difference is attributed
to the significant imbalance in the distribution of the class value in the training data. Addi-
tionally, the results produced by the CT were achieved using only six attributes and the
classification class had only two values, whether to treat or not. Finally, a number of the
used attributes contained information about the phenological state of the olive tree.

<figure><img src="image_7.png" /><figcaption>Fig. 6. Results comparison with previous work [13]</figcaption></figure>

6 Conclusion

In this work, supervised machine learning is used to predict future olive fruit fly trap's
measurements. The proposed feature vector consists of environmental parameters, specifi-
cally temperature, and information about previous trap measurements. Results produced by
the conducted experiments were promising with the support vector machine algorithm
providing the best classification results, although the values of the classification attribute
were unbalanced.

Our approach differentiates from previous work by using environmental parameters in-
stead of information about the health of the olive trees. When results between the best clas-
sifiers of the proposed and existing work were compared, the proposed approach produced
results with 10% ameliorated recall.
Future research will take into account more environmental parameters such as relative humidity and the amount of light the olive fruit flies are exposed to. Furthermore, the experiments described are planned to be conducted again in more training instances as measurement data accumulate.

**Acknowledgments.** Financial support of the European Union and of National Funds of Greece and Albania under the IPA Cross-Border PROGRAMME "Greece - Albania 2007 - 2013", project title "Enhancing Olive Oil Production with the use of Innovative ICT" with the acronym "e-Olive", is gratefully acknowledged.

# 7 Bibliography

Vossen, P., Varel, L., Devarenne A.: Olive fruit fly. University of California Cooperative Extension - Sonoma County (2006).

Rice, R.: Bionomics of the Olive Fruit Fly Bactrocera (Dacus) olea. University of California Plant Protection Quarterly, 10, 1-5, (2000)Fletcher, B.S.: Temperature development rate relationships of the immature stages and adults of tephritid fruit flies. In: Robinson, A. S., Hooper G. (eds) Fruit Flies: Their Biology, Natural Enemies and Control, vol. 3A, pp. 273-89. Elsevier, Amsterdam (1989).

4. Yokoyama, V. Y., Rendon P., Sivinski, J.: Biological Control of Olive Fruit Fly (Diptera: Tephritidae) by Reseases of Psylltalia cf. concolor (Hymenoptera: Braconidae) in California, Parastoid Longevity in Presence of the Host, and Host Status of Walnut Husk Fly. In: 7th International Symposium on Fruit Flies of Economic Importance, pp.157-164. Salvador, Brazil (2006)

5. Broufas, G. D., Pappas, M. L., Koveos, D. S.: Effect of Relative Humidity on Longevity, Ovarian Maturation, and Egg Production in the Olive Fruit Fly (Diptera: Tephritidae). Annals of the Entomological Society of America, 102(1), 70-75 (2009)

6. Patsias, A., 2005, EE Katapolmeese tou THkou tee Elee [The Fighting of Olive fruit fly]. Publicity Department of Agricultural Sector Applications and Publicity. Nicosia, Cyprus

7. Kubat, M., Holte, R. C., Matwin S.: Machine Learning for the Detection of Oil Spills in Satellite Radar Images. Machine Learning, 30, 195-215 (1998)

8. Acevedo, M. A., Corrada-Bravo, C. J., Corrada-Bravo, H., Villanueva-Rivera, L. J. Aide T. M.: Automated classification of bird and amphibian calls using machine learning: A comparison of methods. Ecological Informatics, 4, 206-214, (2009)

9. Pyayt, A. L., Mokhov, I. I., Lang, B., Krzhizhanovskaya, V. V., Meijer, R. J.: Machine Learning Methods for Environmental Monitoring and Flood Protection. World Academy of Science, Engineering and Technology, 78, 118-124, (2011)

10. McQueen, R. J., Garner, S. R., Nevill-Manning, C. G., Witten, I. H.: Applying machine learning to agricultural data. Computers and Electronics in Agriculture, 12(4), 275-293, (1995)

11. Ahmad, S., Kalra, A., Stephen, H.: Estimating Soil Moisture using Remote Sensing Data: A Machine Learning Approach, Advances in Water Resources, 33(1), 69-80, 2010

12. Mitchell, R. S., Sherlock, R. A., Smith, L. A.: An investigation into the use of machine learning for determining oestrus in cows. Computers and Electronics in Agriculture, 15(3), 195-213, (1996)

13. Del Sagrado, J., Del Águila, I. M.: Olive Fly Infestation Prediction Using Machine Learning Techniques. In: Current Topics in Artificial Intelligence: 12th Conference of the Spanish Association for Artificial Intelligence, pp. 229-238, Springer Berlin Heidelberg (2007)

14. Vossen, P., 2014, Monitoring and Control of Olive Fruit Fly (OLF) for Olive Production in California. University of California Cooperative Extension.

15. Witten, I. H., Frank, E.: Data Mining: Practical Machine Learning Tools and Techniques. Second edition. Morgan Kaufmann (2005)

16. Quinlan, J. R.: Bagging, boosting and C4.5. In: 13th National Conference on Artificial Intelligence, pp. 725-730. AAAI Press, Portland, Oregon (1996)

17. Platt, J. C., Sequential Minimal Optimization: A Fast Algorithm for Training Support Vector Machines. Technical Report MSR-TR-98-14, Microsoft Research (1998)

18. Russell, S. and Norvig, P.: Artificial Intelligence: A Modern Approach. 3rd edition, Prentice Hall (2009)

19. Breiman L.: Random Forests. Machine Learning, 45, 5-32 (2001).

20. Freund, Y., Schapire, R. E.: Experiments with a new Boosting Algorithm. In: Proceedings of the Thirteenth International Conference on Machine Learning, pp. 148-156, (1996).

21. Rosenblatt, F.: Principles of Neurodynamics: Perceptrons and the Theory of Brain Mechanisms.
<figure><img src="image_8.png" /></figure>