# Classification of Adulterated Particle Images in Coconut Oil Using Deep Learning Approaches
## 3 Research Methodology
### Experimental Settings and Results  
The CNN modeling experiments were conducted on a laptop with a 2.60 GHz Intel i7-9750H processor and 16 GB of main memory with a Jupyter Notebook and Python 3.7 kernel with TensorFlow, Keras, and OpenCV libraries. After the proposed model was developed, it was tested with the PiCO_V1 and PiCO_V2 datasets. The results were evaluated using a confusion matrix for the correctness measurement. The values in the confusion matrix were used to determine the efficiency of the classification model, which can be calculated from Equations (1)-(4).  
\[\text{Accuracy}=\frac{TP+TN}{TP+FP+TN+FN} \tag{1}\]  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Class** & **Example of Particle Image for Model Training** \\ \hline Air & 0 \\ \hline FiberT1 & 0 \\ \hline FiberT2 & 0 \\ \hline FiberT3 & 0 \\ \hline FiberT4 & 0 \\ \hline ParticleT1 & 0 \\ \hline ParticleT2 & 0 \\ \hline ParticleT3 & 0 \\ \hline ParticleT4 & 0 \\ \hline Tissue & 0 \\ \hline \hline \end{tabular}
\end{table}
Table 1: 10 classes of particles in coconut oil.  
\[\text{Precision}=\frac{\mathit{TP}}{\mathit{TP}+\mathit{FP}} \tag{2}\]  
\[\text{Recall}=\frac{\mathit{TP}}{\mathit{TP}+\mathit{FN}} \tag{3}\]  
\[\text{F1}_{\text{Score}}=2\times\left[\frac{\text{Precision}\;\times\;\text{ Recall}}{\text{Precision}+\;\text{Recall}}\right] \tag{4}\]  
where: \(\mathit{TP}\) is true positive, which means that the predicted data match the actual data in the class under consideration; \(\mathit{FP}\) is false positive, which means that the predicted data are do not match the actual data in the class under consideration; \(\mathit{TN}\) is true negative, which means that the predicted data match the actual data in a class that is not considered; and \(\mathit{FN}\) is false negative, which means mispredicted data in an unconsidered class.  
Equation (1) is used to determine accuracy, meaning the number of times the prediction data match the actual data and, combined with the prediction data, match the actual data in a class that is not considered. When that number is divided by the total number of data, the efficiency of accuracy prediction is obtained.  
Precision value can be calculated from Equation (2), which means the number of times the prediction data match the actual data. Then, it is divided by the number of times the prediction data match the actual data plus the incorrect predictive data in the class under consideration. The precision value can also be called a positive predictive value (PPV).  
The recall value, which means the number of times the prediction data match the actual data, can be calculated from Equation (3). Then, the number obtained is divided by the number of times that the predicted data match the actual data plus the wrong predicted data in the class that is not considered. Finally, the F1 Score value, meaning the value obtained by combining precision and recall values, can be calculated from Equation (4). It is the harmonic mean between the precision and recall values. These four values were used to determine the performance of all models of the CNN architectures. The test results were based on the PiCO_V1 dataset, which will be discussed in the next section.  
For the training model, 10 standard CNNs were used. The preliminary testing of the model's accuracy began with the input of images from the PiCO_V2 dataset that had a resolution size that met the requirements of each standard CNN architecture. The process of training the model started by importing one image at a time until every image of the PiCO_V2 dataset had been imported. The experiment started with the MobileNetV2 architecture, and the results were then compared with those of other CNNs.