# Apple Variety Identification Using Near-Infrared Spectroscopy

Authors: Caihong Li; Lingling Li; Yuan Wu; Min Lu; Yi Yang; Lian Li
Journal: Journal of Spectroscopy
 (2018)

---

## Abstract

Near-infrared (NIR) spectra of apple samples were submitted in this paper to principal component analysis (PCA) and successive projections algorithm (SPA) to conduct variable selection. Three pattern recognition methods, backpropagation neural network (BPNN), support vector machine (SVM), and extreme learning machine (ELM), were applied to establish models for distinguishing apples of different varieties and geographical origins. Experimental results show that ELM models performed better on identifying apple variety and geographical origin than others. Especially, the SPA-ELM model could reach 98.33% identification accuracy on the calibration set and 96.67% on the prediction set. This study suggests that it is feasible to identify apple variety and cultivation region by using NIR spectroscopy.


---

## Body

## 1. Introduction

China is one of the main fruit-producing and fruit-consuming countries in the world. In recent years, both the area for fruit cultivation and the yield of fruits were increased continuously. Since apple has advantages of high nutrient value, high storage, and short supply cycle, it has become one of the four major fruits in the world. In 2014, the apple cultivation area and production in China reached 22724 km2 and 40.93 million tons, respectively, according to the Food and Agriculture Organization (FAO) report. The overall quality of apple could be determined by external attributes (such as size, colour, and texture) and internal attributes (such as soluble solid content (SSC), total acid content (TAC), and vitamins). These attributes are greatly affected by the variety and cultivation region of apple. Different apple has specific firmness, crispness, juiciness, and taste. Apple fruits that are firm, crispy, juicy, and tasteful are more popular among consumers [1]. Moreover, apples of different varieties or geographical origins could be easily mixed during harvesting and marketing. Therefore, effective and reliable technologies that could identify apple variety and geographical origin are demanded urgently by sellers and consumers.To determine the variety of fruits, many methodologies have been explored, such as deoxyribonucleic acid (DNA) analysis [2, 3], gas chromatography (GC) analysis [4], and amino acid composition [5]. However, these methods are always containing a considerable amount of time, manual work, and sample preparation [6].NIR spectroscopy, as a rapid nondestructive detection method, has been proven effective in determining the internal quality attributes of various agricultural products and food [7–11]. Compared with conventional chemical and physical analytical technologies, NIR spectroscopy has the advantages of easy operation, fast detecting speed, and nondestructive measurement. NIR spectral data have information that are concerning the relative proportions of C-H, N-H, and O-H bands which are the main structural constituents of organic molecules [12, 13]. Many studies explored the application of NIR spectroscopy on SSC measurement of fruits, such as apple [14, 15], kiwifruit [16], and grape [17].The main object of this study is to explore the feasibility of applying NIR spectroscopy for distinguishing apple variety and geographical origin. NIR diffuse reflectance spectra of 6 different apples (Fuji apple from Shandong, Fuji apple from Shaanxi, Red Star apple from Shandong, Red Star apple from Shaanxi, Gala apple from Shandong, and Gala apple from Shaanxi) were collected. Two variable selection algorithms were used, and three modelling methods were applied to establish models for distinguishing apples of different species and geographical origins. The capabilities of different models to identify apple variety and cultivation region were also investigated.


## 2. Materials and Methods

### 2.1. Sample Preparation

100 Fuji apples (50 from Shandong and 50 from Shaanxi), 100 Red Star apples (50 from Shandong and 50 from Shaanxi), and 100 Gala apples (50 from Shandong and 50 from Shaanxi) were purchased from two main local markets (Table1). The retailers guaranteed the apples’ varieties and cultivation regions, and the skins of these samples were smooth and perfect. Before measurements, all samples were placed in airtight polyethylene bags and stored in a refrigerator to keep at cold temperature (4 ± 1°C) for 2 days. After storage, the apples were taken away from refrigerator, washed with clean water, wiped dry, and kept at room temperature (24 ± 2°C) for about 3 hours, and then they were used for measurements.Table 1
Source of apple samples.
Variety
Origin
Total fruit samples
Calibration set
Prediction set
Fuji
Shandong
50
30
20
Fuji
Shaanxi
50
30
20
Red Star
Shandong
50
30
20
Red Star
Shaanxi
50
30
20
Gala
Shandong
50
30
20
Gala
Shaanxi
50
30
20
Total
300
180
120In this study, 40 Fuji apples (20 from Shandong and 20 from Shaanxi), 40 Red Star apples (20 from Shandong and 20 from Shaanxi), and 40 Gala apples (20 from Shandong and 20 from Shaanxi) were selected randomly as the prediction set, and the remaining 180 apples were used as the calibration set. The calibration set was used to establish models, and the prediction set was used to evaluate the performances of the established models.


### 2.2. Spectra Acquisition

The NIR spectra were collected in diffuse reflectance mode using Ocean Optics USB2000-VIS-NIR-ES spectrometer (Ocean optics, USA), equipped with HL-2000 tungsten halogen light sources (Ocean optics, USA), and optical fibre reflection Probes (QR600-7-VIS-NIR, Ocean optics, USA). The NIR diffuse reflectance spectra were collected between 400 and 1021 nm with an internal of about 0.33 nm, which resulted in 1888 variables for each spectrum. Software Ocean View (Ocean optics, USA) was used to collect and transform the spectra. All measurements were undertaken at room temperature (24 ± 2°C).Before measuring the spectra, the spectrometer was turned on for at least 1 hour for warming up. When measuring the spectra, the NIR optical fibre probe was kept close to the surface of apple in order to avoid surface reflectance and air interference. For each intact apple sample, the diffuse reflectance spectra was obtained at 15 different points that were randomly chosen along the equator, and each location was scanned 10 times for spectra measurements. Thus, a total of 150 scans were averaged to represent the spectral data for one apple and then used in further data analysis.


### 2.3. Principal Component Analysis

PCA is a very effective data mining technique and has been widely used for dealing with spectra data [18]. The principle of PCA is to reduce data dimension and orthogonalize the original multidimensional data to obtain a set of values of linearly uncorrelated variables to minimize the chance of overfitting and improve the speed of training procedure. This set of values is called principal components (PCs). In the case of small size of data set, PCs are computed simultaneously from a single matrix decomposition. The first PC accounts for as much of the variability in the original data as possible, and each subsequent component has lower variance possible than the preceding one. PCA could transform high-dimensional data into lower dimensional data without losing original information [19]. In most cases, PCs have much smaller variable numbers, yet still provide information that could describe most of variance of the original data.


### 2.4. Successive Projections Algorithm

SPA is a forward variable selection method, and its purpose is to select wavelengths whose information is minimally redundant [20]. In the process of SPA, the first variable of spectral data is used as the initial variable x0 and then incorporates a new one at each iteration, until the preset number N is reached. At the next iteration, the second variable of spectral data is selected as the initial variable x1, until all variables are used as the initial one. SPA has been successfully applied to select variables in spectra [21, 22].For a classification problem, the number of extracted wavelengths could be determined byG value (validation cost) [23]:(1)G=1L∑i=1Lgi,where L is the number of the validation samples, and gi is defined as follows:(2)gi=r2xi,μIiminIj≠Iir2xi,μIi,where the numerator r2xi,μIi is the squared Mahalanobis distance between xi (a vector of the ith sample at the selected wavelengths by SPA) and μIi (the mean of the Ii-th variety apples at each wavelength). This numerator represents the squared Mahalanobis distance between xi and the closest wrong variety. gi should be as small as possible, which means xi is close to its true variety and distant from other varieties.


### 2.5. Backpropagation Neural Network

The BPNN model is considered as the most widely used type of artificial neural network (ANN) model [24]. BPNN has the properties of forward propagation of the signals and backpropagation of the errors. The general structure of BPNN has three layers: an input layer, a hidden layer, and an output layer (Figure 1). The weights and thresholds in the architecture could be adjusted automatically according to the backpropagation of errors.Figure 1
The general structure of BPNN model.


### 2.6. Support Vector Machine

The SVM, which is proposed by Vapnik and his colleagues, is a statistical method based on Vapnik-Chervonenkis (VC) dimension theory and the structural risk minimization (SRM) principle [25–27]. The target of SVM is to obtain the best compromise between complexity and learning ability of the model based on limited sample information. SVM has been applied in a considerable amount of studies in NIR spectroscopy as a discrimination method [28–30]. In this experiment, the radical basis function (RBF) was introduced as the kernel function for SVM models because RBF could reduce the computational complexity of training process. Cost parameter, which determines the trade-off between minimizing the training error and minimizing model complexity, and gamma parameter, which implicitly defines the nonlinear mapping from input space to certain higher dimensional space, are two main parameters in RBF kernel function. In the establishing processing of SVM models, the most important step is optimizing these two parameters [28].


### 2.7. Extreme Learning Machine

ELM, proposed by Huang [31], is a single-hidden layer feed forward neural network (SLFNs). ELM has advantages of learning fast with higher generalization performance and overcoming difficulties that are common in traditional gradient-based learning algorithms. The general structure of ELM is composed of three layers: an input layer, a hidden layer, and an output layer. It is important to select the number of neurons in the hidden layer for establishing a reliable ELM-based model because the number of neurons in the hidden layer influences the robustness and performance of the ELM model greatly. ELM randomly chooses and tunes the weights between the input layer and the hidden layer using continuous probability density function and sets the weights between the hidden layer and the output layer analytically.


### 2.8. Data Processing

In this study, all calculations were performed in Matlab R2014b (The Mathworks Inc., USA) under Windows 7 with 3.6 GHz CPU and 4 GB memory. Before the multivariate analysis, the raw spectral dataR were converted to absorbance values log1/R. To reduce the noise, Savitzky–Golay smoothing method was used, and the segment size was set to be 5. Then multivariate scatter correction (MSC), which modifies the additive and multiplicative effects [32], was applied on the denoised data. PCA and SPA were implemented to extract essential information from the whole spectral regions respectively, and then fewer variables were applied as the input for constructing models. Three different algorithms were used to establish models to identify apple varieties and geographical origins. These three methods were BPNN, SVM, and ELM. Figure 2 shows the flowchart of this procedure.Figure 2
The flowchart of data processing.In this experiment, the performance of the models was evaluated through identification accuracy. The identification accuracy was defined as(3)accuracy=number  ofTPs+TNsnumber  ofTPs+TNs+FPs+FNs×100%,where TP indicates true positive, which represents a positive sample was classified as a positive example; TN indicates true negative, which represents a negative sample was classified as a negative example; FP indicates false positive, which represents a negative sample was classified as a positive example; and FN indicates false negative, which represents a positive sample was classified as a negative example. The higher the classification accuracy reached, the better performance the model obtained.


## 2.1. Sample Preparation

100 Fuji apples (50 from Shandong and 50 from Shaanxi), 100 Red Star apples (50 from Shandong and 50 from Shaanxi), and 100 Gala apples (50 from Shandong and 50 from Shaanxi) were purchased from two main local markets (Table1). The retailers guaranteed the apples’ varieties and cultivation regions, and the skins of these samples were smooth and perfect. Before measurements, all samples were placed in airtight polyethylene bags and stored in a refrigerator to keep at cold temperature (4 ± 1°C) for 2 days. After storage, the apples were taken away from refrigerator, washed with clean water, wiped dry, and kept at room temperature (24 ± 2°C) for about 3 hours, and then they were used for measurements.Table 1
Source of apple samples.
Variety
Origin
Total fruit samples
Calibration set
Prediction set
Fuji
Shandong
50
30
20
Fuji
Shaanxi
50
30
20
Red Star
Shandong
50
30
20
Red Star
Shaanxi
50
30
20
Gala
Shandong
50
30
20
Gala
Shaanxi
50
30
20
Total
300
180
120In this study, 40 Fuji apples (20 from Shandong and 20 from Shaanxi), 40 Red Star apples (20 from Shandong and 20 from Shaanxi), and 40 Gala apples (20 from Shandong and 20 from Shaanxi) were selected randomly as the prediction set, and the remaining 180 apples were used as the calibration set. The calibration set was used to establish models, and the prediction set was used to evaluate the performances of the established models.


## 2.2. Spectra Acquisition

The NIR spectra were collected in diffuse reflectance mode using Ocean Optics USB2000-VIS-NIR-ES spectrometer (Ocean optics, USA), equipped with HL-2000 tungsten halogen light sources (Ocean optics, USA), and optical fibre reflection Probes (QR600-7-VIS-NIR, Ocean optics, USA). The NIR diffuse reflectance spectra were collected between 400 and 1021 nm with an internal of about 0.33 nm, which resulted in 1888 variables for each spectrum. Software Ocean View (Ocean optics, USA) was used to collect and transform the spectra. All measurements were undertaken at room temperature (24 ± 2°C).Before measuring the spectra, the spectrometer was turned on for at least 1 hour for warming up. When measuring the spectra, the NIR optical fibre probe was kept close to the surface of apple in order to avoid surface reflectance and air interference. For each intact apple sample, the diffuse reflectance spectra was obtained at 15 different points that were randomly chosen along the equator, and each location was scanned 10 times for spectra measurements. Thus, a total of 150 scans were averaged to represent the spectral data for one apple and then used in further data analysis.


## 2.3. Principal Component Analysis

PCA is a very effective data mining technique and has been widely used for dealing with spectra data [18]. The principle of PCA is to reduce data dimension and orthogonalize the original multidimensional data to obtain a set of values of linearly uncorrelated variables to minimize the chance of overfitting and improve the speed of training procedure. This set of values is called principal components (PCs). In the case of small size of data set, PCs are computed simultaneously from a single matrix decomposition. The first PC accounts for as much of the variability in the original data as possible, and each subsequent component has lower variance possible than the preceding one. PCA could transform high-dimensional data into lower dimensional data without losing original information [19]. In most cases, PCs have much smaller variable numbers, yet still provide information that could describe most of variance of the original data.


## 2.4. Successive Projections Algorithm

SPA is a forward variable selection method, and its purpose is to select wavelengths whose information is minimally redundant [20]. In the process of SPA, the first variable of spectral data is used as the initial variable x0 and then incorporates a new one at each iteration, until the preset number N is reached. At the next iteration, the second variable of spectral data is selected as the initial variable x1, until all variables are used as the initial one. SPA has been successfully applied to select variables in spectra [21, 22].For a classification problem, the number of extracted wavelengths could be determined byG value (validation cost) [23]:(1)G=1L∑i=1Lgi,where L is the number of the validation samples, and gi is defined as follows:(2)gi=r2xi,μIiminIj≠Iir2xi,μIi,where the numerator r2xi,μIi is the squared Mahalanobis distance between xi (a vector of the ith sample at the selected wavelengths by SPA) and μIi (the mean of the Ii-th variety apples at each wavelength). This numerator represents the squared Mahalanobis distance between xi and the closest wrong variety. gi should be as small as possible, which means xi is close to its true variety and distant from other varieties.


## 2.5. Backpropagation Neural Network

The BPNN model is considered as the most widely used type of artificial neural network (ANN) model [24]. BPNN has the properties of forward propagation of the signals and backpropagation of the errors. The general structure of BPNN has three layers: an input layer, a hidden layer, and an output layer (Figure 1). The weights and thresholds in the architecture could be adjusted automatically according to the backpropagation of errors.Figure 1
The general structure of BPNN model.


## 2.6. Support Vector Machine

The SVM, which is proposed by Vapnik and his colleagues, is a statistical method based on Vapnik-Chervonenkis (VC) dimension theory and the structural risk minimization (SRM) principle [25–27]. The target of SVM is to obtain the best compromise between complexity and learning ability of the model based on limited sample information. SVM has been applied in a considerable amount of studies in NIR spectroscopy as a discrimination method [28–30]. In this experiment, the radical basis function (RBF) was introduced as the kernel function for SVM models because RBF could reduce the computational complexity of training process. Cost parameter, which determines the trade-off between minimizing the training error and minimizing model complexity, and gamma parameter, which implicitly defines the nonlinear mapping from input space to certain higher dimensional space, are two main parameters in RBF kernel function. In the establishing processing of SVM models, the most important step is optimizing these two parameters [28].


## 2.7. Extreme Learning Machine

ELM, proposed by Huang [31], is a single-hidden layer feed forward neural network (SLFNs). ELM has advantages of learning fast with higher generalization performance and overcoming difficulties that are common in traditional gradient-based learning algorithms. The general structure of ELM is composed of three layers: an input layer, a hidden layer, and an output layer. It is important to select the number of neurons in the hidden layer for establishing a reliable ELM-based model because the number of neurons in the hidden layer influences the robustness and performance of the ELM model greatly. ELM randomly chooses and tunes the weights between the input layer and the hidden layer using continuous probability density function and sets the weights between the hidden layer and the output layer analytically.


## 2.8. Data Processing

In this study, all calculations were performed in Matlab R2014b (The Mathworks Inc., USA) under Windows 7 with 3.6 GHz CPU and 4 GB memory. Before the multivariate analysis, the raw spectral dataR were converted to absorbance values log1/R. To reduce the noise, Savitzky–Golay smoothing method was used, and the segment size was set to be 5. Then multivariate scatter correction (MSC), which modifies the additive and multiplicative effects [32], was applied on the denoised data. PCA and SPA were implemented to extract essential information from the whole spectral regions respectively, and then fewer variables were applied as the input for constructing models. Three different algorithms were used to establish models to identify apple varieties and geographical origins. These three methods were BPNN, SVM, and ELM. Figure 2 shows the flowchart of this procedure.Figure 2
The flowchart of data processing.In this experiment, the performance of the models was evaluated through identification accuracy. The identification accuracy was defined as(3)accuracy=number  ofTPs+TNsnumber  ofTPs+TNs+FPs+FNs×100%,where TP indicates true positive, which represents a positive sample was classified as a positive example; TN indicates true negative, which represents a negative sample was classified as a negative example; FP indicates false positive, which represents a negative sample was classified as a positive example; and FN indicates false negative, which represents a positive sample was classified as a negative example. The higher the classification accuracy reached, the better performance the model obtained.


## 3. Results and Discussion

### 3.1. NIR Spectra of Apple Samples

Figure3 shows the raw diffuse reflectance spectra of the experimented apple samples between 400 and 1021 nm. There are many crossovers and overlappings among these samples. The overall trends of the 300 apple spectra were similar. The absorbance spectra of all apple samples were similar, and there were no significant spectral differences among spectra of different varieties and geographical origins. Therefore, it was difficult to discriminate the variety and geographical origin directly based on the raw diffuse reflectance spectra. It is necessary to establish some models for identifying the apple variety and geographical origin.Figure 3
NIR spectra of all measured apples between 400 and 1021 nm.


### 3.2. Characteristic Wavelength Selection

A large amount of factors in the input vector may involve some irrelevant information and deteriorate the performance of models. In this study, we need to apply variable selection algorithms to the spectral data that had been preprocessed by Savitzky–Golay smoothing method and MSC. For PCA, Table2 lists the contribution rates and accumulative contribution rates of the first 8 PCs. It showed that the first PC provided the most contribution (87.47%) and the second PC contributed to 7.14%. The first two PCs could represent more than 94% of the original spectral data. In this experiment, since more variables involving in the process of constructing models may slow down the calculation speed, the first 6 PCs, whose accumulative contribution rate reached 99.27%, were selected as the input to develop models based on the criterion for an increment of explained variance lower than 0.25% [33].Table 2
The contribution and accumulative contribution rates of the first 8 PCs of the spectra.
PCs
PC1
PC2
PC3
PC4
PC5
PC6
PC7
PC8
Contribution rate (%)
87.47
7.14
2.97
0.87
0.52
0.30
0.14
0.08
Accumulative contribution rate (%)
87.47
94.61
97.58
98.45
98.97
99.27
99.41
99.49For SPA, Figure4 presents the changing G value with the number of wavelengths. The overall trend of G value decreased with the increased number of wavelengths. The best number of wavelengths could be achieved when the decrease rate of G value was lower than 5%, while the decrease was less than 0.01 [34]. In this experiment, the best number of wavelengths was 10. The selected wavelengths were 530.36, 547.81, 564.45, 587.67, 606.53, 624.58, 652.45, 665.77, 677.99, and 996.84 nm, respectively.Figure 4
TheG values under different numbers of wavelengths. The red × means the selected number of wavelengths.


### 3.3. Classification Models

For the BPNN models, the optimal number of neurons in the hidden layer was calculated by using leave-one-out cross validation in the range from 10 to 50 (large number of neurons in the hidden layer had no performance improvement in the experiment). Table3 lists the optimal number of the neurons in the hidden layer of BPNN models. The results for apple variety and geographical origin identification by BPNN models are given in Table 4. Obviously, the average performance was poor. Only identification accuracy of SPA-BPNN model on the calibration set was more than 50%.Table 3
The optimal number of neurons in the hidden layer of BPNN models.
Dimension reduction methods
The number of neurons
PCA
17
SPA
21Table 4
Classification accuracies of BPNN models.
Set
Calibration set
Prediction set
PCA (%)
SPA (%)
PCA (%)
SPA (%)
Fuji apple from Shandong
80
76.67
45
40
Fuji apple from Shaanxi
0
0
0
0
Red Star apple from Shandong
43.33
53.33
55
20
Red Star apple from Shaanxi
86.67
70
30
30
Gala apple from Shandong
10
43.33
5
65
Gala apple from Shaanxi
60
66.67
45
75
Average
46.67
51.67
30
38.33For the SVM models, the optimal values of cost and gamma parameters were selected through the leave-one-out cross validation method. Table5 lists the optimal values of cost and gamma parameters of SVM models. Table 6 gives the identification accuracy for apple variety and geographical origin by using SVM models. It can be seen that PCA-SVM model outperformed SPA-SVM model with average accuracy 98.89% on the calibration set and 85.83% on the prediction set.Table 5
The optimal values of cost and gamma parameters of SVM models.
Dimension reduction methods
Cost value
Gamma value
PCA
5.66
2
SPA
36.76
0.76Table 6
Classification accuracies of SVM models.
Set
Calibration set
Prediction set
PCA (%)
SPA (%)
PCA (%)
SPA (%)
Fuji apple from Shandong
100
93.33
75
45
Fuji apple from Shaanxi
96.67
93.33
55
80
Red Star apple from Shandong
100
90
100
65
Red Star apple from Shaanxi
96.67
93.33
95
90
Gala apple from Shandong
100
93.33
100
90
Gala apple from Shaanxi
100
73.33
90
65
Average
98.89
89.44
85.83
72.50When the variables extracted by PCA and SPA were used as the inputs for ELM models, the best numbers of the neurons in the hidden layer are listed in Table7. The identification results of ELM models are shown in Table 8. It showed that all ELM models could efficiently distinguish apple variety and geographical origin for both the calibration set and the prediction set with accuracy more than 90%. In particular, the identification accuracy of SPA-ELM model could reach more than 95% for both the calibration set and the prediction set.Table 7
The best number of the neurons in the hidden layer of ELM models.
Dimension reduction methods
Number
PCA
70
SPA
20Table 8
Classification accuracies of ELM models.
Set
Calibration set
Prediction set
PCA (%)
SPA (%)
PCA (%)
SPA (%)
Fuji apple from Shandong
100
100
95
100
Fuji apple from Shaanxi
96.67
100
95
100
Red Star apple from Shandong
100
100
80
100
Red Star apple from Shaanxi
100
100
95
90
Gala apple from Shandong
100
96.67
95
100
Gala apple from Shaanxi
100
93.33
95
90
Average
99.44
98.33
92.50
96.67When comparing all the established models, it could be found that ELM models had better performance than BPNN models and SVM models. It suggested that suitable intelligent algorithm could improve prediction performance. PCA-SVM model could identify Red Star apple from Shandong and Gala apple from Shandong with 100% accuracy, while SPA-ELM model has the ability of identifying Fuji apple from Shandong, Fuji apple from Shaanxi, and Red Star apple from Shandong with 100% accuracy.


## 3.1. NIR Spectra of Apple Samples

Figure3 shows the raw diffuse reflectance spectra of the experimented apple samples between 400 and 1021 nm. There are many crossovers and overlappings among these samples. The overall trends of the 300 apple spectra were similar. The absorbance spectra of all apple samples were similar, and there were no significant spectral differences among spectra of different varieties and geographical origins. Therefore, it was difficult to discriminate the variety and geographical origin directly based on the raw diffuse reflectance spectra. It is necessary to establish some models for identifying the apple variety and geographical origin.Figure 3
NIR spectra of all measured apples between 400 and 1021 nm.


## 3.2. Characteristic Wavelength Selection

A large amount of factors in the input vector may involve some irrelevant information and deteriorate the performance of models. In this study, we need to apply variable selection algorithms to the spectral data that had been preprocessed by Savitzky–Golay smoothing method and MSC. For PCA, Table2 lists the contribution rates and accumulative contribution rates of the first 8 PCs. It showed that the first PC provided the most contribution (87.47%) and the second PC contributed to 7.14%. The first two PCs could represent more than 94% of the original spectral data. In this experiment, since more variables involving in the process of constructing models may slow down the calculation speed, the first 6 PCs, whose accumulative contribution rate reached 99.27%, were selected as the input to develop models based on the criterion for an increment of explained variance lower than 0.25% [33].Table 2
The contribution and accumulative contribution rates of the first 8 PCs of the spectra.
PCs
PC1
PC2
PC3
PC4
PC5
PC6
PC7
PC8
Contribution rate (%)
87.47
7.14
2.97
0.87
0.52
0.30
0.14
0.08
Accumulative contribution rate (%)
87.47
94.61
97.58
98.45
98.97
99.27
99.41
99.49For SPA, Figure4 presents the changing G value with the number of wavelengths. The overall trend of G value decreased with the increased number of wavelengths. The best number of wavelengths could be achieved when the decrease rate of G value was lower than 5%, while the decrease was less than 0.01 [34]. In this experiment, the best number of wavelengths was 10. The selected wavelengths were 530.36, 547.81, 564.45, 587.67, 606.53, 624.58, 652.45, 665.77, 677.99, and 996.84 nm, respectively.Figure 4
TheG values under different numbers of wavelengths. The red × means the selected number of wavelengths.


## 3.3. Classification Models

For the BPNN models, the optimal number of neurons in the hidden layer was calculated by using leave-one-out cross validation in the range from 10 to 50 (large number of neurons in the hidden layer had no performance improvement in the experiment). Table3 lists the optimal number of the neurons in the hidden layer of BPNN models. The results for apple variety and geographical origin identification by BPNN models are given in Table 4. Obviously, the average performance was poor. Only identification accuracy of SPA-BPNN model on the calibration set was more than 50%.Table 3
The optimal number of neurons in the hidden layer of BPNN models.
Dimension reduction methods
The number of neurons
PCA
17
SPA
21Table 4
Classification accuracies of BPNN models.
Set
Calibration set
Prediction set
PCA (%)
SPA (%)
PCA (%)
SPA (%)
Fuji apple from Shandong
80
76.67
45
40
Fuji apple from Shaanxi
0
0
0
0
Red Star apple from Shandong
43.33
53.33
55
20
Red Star apple from Shaanxi
86.67
70
30
30
Gala apple from Shandong
10
43.33
5
65
Gala apple from Shaanxi
60
66.67
45
75
Average
46.67
51.67
30
38.33For the SVM models, the optimal values of cost and gamma parameters were selected through the leave-one-out cross validation method. Table5 lists the optimal values of cost and gamma parameters of SVM models. Table 6 gives the identification accuracy for apple variety and geographical origin by using SVM models. It can be seen that PCA-SVM model outperformed SPA-SVM model with average accuracy 98.89% on the calibration set and 85.83% on the prediction set.Table 5
The optimal values of cost and gamma parameters of SVM models.
Dimension reduction methods
Cost value
Gamma value
PCA
5.66
2
SPA
36.76
0.76Table 6
Classification accuracies of SVM models.
Set
Calibration set
Prediction set
PCA (%)
SPA (%)
PCA (%)
SPA (%)
Fuji apple from Shandong
100
93.33
75
45
Fuji apple from Shaanxi
96.67
93.33
55
80
Red Star apple from Shandong
100
90
100
65
Red Star apple from Shaanxi
96.67
93.33
95
90
Gala apple from Shandong
100
93.33
100
90
Gala apple from Shaanxi
100
73.33
90
65
Average
98.89
89.44
85.83
72.50When the variables extracted by PCA and SPA were used as the inputs for ELM models, the best numbers of the neurons in the hidden layer are listed in Table7. The identification results of ELM models are shown in Table 8. It showed that all ELM models could efficiently distinguish apple variety and geographical origin for both the calibration set and the prediction set with accuracy more than 90%. In particular, the identification accuracy of SPA-ELM model could reach more than 95% for both the calibration set and the prediction set.Table 7
The best number of the neurons in the hidden layer of ELM models.
Dimension reduction methods
Number
PCA
70
SPA
20Table 8
Classification accuracies of ELM models.
Set
Calibration set
Prediction set
PCA (%)
SPA (%)
PCA (%)
SPA (%)
Fuji apple from Shandong
100
100
95
100
Fuji apple from Shaanxi
96.67
100
95
100
Red Star apple from Shandong
100
100
80
100
Red Star apple from Shaanxi
100
100
95
90
Gala apple from Shandong
100
96.67
95
100
Gala apple from Shaanxi
100
93.33
95
90
Average
99.44
98.33
92.50
96.67When comparing all the established models, it could be found that ELM models had better performance than BPNN models and SVM models. It suggested that suitable intelligent algorithm could improve prediction performance. PCA-SVM model could identify Red Star apple from Shandong and Gala apple from Shandong with 100% accuracy, while SPA-ELM model has the ability of identifying Fuji apple from Shandong, Fuji apple from Shaanxi, and Red Star apple from Shandong with 100% accuracy.


## 4. Conclusion

In this study, the experiment results indicated that it was possible to develop a nondestructive technique to discriminate apple variety and cultivated region using NIR spectroscopy. PCA and SPA were applied to conduct variable selection of the spectra. BPNN, SVM, and ELM were used to establish models for distinguishing apple variety and geographical origin by using NIR diffuse reflectance spectroscopy. The results obtained from the experiments showed that it was feasible to identify apple variety and geographic origin using NIR spectroscopy in the range between 400 and 1021 nm, and the techniques were nondestructive. ELM models could give better identification accuracies than BPNN models and SVM models. For ELM models, PCA and SPA could both provide good performances. In particular, SPA-ELM could offer 98.33% accuracy for the calibration set and 96.67% accuracy for the prediction set. Therefore, this pattern would be suitable and effective for variety and geographical origin identification of apple fruits.



---

*Source: 6935197-2018-08-27.xml*