For experimentation, Artificial Neural Network classifier, Support Vector Machine and K-Nearest Neighbor classifiers were used. After distinctly testing morphological features and color features of Coffee bean images, a combination of these two features is used in this experiment. Classification was verified by using morphological features, color features and combination of both morphological and color features. There are two basic phases of classification used in this study. Those are training and testing phases. The trained system is applied to new data to check the performance of the classification in testing phase. The classifier was designed by dividing the total dataset into training and testing dataset. From the total dataset of each grade, 80% was used for training and 20% was used for testing data. This means that, out of the total 10, 000 datasets, 116 images (with 8000 piece of Coffee beans) were used for training and 29 images (with 2000 piece of Coffee beans) were used for testing.
A. Artificial neural network (ANN) classifier and its output
The network was trained to yield output 1000, 0100, 0010, 0001 in the correct class of the output vector for Grade I, Grade II, Grade III and Grade IV respectively. When the network was trained, the neuron number of the input layer be subject to the nominated features. The neuron numbers of hidden layers were sixteen (16) for the first hidden layer and ten (10) for the second hidden layer neurons. The neuron number of the output layer was four (4) established on the number of Coffee bean grade that were proposed for the study. When the network training was done, the network was confirmed with 20% of the total dataset. As anticipated, Matlab version R2018a software was used as artificial neural network simulation program. There were four (4) layers in ANN classifier which are an input layer consisting of nodes/parameters for morphological and color features, the two (2) hidden layers, and an output layer node representing the nominal ideals of the raw quality value of Coffee bean images which are Grade I, Grade II, Grade III, Grade IV. The simulation was piloted on the mutual color and morphological features of sample Coffee beans. The classifier yields for the modeling dataset partitions yielded meaningfully lower values of mean square errors and higher values of correlation coefficients. Eighty eight point two percent (88.2%) of the samples are classified correctly with respect to their real raw excellence value group.
Using morphological features
In this experimentation, ten (10) morphological features of Coffee were used as input to the network and the neuron numbers of the input layers were also ten (10). The output neurons were four (4) that resembles to four (4) predefined Coffee grade well-thought-out in this study. The network was trained by 80% of the total dataset and for computing performance of the trained network, 20% of the total dataset was used.
Table 1. Confusion matrix of morphological features in ANN
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
391
|
24
|
0
|
0
|
Grade-II
|
29
|
460
|
82
|
18
|
Grade-III
|
10
|
93
|
518
|
53
|
Grade-IV
|
0
|
14
|
8
|
360
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
90.93%
|
86.62%
|
85.19%
|
83.52
|
Correctly classified (Precision)
|
94.2%
|
78.2%
|
76.9%
|
94.2%
|
The Grade I Coffee was misclassified to the Grade II Coffee (6.7%) and Grade II Coffee was more misclassified to the Grade III Coffee (17.5%). This shows that there is a strong morphology relationship between Grade II and Grade III Coffee beans. A comparable appearance at the morphological feature of these Coffee been displays that their comparative bigger size from other beans. There is also a misclassification of Grade II and Grade III Coffee bean images to the Grade IV 2.6% and 1.4% respectively Coffees since the assembly and bean shapes of these Coffees were associated. The Grade I Coffees were not misclassified to Grade IV. Grade III and Grade IV Coffees were not misclassified to the Grade I because their morphological feature variances between them. The Grade IV Coffees were also misclassified to the Grade II and Grade III. In general, the morphological classification pattern in Artificial Neural Network classifiers was the best in performance accuracy. From the overall performance results, the overall classification accuracy was 86.45% under this experimentation. The ANN classifier yields best accuracy performances and also has compensations of compatibility with pool illumination in Coffee bean images.
Using Color Features
In this experimentation six (6) color features were used as input to the neural network and the neuron numbers of the input layer were also six (6). The output neurons were four (4) corresponds to the four (4) labeled Coffee grades for this study. The below Table 2 shows the summary result of artificial neural network classifier using color features. Out of the total test set of 2000 Coffee beans 59.1% were correctly classified and 40.9% were incorrectly classified.
Table 2: Confusion matrix of color features in ANN
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
296
|
33
|
51
|
25
|
Grade-II
|
68
|
280
|
199
|
33
|
Grade-III
|
48
|
192
|
318
|
85
|
Grade-IV
|
18
|
26
|
40
|
288
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
68.8%
|
52.74%
|
52.3%
|
66.8%
|
Correctly classified (Precision)
|
73.1%
|
50%
|
50.1%
|
77.4%
|
The Grade I Coffee was misclassified to all Grade II, III and IV Coffee, but it was classified more to Grade II Coffees (16%). Grade II Coffee was more misclassified to the Grade III Coffee (36%) and Grade Coffee III is also more misclassified to the Grade II Coffee (33%). Grade IV Coffee was classified to all other grades and more misclassified to the Grade III Coffee (18%). In addition, there is a significant misclassification among each Grade using color features. There is a better classification pattern than SVM and KNN color feature classification and also a better classification performance was obtained in most Grades than the others though there is a slight color difference in each Coffee grades. This shows that there is a slight difference in color between each grade Coffee.
Using aggregated Features
Table 3: Confusion matrix of aggregated features in ANN
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
403
|
9
|
6
|
0
|
Grade-II
|
12
|
480
|
61
|
13
|
Grade-III
|
14
|
40
|
529
|
41
|
Grade-IV
|
1
|
2
|
12
|
377
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
93.7%
|
90.39
|
87.00%
|
87.47%
|
Correctly classified (Precision)
|
96.4%
|
85%
|
84.7%
|
96.1
|
In this experimentation all of the three algorithms produce increased classification accuracy in terms of recall and it reflects the property of both features. The analysis result of this experiment yields good performance accuracy. But here also it can be concluded there is a great feature relation between Grade II and Grade III Coffee. The color contributes its part of misclassified Grade I to Grade IV Coffee and vice versa, which not happened in morphological feature experimentation. It was found that aggregated features of morphological and color features are good to use for developing models.
B. Support Vector Machine (SVM) classifier
The result of training and testing SVM classifier using morphological, color and aggregated features is presented below.
Using Morphological Features
Table 4. Confusion matrix of morphological features in SVM
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
367
|
4
|
3
|
0
|
Grade-II
|
29
|
430
|
94
|
32
|
Grade-III
|
27
|
83
|
488
|
46
|
Grade-IV
|
7
|
14
|
23
|
353
|
Total
|
430
|
531
|
608
|
431
|
Correctlyclassified (Recall)
|
85.34%
|
80.97%
|
80.26%
|
81.90%
|
Correctlyclassified (Precision)
|
98.12%
|
74.5%
|
76.7%
|
88.9%
|
The same to the ANN of morphology feature experimentation, Grade II Coffee was misclassified more to Grade III Coffee (20%) and Grade III Coffee was more misclassified to Grade II Coffee (22%). Here also SVM is telling us there is a strong morphology relationship between Grade II and Grade III Coffee beans. There is also misclassification of Grade I and Grade IV Coffee bean images to Grade II (7% and 7.5% respectively). Grade IV Coffees were not misclassified to Grade I Coffees as in ANN, But Grade I was misclassified to Grade IV. In general, the morphological classification pattern of SVM classifiers was less in performance accuracy than ANN. From the performance results, the overall classification accuracy of SVM using morphological features was 81.9%.
Using Color Features
Table 5. Confusion matrix of color features in SVM
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
287
|
40
|
41
|
36
|
Grade-II
|
66
|
269
|
170
|
45
|
Grade-III
|
34
|
160
|
314
|
73
|
Grade-IV
|
43
|
54
|
83
|
277
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
66.74%
|
50.65%
|
51.64%
|
64.26%
|
Correctly classified (Precision)
|
71.03%
|
49.9%
|
54.04%
|
60.61%
|
All grade Coffees were misclassified to each other. Here also Grade I Coffee yields better accuracy performances than other grades and Grade II Coffee attain the least accuracy performance. Grade I Coffee was misclassified to the Grade II Coffee in 15.3%, Grade III in 8% and Grade IV in 10%. Grade II Coffees were more misclassified to the Grade III Coffee in 30.13%. Grade III Coffee was also misclassified to all others Grade Coffee. Grade III Coffee was more misclassified to Grade II Coffee by 27.96% and also misclassified to the Grade I and Grade IV Coffee were 6.74% and 13.65% respectively. Grade IV Coffee is also misclassified to the Grade I, II, III and more classified to the grade III by 16.93%. In addition, there is a significant misclassification among each grade as shown in ANN color feature experimentation. There is a better classification performance was obtained in most regions, but less accuracy performance than ANN using color features.
Using aggregated Features
Table 6: Confusion matrix of aggregated features in SVM
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
372
|
7
|
5
|
1
|
Grade-II
|
35
|
444
|
91
|
29
|
Grade-III
|
22
|
60
|
493
|
35
|
Grade-IV
|
1
|
20
|
19
|
366
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
86.5%
|
83.6%
|
81.1%
|
84.9%
|
Correctly classified (Precision)
|
96.6%
|
74.12%
|
80.81%
|
90.14%
|
The Grade I Coffee accuracy performances were greater than others` and Grade III Coffee yields the least accuracy performance under this experimentation. As compared to morphological and color features individually, their combination features of Coffee bean yield better performance under this experimentation. The result shows that, there was no misclassification between Grade I and Grade IV Coffee in morphological feature experimentation of ANN but here color value had contributed to change that value.
C. K-Nearest Neighbor (KNN) classifier and its output
Using Morphological features
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
321
|
0
|
0
|
0
|
Grade-II
|
63
|
384
|
110
|
24
|
Grade-III
|
46
|
112
|
456
|
84
|
Grade-IV
|
0
|
35
|
42
|
323
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
74.65%
|
72.31%
|
75%
|
74.94%
|
Correctly classified (Precision)
|
100%
|
66.1%
|
65.32%
|
80.75%
|
These Coffees were relatively less misclassified to Grade II because the size of these Coffee beans is small. Grade I Coffee wasn’t misclassified to Grade IV Coffee and Grade II Coffee misclassified to the Grade I Coffee. Grade III and Grade IV Coffee also misclassified to Grade I. This shows that the nonexistence of the strong morphology relationship between Grade I and the left three grades (Grade II, Grade III and Grade IV) Coffee according to the result obtained from this experimentation. So KNN was perfect on classifying Grade I Coffee and also didn’t misclassified other Coffee Grade to Grade I. KNN was better at classifying Grade I Coffee than SVM even if the overall accuracy of this classifier was less than that of SVM using morphological features. From the performance results, the overall grading accuracy of KNN using morphological features was 74.2%. The KNN algorithm yields the least accuracy performances as compared to ANN and SVM classifier.
Using Color Features
Table 8. Confusion matrix of color features in KNN
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
302
|
31
|
16
|
32
|
Grade-II
|
55
|
376
|
87
|
56
|
Grade-III
|
46
|
63
|
436
|
45
|
Grade-IV
|
27
|
61
|
69
|
298
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
70.23%
|
70.80%
|
71.71%
|
69.14%
|
Correctly classified (Precision)
|
79.26%
|
65.5%
|
73.9%
|
65.5%
|
The Grade I Coffee was misclassified more to the Grade II Coffee (13%) and Grade II Coffees were more misclassified to the Grade III Coffee (12%). Grade III Coffee was more misclassified to Grade II Coffee (14.3%) and Grade IV Coffee is also more misclassified to the Grade II Coffee (13%). All grades were misclassified to each other because there is a slight difference in color feature between each Coffee grade and there is no regular pattern regarding color feature classification. The Grade III Coffee was better in accuracy than the others and Grade IV were the least under this experimentation.
Using aggregated Features
Table 9. Confusion matrix of aggregated features in KNN
Actual Class
Predicted Class
|
Grade-I
|
Grade-II
|
Grade-III
|
Grade-IV
|
Grade-I
|
340
|
4
|
9
|
16
|
Grade-II
|
53
|
413
|
77
|
27
|
Grade-III
|
34
|
86
|
473
|
57
|
Grade-IV
|
3
|
28
|
49
|
331
|
Total
|
430
|
531
|
608
|
431
|
Correctly classified (Recall)
|
79.1%
|
77.77%
|
77.79%
|
76.79%
|
Correctly classified (Precision)
|
92.1%
|
72.4%
|
72.7%
|
80.53%
|
Under this experimentation most of the images are classified under their respective classes. Under all classifiers, aggregated features produce better accuracy performances over the separate features. But, under this experimentation, one thing that can be concluded is color contribute its part on misclassifying other grade to grade I which happened in ANN. Here also aggregated features were selected as per its accuracy performance over other features.