# Classification of Date Fruits into Genetic Varieties Using Image Analysis

Authors: Murat Koklu; Ramazan Kursun; Yavuz Selim Taspinar; Ilkay Cinar
Journal: Mathematical Problems in Engineering
 (2021)

---

## Abstract

A great number of fruits are grown around the world, each of which has various types. The factors that determine the type of fruit are the external appearance features such as color, length, diameter, and shape. The external appearance of the fruits is a major determinant of the fruit type. Determining the variety of fruits by looking at their external appearance may necessitate expertise, which is time-consuming and requires great effort. The aim of this study is to classify the types of date fruit, that are, Barhee, Deglet Nour, Sukkary, Rotab Mozafati, Ruthana, Safawi, and Sagai by using three different machine learning methods. In accordance with this purpose, 898 images of seven different date fruit types were obtained via the computer vision system (CVS). Through image processing techniques, a total of 34 features, including morphological features, shape, and color, were extracted from these images. First, models were developed by using the logistic regression (LR) and artificial neural network (ANN) methods, which are among the machine learning methods. Performance results achieved with these methods are 91.0% and 92.2%, respectively. Then, with the stacking model created by combining these models, the performance result was increased to 92.8%. It has been concluded that machine learning methods can be applied successfully for the classification of date fruit types.


---

## Body

## 1. Introduction

Date fruit (Phoenix dactylifera), which has about 200 types and more than 2500 species worldwide, is an edible and a nutritive fruit [1–3]. Date fruit can be classified by evaluating with image analysis and pattern recognition techniques. The differences in view, distance, and lighting exposure are the obstacles encountered in terms of performing a reliable classification. In order to make a successful classification, interclass similarities and differences should be handled cautiously. Therefore, the studies on fruit recognition and classification have been carried out based on the visual features extracted from images.In short, easily determining the changes in the surface area and color values of the agricultural products with image analysis techniques facilitates the classification studies [4]. In the literature, there are numerous automatic classification and sorting systems based on image processing for various fruits, such as citrus, apple, date fruit, strawberry, mango, lemon, tomato, and pulses [5–10]. Morphological features are frequently used in the classification of fruits and vegetables [11, 12]. In another study carried out with seven different date fruit types, the k-nearest neighbor (cityblock), k-nearest neighbor (Euclidean), discriminant analysis, and neural networks classification methods have been tested by properly preparing 15 different visual features on the image data. The highest accuracy rates achieved as a result range between 89% and 99% [13]. In addition to the local binary pattern (LBP) and Weber local descriptor (WLD) methods used in order to extract the details of a date fruit’s tissue pattern, the feature extraction method based on the Fisher discriminant ratio (FDR) was also applied to select more important features than these two methods. The data obtained through these methods were classified using the multiclass support vector machine (SVM) [14]. The data obtained as a result of the segmentation of the images obtained for the determination of the date fruits’ ripening stages with the Otsu method was classified with the support vector machines (SVM) method, and an accuracy of 92.5% was achieved on 160 images [15]. In another study, in which 6 features extracted from date fruit images are used, it is stated that the SVM classifier, ANN, random forest (RF), and decision trees (DT) give better results than the classification approaches. As a result of the classification of features obtained from date fruit images, with two different neural network models, which are back propagation and radial basis function (RBF) networks, and the method of multilayer perceptron (MLP), 87.5% and 91.1% success performances were achieved, respectively [16].In a study using barley grains, features were extracted using the Spatial Pyramid Partition Ensemble computer vision method, and machine learning methods were classified. They achieved 75% success with the kNN model and 100% success with the J48 model [17].Date fruit, which has many varieties throughout the world, is used in the production of food, medical, and cosmetic products [18]. Expert opinion is needed to distinguish date fruit varieties due to different nutritional value, different consumption times, different prices, and quality differences [13]. Computer vision systems are used without the need for an expert in order to quickly distinguish the quality, size, and type of date varieties [19, 20]. In this way, the process from the production stage to the consumption stage can be shortened [21]. With this type of agricultural technologies, it is possible to increase the productivity in the agricultural industry [22].When the literature is examined, it is seen that various machine learning methods have been tried for the classification of the date fruit. There are not many studies in which hybrid methods such as the stacking model is used. Within the scope of this study, as well as the models based on the LR and ANN, the stacking model that combine works according to the results of these two models have been tried. By using these models, date fruits were classified with a total of 34 features such as morphological, shape, and color characteristics obtained from date fruits. While determining these features, other studies on the field were also considered, and it was investigated whether the classification success is impacted by the number of features extracted.In the second chapter, information on the methods of image acquisition, image processing, feature extraction, and success performance analysis will be given. In the third chapter, the LR, ANN, and stacking methods will be explained. In the fourth chapter, the results of the study will be presented. Last, in the fifth chapter, suggestions will be made together with the evaluation of the study.


## 2. Materials and Methods

In this section, acquisition of date fruit images, features extraction, and also the logistic regression (LR), artificial neural network (ANN), and stacking methods used for the classification process will be explained. Besides, the performance metrics of the classification results will be given. Figure1 shows the general process steps of the study.Figure 1
Process steps for classification of date fruit.Accordingly, the steps performed are image acquisition, images processing, and feature extraction. Afterwards, the performance analyzes were evaluated by completing classification processes carried out according to LR, ANN, and stacking methods.


### 2.1. Image Acquisition

In this study, the classification process was performed for 7 different date fruit types, that are, Barhee, Deglet Nour, Sukkary, Rotab Mozafati, Ruthana, Safawi, and Sagai. Barhee 65, Deglet Nour 98, Sukkary 204, Rotab Mozafati 72, Ruthana 166, Safawi 199, and Sagai 94 samples were used from palm varieties, respectively. Date fruit is a fruit grown in countries neighboring Turkey. Therefore, access to varieties is very easy. There is a market where many types of dates are sold. In the study, ready-to-eat date fruits obtained from these markets were used. A CVS was set up such as the system given in Figure2, for the image acquisition and captured images of the date fruits were transferred to the computer environment. The camera used in the setup is placed on a closed box with an LED light system. The future robot S100 series smart camera used to capture images has a resolution of 1280 × 1024. This camera, which has a CMOS-type 1.3 MP sensor, captures 90 FPS images in order to quickly take images in the installed conveyor system.Figure 2
Example of the system established to obtain images.The images of date fruits were obtained via a mechanism that does not receive external light, so that preprocesses can be completed quickly. During image processing, the background and shadows should be cleaned according to the band speed and ambient light conditions [23]. Via automatically cleaning the shadows and background color that emerged during the illumination, clear date fruit images were obtained. Green color is used in the background in order to easily distinguish the palm image from the background. RGB values of green color were determined as R = 106, G = 210, and B = 175. Using these color values, the image was color filtered, and the date fruit image was obtained without a background [24]. This process is shown in Figure 3. In the study, classification processes were performed with features extracted from 898 images of 7 different date fruit types.Figure 3
Processing the obtained images of the palm fruit stages. (a) Initial status. (b) Cleaned status. (c) Final status.
(a)(b)(c)


### 2.2. Image Processing and Extraction of Morphological Features

The obtained images were converted into grayscale and binary images for feature extraction. Basically, the operations were performed on methodologies of threshold and pixel information. At the end of the image processing, each date fruit was examined separately, and a set of features were extracted from them. The Otsu method, one of the commonly used image thresholding techniques, was used within the scope of the study [25]. This method specifies a variable that can distinguish between two or more groups found in nature. Generally working on gray level images, the method only checks how many times each color is present on the image. Therefore, the color distributions of the images are first calculated, and then, all processes are performed on this distribution sequence.The progress of the method can be briefly summarized as follows:(1)
The distribution and probabilities of each density level are calculated(2)
Initial settingωi0 and μi0(3)
Step by stept = 1 maximum density for all possible thresholds(a)
Update forωi and μi(b)
Calculation forσb2t(4)
The desired threshold corresponds to the maximum valueσb2tA total of 34 features, including also 12 morphological [26], 4 shape [27], and 18 color [28] features, were extracted [29]. The features used in the study are given in Table 1.Table 1
Features depending on the external appearance used in the study.
Main featuresSubfeaturesMorphological featuresAreaEquivalent diameterPerimeterSolidityMajor axisConvex_areaMinor axisExtentEccentricityAspect ratioRoundnessCompactnessShape featuresShapefactor_1Shapefactor_3Shapefactor_2Shapefactor_4Color featuresMean RRMean RGMean RRStd. dev RRStd. dev RGStd. dev RRSkew RRSkew RGSkew RRKurtosis RRKurtosis RGKurtosis RREntropy RREntropy RGEntropy RRAll Daub4 RRAll Daub4 RGAll Daub4 RR


### 2.3. Date Fruit Features Dataset

The date fruit types selected to be examined in the study are Barhee from the Palestinian region, Deglet Nour from the Algeria region, Sukkary, Safawi, Sagai, and Ruthana from the Saudi Arabia Riyadh and Medina region, and Rotab Mozafati from the Iran region. These selected date fruits are the most common and frequently grown types in their region of belonging. Table2 provides the general characteristics of the date fruit types used in the study, while Table 3 provides places to statistical averages of the features obtained from the date fruits.Table 2
Date fruits used in the study and their features.
Date fruit typeImagesColor and sizeOriginsBarheeIt is amber in color at harvest and then turns a golden-brown color. It is small to medium in size with a hard shellBasra, IraqDeglet NourIt is a medium- to large-sized date fruits variety that matures from amber to dark brown after harvestNot specificSukkaryIt is golden in color and is a medium-sized date fruits varietyAl Qassim region, Saudi ArabiaRotab MozafatiIt has a full, dark brown appearance. It is a medium-sized and fleshy date varietyKerman, IranRuthanaIt has brown and gold colors. It is a medium-sized date fruit varietyMadinah, Saudi ArabiaSafawiIt has a dark black cherry color and the tips are brown. It is a medium-sized date fruit varietyMadina, Saudi ArabiaSagaiThe tips are dry, golden in color, and the undersides are brown and soft. It is a medium-sized date varietyArabian Peninsula, especially Saudi ArabiaTable 3
Statistical averages of the features extracted from date fruits.
FeatureBarheeDeglet NourSukkaryRotab MozafatiRuthanaSafawiSagaiArea405213.4000233743.3571145147.4000433983.6000387115.9000334367.8000286873.0000Perimeter2321.50501831.44201436.32102411.04602376.31002329.18602051.2770Major axis815.3703680.2224537.8438836.1045832.4755881.3856755.9785Minor axis634.6560440.2732342.9496664.3262599.8809488.4889492.6769Eccentricity0.62140.75660.76330.59500.68690.82640.7519Equivalent diameter716.9042543.4765427.5469742.7018701.0097650.1046602.3296Solidity0.99400.98430.98720.99310.98030.97340.9712Convex_area407666.2000237428.9082147027.0000436990.5000394846.1000343399.9000295203.7000Extent0.76650.76080.75510.76390.73670.68690.7314Aspect ratio1.28851.55001.56591.26181.39204.48361.5369Roundness0.94130.87070.87660.93690.86000.77620.8535Compactness0.87970.80040.79800.88980.84300.74050.7987Shapefactor_10.00200.00300.00380.00190.00220.00570.0027Shapefactor_20.00160.00190.00240.00150.00160.00150.0017Shapefactor_30.77460.64200.63780.79290.71160.55210.6392Shapefactor_40.99420.98820.99270.99450.98530.98970.9760


### 2.4. Performance Analysis

In numerous fields of science, classification techniques have been applied for many problems. There are several ways to evaluate the classification algorithms. To evaluate the classification algorithms, the correct metric analysis must be interpreted correctly [30, 31]. The confusion matrix summarizes the correct and incorrect classifications, in the form of a table [32].True positive (TP) refers to correctly classified positive samples, true negative (TN) refers to correctly classified negative samples, false positive (FP) refers to incorrectly classified positive samples, and false negative (FN) refers to incorrectly classified negative samples. A seven-class confusion matrix was used since a seven-class classification problem was worked on in the research. The multiclass confusion matrix used is given in Table4.Table 4
Seven-class confusion matrix.
PredictedBarheeDeglet NourSukkaryRotab MozafatiRuthanaSafawiSagaiActualBarheeT1F12F13F14F15F16F17Deglet NourF21T2F23F24F25F26F27SukkaryF31F32T3F34F35F36F37Rotab MozafatiF41F42F43T4F45F46F47RuthanaF51F52F53F54T5F56F57SafawiF61F62F63F64F65T6F67SagaiF71F72F73F74F75F76T7To make the detailed performance analysis of the models, there are different metrics besides the classification success [33]. F-score, precision, recall, and specificity metrics are the other metrics utilized to measure models’ performance. Calculation of performance metrics with a seven-class confusion matrix is given in Table 5.Table 5
Performance metrics equation for seven-class.
MetricsEquationAverage accuracyTPi+TNi/TPi+TNi+FPi+FNiAverage precision (P)TPi/TPi+FPiAverage recall (R)TPi/TPi+FNiAverage F-score2∗Pi+Ri/Pi+RiAverage specificityTNi/TNi+FPiAUC (area under the curve)–ROC (receiver operating characteristic curve), which is another method to be used when it is necessary to control or visualize the performance of multiclass classification problems, is one of the most important evaluation criteria to check the performance of any classification model [34]. It is a performance measurement for classification problem at various threshold settings. Each point on the ROC curve represents a sensitivity/specificity pair corresponding to a certain decision threshold. A test with perfect separation has a ROC curve that passes through the upper left corner (100% sensitivity and 100% specificity). Therefore, the closer the ROC curve is to the upper left corner, the higher the overall accuracy of the test [35].


## 2.1. Image Acquisition

In this study, the classification process was performed for 7 different date fruit types, that are, Barhee, Deglet Nour, Sukkary, Rotab Mozafati, Ruthana, Safawi, and Sagai. Barhee 65, Deglet Nour 98, Sukkary 204, Rotab Mozafati 72, Ruthana 166, Safawi 199, and Sagai 94 samples were used from palm varieties, respectively. Date fruit is a fruit grown in countries neighboring Turkey. Therefore, access to varieties is very easy. There is a market where many types of dates are sold. In the study, ready-to-eat date fruits obtained from these markets were used. A CVS was set up such as the system given in Figure2, for the image acquisition and captured images of the date fruits were transferred to the computer environment. The camera used in the setup is placed on a closed box with an LED light system. The future robot S100 series smart camera used to capture images has a resolution of 1280 × 1024. This camera, which has a CMOS-type 1.3 MP sensor, captures 90 FPS images in order to quickly take images in the installed conveyor system.Figure 2
Example of the system established to obtain images.The images of date fruits were obtained via a mechanism that does not receive external light, so that preprocesses can be completed quickly. During image processing, the background and shadows should be cleaned according to the band speed and ambient light conditions [23]. Via automatically cleaning the shadows and background color that emerged during the illumination, clear date fruit images were obtained. Green color is used in the background in order to easily distinguish the palm image from the background. RGB values of green color were determined as R = 106, G = 210, and B = 175. Using these color values, the image was color filtered, and the date fruit image was obtained without a background [24]. This process is shown in Figure 3. In the study, classification processes were performed with features extracted from 898 images of 7 different date fruit types.Figure 3
Processing the obtained images of the palm fruit stages. (a) Initial status. (b) Cleaned status. (c) Final status.
(a)(b)(c)


## 2.2. Image Processing and Extraction of Morphological Features

The obtained images were converted into grayscale and binary images for feature extraction. Basically, the operations were performed on methodologies of threshold and pixel information. At the end of the image processing, each date fruit was examined separately, and a set of features were extracted from them. The Otsu method, one of the commonly used image thresholding techniques, was used within the scope of the study [25]. This method specifies a variable that can distinguish between two or more groups found in nature. Generally working on gray level images, the method only checks how many times each color is present on the image. Therefore, the color distributions of the images are first calculated, and then, all processes are performed on this distribution sequence.The progress of the method can be briefly summarized as follows:(1)
The distribution and probabilities of each density level are calculated(2)
Initial settingωi0 and μi0(3)
Step by stept = 1 maximum density for all possible thresholds(a)
Update forωi and μi(b)
Calculation forσb2t(4)
The desired threshold corresponds to the maximum valueσb2tA total of 34 features, including also 12 morphological [26], 4 shape [27], and 18 color [28] features, were extracted [29]. The features used in the study are given in Table 1.Table 1
Features depending on the external appearance used in the study.
Main featuresSubfeaturesMorphological featuresAreaEquivalent diameterPerimeterSolidityMajor axisConvex_areaMinor axisExtentEccentricityAspect ratioRoundnessCompactnessShape featuresShapefactor_1Shapefactor_3Shapefactor_2Shapefactor_4Color featuresMean RRMean RGMean RRStd. dev RRStd. dev RGStd. dev RRSkew RRSkew RGSkew RRKurtosis RRKurtosis RGKurtosis RREntropy RREntropy RGEntropy RRAll Daub4 RRAll Daub4 RGAll Daub4 RR


## 2.3. Date Fruit Features Dataset

The date fruit types selected to be examined in the study are Barhee from the Palestinian region, Deglet Nour from the Algeria region, Sukkary, Safawi, Sagai, and Ruthana from the Saudi Arabia Riyadh and Medina region, and Rotab Mozafati from the Iran region. These selected date fruits are the most common and frequently grown types in their region of belonging. Table2 provides the general characteristics of the date fruit types used in the study, while Table 3 provides places to statistical averages of the features obtained from the date fruits.Table 2
Date fruits used in the study and their features.
Date fruit typeImagesColor and sizeOriginsBarheeIt is amber in color at harvest and then turns a golden-brown color. It is small to medium in size with a hard shellBasra, IraqDeglet NourIt is a medium- to large-sized date fruits variety that matures from amber to dark brown after harvestNot specificSukkaryIt is golden in color and is a medium-sized date fruits varietyAl Qassim region, Saudi ArabiaRotab MozafatiIt has a full, dark brown appearance. It is a medium-sized and fleshy date varietyKerman, IranRuthanaIt has brown and gold colors. It is a medium-sized date fruit varietyMadinah, Saudi ArabiaSafawiIt has a dark black cherry color and the tips are brown. It is a medium-sized date fruit varietyMadina, Saudi ArabiaSagaiThe tips are dry, golden in color, and the undersides are brown and soft. It is a medium-sized date varietyArabian Peninsula, especially Saudi ArabiaTable 3
Statistical averages of the features extracted from date fruits.
FeatureBarheeDeglet NourSukkaryRotab MozafatiRuthanaSafawiSagaiArea405213.4000233743.3571145147.4000433983.6000387115.9000334367.8000286873.0000Perimeter2321.50501831.44201436.32102411.04602376.31002329.18602051.2770Major axis815.3703680.2224537.8438836.1045832.4755881.3856755.9785Minor axis634.6560440.2732342.9496664.3262599.8809488.4889492.6769Eccentricity0.62140.75660.76330.59500.68690.82640.7519Equivalent diameter716.9042543.4765427.5469742.7018701.0097650.1046602.3296Solidity0.99400.98430.98720.99310.98030.97340.9712Convex_area407666.2000237428.9082147027.0000436990.5000394846.1000343399.9000295203.7000Extent0.76650.76080.75510.76390.73670.68690.7314Aspect ratio1.28851.55001.56591.26181.39204.48361.5369Roundness0.94130.87070.87660.93690.86000.77620.8535Compactness0.87970.80040.79800.88980.84300.74050.7987Shapefactor_10.00200.00300.00380.00190.00220.00570.0027Shapefactor_20.00160.00190.00240.00150.00160.00150.0017Shapefactor_30.77460.64200.63780.79290.71160.55210.6392Shapefactor_40.99420.98820.99270.99450.98530.98970.9760


## 2.4. Performance Analysis

In numerous fields of science, classification techniques have been applied for many problems. There are several ways to evaluate the classification algorithms. To evaluate the classification algorithms, the correct metric analysis must be interpreted correctly [30, 31]. The confusion matrix summarizes the correct and incorrect classifications, in the form of a table [32].True positive (TP) refers to correctly classified positive samples, true negative (TN) refers to correctly classified negative samples, false positive (FP) refers to incorrectly classified positive samples, and false negative (FN) refers to incorrectly classified negative samples. A seven-class confusion matrix was used since a seven-class classification problem was worked on in the research. The multiclass confusion matrix used is given in Table4.Table 4
Seven-class confusion matrix.
PredictedBarheeDeglet NourSukkaryRotab MozafatiRuthanaSafawiSagaiActualBarheeT1F12F13F14F15F16F17Deglet NourF21T2F23F24F25F26F27SukkaryF31F32T3F34F35F36F37Rotab MozafatiF41F42F43T4F45F46F47RuthanaF51F52F53F54T5F56F57SafawiF61F62F63F64F65T6F67SagaiF71F72F73F74F75F76T7To make the detailed performance analysis of the models, there are different metrics besides the classification success [33]. F-score, precision, recall, and specificity metrics are the other metrics utilized to measure models’ performance. Calculation of performance metrics with a seven-class confusion matrix is given in Table 5.Table 5
Performance metrics equation for seven-class.
MetricsEquationAverage accuracyTPi+TNi/TPi+TNi+FPi+FNiAverage precision (P)TPi/TPi+FPiAverage recall (R)TPi/TPi+FNiAverage F-score2∗Pi+Ri/Pi+RiAverage specificityTNi/TNi+FPiAUC (area under the curve)–ROC (receiver operating characteristic curve), which is another method to be used when it is necessary to control or visualize the performance of multiclass classification problems, is one of the most important evaluation criteria to check the performance of any classification model [34]. It is a performance measurement for classification problem at various threshold settings. Each point on the ROC curve represents a sensitivity/specificity pair corresponding to a certain decision threshold. A test with perfect separation has a ROC curve that passes through the upper left corner (100% sensitivity and 100% specificity). Therefore, the closer the ROC curve is to the upper left corner, the higher the overall accuracy of the test [35].


## 3. Classification Models

In order to evaluate the proposed classification methods, a dataset was created with the features extracted from date fruits. LR and ANN models and the stacking model created by combining these two models were used in classification processes.


### 3.1. Logistic Regression Analysis

The logistic regression method is often used to analyze the probability of the outcome emergence using the relationship between two or more variables. The result is obtained by fitting the achieved logarithmic ratios and explanatory variables to a linear model [36]. Logistic regression analysis is calculated as(1)logPY=1|X1−PY=1|X=β0+β1X1+⋯+βnXn,where Y=0,1 is the binary variable, X=X1,…,Xn are the “n” explanatory variables, and β=β0,…,βn are the regression coefficients to be estimated based on the data. The logistic regression model is an analysis method that is frequently used in many fields from physical sciences to social sciences, such as engineering [37], biomedicine [38], social sciences [39], and agriculture [40]. Consequently, logistic regression analysis is used to analyze a dataset with one or more independent variables that determine a result [41, 42].


### 3.2. Artificial Neural Network

An artificial neural network (ANN) is a set of algorithms trying to recognize the main associations in a dataset that mimics the way of human brain works [43, 44]. In computer science, on the other hand, the neural network (ANN) model is a simple basic mathematical model that describes a function of F:X⟶Y in which nonlinear relationships between input variables on the X side and output variables on the Y side can be determined [45]. It is used in many basic fields such as engineering [46], medicine [47], agriculture [48], and social sciences [49]. The “neuron” in a neural network is a mathematical function that collects and classifies the information according to a particular architecture. The network has a strong resemblance to statistical methods such as curve fitting and regression analysis [50].


### 3.3. Stacking

Stacking is a machine learning algorithm in which two or more models are trained to solve the same problem and combined to achieve better results. Mainly, it aims at obtaining more accurate and/or robust models when the weak models are combined correctly and can be obtained. For this reason, it has been observed that the classification performance is improved by combining the estimations of multiple different classifiers under a single robust estimation [51, 52]. By combining the ANN and LR methods and with the results obtained with these models, the stacking model was created. The created model is shown in Figure 4.Figure 4
The created stacking model.


## 3.1. Logistic Regression Analysis

The logistic regression method is often used to analyze the probability of the outcome emergence using the relationship between two or more variables. The result is obtained by fitting the achieved logarithmic ratios and explanatory variables to a linear model [36]. Logistic regression analysis is calculated as(1)logPY=1|X1−PY=1|X=β0+β1X1+⋯+βnXn,where Y=0,1 is the binary variable, X=X1,…,Xn are the “n” explanatory variables, and β=β0,…,βn are the regression coefficients to be estimated based on the data. The logistic regression model is an analysis method that is frequently used in many fields from physical sciences to social sciences, such as engineering [37], biomedicine [38], social sciences [39], and agriculture [40]. Consequently, logistic regression analysis is used to analyze a dataset with one or more independent variables that determine a result [41, 42].


## 3.2. Artificial Neural Network

An artificial neural network (ANN) is a set of algorithms trying to recognize the main associations in a dataset that mimics the way of human brain works [43, 44]. In computer science, on the other hand, the neural network (ANN) model is a simple basic mathematical model that describes a function of F:X⟶Y in which nonlinear relationships between input variables on the X side and output variables on the Y side can be determined [45]. It is used in many basic fields such as engineering [46], medicine [47], agriculture [48], and social sciences [49]. The “neuron” in a neural network is a mathematical function that collects and classifies the information according to a particular architecture. The network has a strong resemblance to statistical methods such as curve fitting and regression analysis [50].


## 3.3. Stacking

Stacking is a machine learning algorithm in which two or more models are trained to solve the same problem and combined to achieve better results. Mainly, it aims at obtaining more accurate and/or robust models when the weak models are combined correctly and can be obtained. For this reason, it has been observed that the classification performance is improved by combining the estimations of multiple different classifiers under a single robust estimation [51, 52]. By combining the ANN and LR methods and with the results obtained with these models, the stacking model was created. The created model is shown in Figure 4.Figure 4
The created stacking model.


## 4. Experimental Results

In order to classify the date fruits used in the study, the features of 898 preprocessed date fruits were extracted. In total, 34 features were extracted for each date fruit based on 3 main features, which are morphological, shape, and color features. A dataset was created with these extracted features. For the classification process, ANN and LR models were created and performance metrics were obtained. In addition, the performance metrics of the stacking model created by combining these two models were compared with both models. The cross-validation method, a method for splitting the dataset into parts, was used to evaluate the classification models and to train the model [53]. With this method, the dataset is split into a certain number of subsets as training and testing. In the study shown in Figure 5, the number of sample repetitions (k) was determined as 10.Figure 5
Cross-validation example preferred for the study.The performance results were evaluated with the ROC curve and confusion matrix. Table6 provides the AUC value, accuracy, F1 score, precision value, recall value, and specificity value, which are the performance metrics of classification measurements, respectively. According to the table, ANN and LR methods have achieved success over 90%. By obtaining the highest accuracy of 92.8% with the stacking model, a combination of these two models, high success was obtained from both models applied separately. The confusion matrix values are given in Table 7 for all models.Table 6
Performance results of classification performances.
ModelAUCCaF1PrecisionRecallSpecificityStacking0.9910.9280.9270.9270.9280.988Neural network0.9930.9220.9220.9210.9220.987Logistic regression0.9910.9100.9070.9080.9100.984Table 7
Confusion matrix of all models.
Methods LR, ANN, stackingPredictedBarheeDeglet NourSukkaryRotab MozafatiRuthanaSafawiSagai∑ActualBarhee54006302655800510158005101Deglet Nour06319031129807412001110731300111Sukkary041990001204071960001061970001Rotab Mozafati20067201723006720030067200Ruthana010016104166130016101120016102Safawi001001962199001101961001001971Sagai0110033779411200327619002280∑56792197317220099898According to the confusion matrix, Safawi is the date fruit with the highest classification success for all models, while Barhee is the model with the lowest classification success.In machine learning, AUC-ROC curve is also utilized for evaluating the performance of a classification problem. In the AUC-ROC curves (Figure6) obtained for each date fruit in the study, the x-axis shows the FP ratio and the y-axis shows the TP ratio. When the AUC-ROC curves are examined, it is seen that the success performance is high in Safawi date fruit. The closer the upper left corner of the curve is to 1, the better the success performance.Figure 6
AUC-ROC curves of the methods used for each date fruit in the study. (a) Barhee date fruit. (b) Deglet Nour date fruit. (c) Sukkary date fruit. (d) Rotab Mozafati date fruit. (e) Ruthana date fruit. (f) Safawi date fruit. (g) Sagai date fruit.
(a)(b)(c)(d)(e)(f)(g)


## 5. Conclusions

In this study, a system has been put forth, with the aim of classifying the date fruits automatically without needing time-consuming and complex physical measurements. When previous studies are examined, it is seen that LR and ANN basic machine learning methods have been tried in classification with extracting more features from a date fruit. Furthermore, better results were obtained through the stacking method created by combining these two methods. In classification studies, high performance results in classification can be achieved not only with common machine learning methods but also with new stacking methods to be created by combining two or more of these methods. More successful results can be obtained by developing end-to-end classification models using the images of date fruit with deep learning models. Inspired by this study, it can be presented to the service of the users with the date fruit classification program with the help of a software on mobile phones. With the developed smartphone application, it is thought that consumers can have information about the type by classifying any date fruit sold over the counter. By extracting more features in classification studies, it is thought that success rates can be increased in the classification of not only date fruits but also other vegetables, fruits, legumes, or any object.



---

*Source: 4793293-2021-11-10.xml*