Next Article in Journal
Factorial Numbers and Their Practical Applications
Previous Article in Journal
Stress Evolution and Rock Burst Prevention in Triangle Coal Pillars under the Influence of Penetrating Faults: A Case Study
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Classification of Urea Content in Fish Using Absorbance Near-Infrared Spectroscopy and Machine Learning

by
Duy Khanh Ninh
1,*,
Kha Duy Phan
2,
Thu Thi Anh Nguyen
3,
Minh Nhat Dang
4,
Nhan Le Thanh
2,5 and
Fabien Ferrero
2,5,*
1
Faculty of Information Technology, The University of Danang—University of Science and Technology, Danang 550000, Vietnam
2
Danang International Institute of Technology (DNIIT), The University of Danang, Danang 550000, Vietnam
3
Faculty of Advanced Science and Technology, The University of Danang—University of Science and Technology, Danang 550000, Vietnam
4
Faculty of Chemical Engineering, The University of Danang—University of Science and Technology, Danang 550000, Vietnam
5
Université Côte d’Azur, Laboratoire d’Electronique, Antennes et Télécommunications (LEAT), CNRS (UMR 7248), 06903 Sophia Antipolis, France
*
Authors to whom correspondence should be addressed.
Appl. Sci. 2024, 14(19), 8586; https://doi.org/10.3390/app14198586
Submission received: 29 July 2024 / Revised: 19 September 2024 / Accepted: 20 September 2024 / Published: 24 September 2024
(This article belongs to the Special Issue Application of Neural Networks in Sensors and Microwave Antennas)

Abstract

:
Near-infrared (NIR) spectroscopy has become a popular technique for assessing food quality due to its advantages over complex chemical analysis methods. However, the application of NIR spectroscopy for evaluating fish quality based on urea content has not been extensively explored. This study investigates the use of NIR spectroscopy in combination with machine learning (ML) techniques to classify fish samples into two safety classes—Safe and Unsafe—based on their urea content. A comprehensive NIR dataset comprising 11,960 spectra collected from eight distinct positions within the fish body was obtained from 299 fish samples of mackerel, tuna, and pompano species. ML experiments were conducted to classify fish samples based on whether their urea content exceeded the permissible limit of 1000 ppm. To address class imbalance and optimize ML models, various data pre-processing and feature extraction techniques, as well as ML algorithms, were explored. The results demonstrated that utilizing NIR data specifically obtained from the outer skin of the stomach yielded superior models for fish safety classification. A feature extraction method employing pre-processed NIR spectra and their first derivatives, combined with an optimized convolutional neural network architecture, outperformed traditional ML classifiers, achieving an accuracy of up to 83.9%.

1. Introduction

Given the direct impact of fish quality on consumer health, the assessment of fish quality warrants significant attention. Moreover, the growing consumption of fish globally [1], coupled with increasing concerns about food hygiene and safety among both regulatory bodies and consumers, underscores the urgency of addressing the challenges in fish quality control. According to statistics from the Institute of Marine Research, Vietnam’s fishery production from 2011 to 2015 included 493.9 thousand tons of mackerel, 42.6 thousand tons of tuna, and 344 thousand tons of pompano [2]. Thus, it is evident that tuna, mackerel, and pompano are important seafood products in Vietnam’s fishing grounds. These three types of fish are used for both domestic markets and export, making them crucial to enhancing quality monitoring [2].
Urea is a type of chemical fertilizer used in agriculture to increase nitrogen content for crops and is not a food preservative. However, in Vietnam, urea is mixed with ice to preserve seafood because when urea dissolves in water, the water becomes cold due to an endothermic reaction, thereby keeping the fish meat fresh for longer. The misuse of urea in preservation arises from several factors: prolonged sea trips, insufficient ice supplies, ease of accessibility and use, low cost of urea, and a lack of knowledge and awareness and poor attitudes of those involved in the seafood supply chain regarding food safety [2]. These reasons create the risk of urea contamination in seafood. Urea is not included in the list of food additives permitted for use in food issued under Circular No. 27/2012/TT-BYT [3], the Circular on food additive management published by the Ministry of Health of Vietnam in 2012, nor is it included in the Codex General Standard for Food Additives (GSFA, Codex STAN 192-1995) [4]. Regular consumption of food containing urea, even in low amounts, can lead to chronic poisoning with symptoms such as prolonged insomnia, headaches, body aches, memory loss, frequent cramps, loss of appetite leading to malnutrition, intestinal ulcers, and imbalances in calcium and phosphorus causing osteoporosis [5]. Eating food with high urea residue can result in acute poisoning with symptoms like abdominal pain, nausea, diarrhea, difficulty breathing, heart failure, and arteriosclerosis, which can lead to death [5].
Standard methods for analyzing urea in the laboratory are often time-consuming, sample-destructive, expensive, and require skilled personnel [6]. To promptly detect urea in seafood at markets, rapid analysis methods are needed to screen samples at risk of urea contamination without requiring sample destruction and complicated sample preparation. To the best of our knowledge, no research has been conducted on rapid and non-destructive analysis methods specifically for determining urea content in raw fish samples. We also find that most of the currently available rapid test kits for urea concentration are not specifically designed for fish samples. For example, the Urea/Ammonia Assay Kit (Rapid) produced by Neogen’s Megazyme is suitable for the rapid analysis of urea in water, beverages, milk, and food products [7]. This kit utilizes an enzymatic spectrophotometric method for accurate determination of urea concentrations [8]. However, it requires a spectrophotometer and two supplied enzymes, with a reaction time of approximately 10 min [7,8]. In Vietnam, a rapid detection kit for urea in frozen and fresh fish samples has been developed and commercialized by the Institute of Science and Technology, Ministry of Public Security of Vietnam. This kit, named UT12, has a limit of detection (LOD) of 1000 ppm [9]. While this test kit offers the advantages of being cost-effective and capable of non-destructive urea detection in fish samples, the sample preparation process remains somewhat cumbersome, involving the application of water droplets to the fish body and gills. Additionally, the time required to obtain results is still relatively long, ranging from 1 to 5 min [9]. Our investigation has indicated that existing rapid methods for urea detection in fish may exhibit certain limitations, including the necessity for sample preparation and prolonged detection times. Therefore, the development of novel approaches is warranted to address these challenges.
Recently, near-infrared (NIR) spectroscopy, coupled with machine learning (ML) techniques, has gained traction as an analytical approach for determining chemical composition and/or classifying food quality [10,11]. The NIR region, spanning wavelengths from 780 to 2500 nm, offers deep penetration into chemical substances [10,11]. Recent research [12] has demonstrated the efficacy of combining NIR spectroscopy with ML for the rapid and non-invasive evaluation of fish quality, encompassing both quantitative and qualitative aspects. This innovative approach has been successfully employed to predict various fish attributes, including freshness [13,14,15,16,17], fat content [18,19,20], species identification [21,22], and geographical origin [23,24,25,26]. The application of NIR spectroscopy coupled with ML extends beyond the fishing industry, proving values in diverse food quality control ecosystems. Notable examples include the detection of meat [27] and milk [28] adulteration and other aspects of fruit quality assessment [29]. It is expected that the recent development of low-cost handheld NIR spectrometers, along with ML, has opened up the possibility of developing rapid and on-site analysis methods for urea content based on NIR spectral measurements.
To address the limitations of existing rapid methods and support risk-based inspection, this study explores the potential of NIR spectroscopy coupled with ML for the rapid and non-destructive classification of raw fish samples based on urea content. Specifically, we aim to develop a novel method based on NIR spectroscopy and ML techniques to detect urea in fish meat with a LOD of 1000 ppm, but without sample preparation and with a reduced detection time. This innovative approach could streamline safety assessments within the seafood industry, enabling efficient product management and reducing losses. Moreover, regulatory bodies could utilize this technology to enhance their inspection protocols. For developing a urea detector with a LOD of 1000 ppm based on the coupling between ML and NIR spectroscopy, the development of an ML pipeline is necessary. This pipeline should be capable of accurately classifying the urea content of a fish sample as either Safe (below 1000 ppm) or Unsafe based on its NIR spectrum. To achieve this, a NIR spectrum dataset of multiple fish samples with various urea contents belonging to the two safety classes needs to be collected. Subsequently, various combinations of feature extraction techniques and potential ML models should be evaluated on the NIR dataset to identify the combination yielding the highest performance. Regarding the NIR spectral measurement of a fish sample, an important question arises concerning the relative importance of distinct anatomical regions of a fish in the classification problem of their urea content. Different hypotheses could be formulated due to the lack of previous studies in this field. Thus, this study will also identify the optimal location within a fish’s body to measure the NIR spectrum for accurate identification of the safety class of the given fish sample. The optimal measurement location could be either a specific position or any. In the latter case, the identification of the safety class based on urea content is considered position independent.

2. Materials and Methods

Figure 1 presents our study’s proposed workflow. It begins with the collection of NIR spectra, followed by the handling of missing data to ensure a complete dataset. Next, the data are divided into training, validation, and test sets to support the development of a robust predictive model. The workflow incorporates SMOTE (Synthetic Minority Over-Sampling Technique) [30], which generates additional training data to address class imbalance. Afterward, the data undergo normalization and smoothing to ensure consistency and reduce noise. Feature extraction is then performed to identify and prioritize relevant information, enhancing model performance. These extracted features are used to train and validate the machine learning model, allowing fine-tuning of its parameters. Finally, the model’s performance is evaluated on an independent test set to ensure its ability to generalize to unseen data.
In the following subsections, we will describe each step in the workflow in detail.

2.1. Device and Software for Data Collection

We used a low-cost handheld NIR device, which is the DLP® NIRscan™ Nano Evaluation Module (Texas Instruments, Dallas, TX, USA) [31], to measure the NIR spectra of fish samples (Figure 2). This spectrometer leverages digital light processing (DLP) technology, which replaces the traditional linear array detector with a digital micromirror device (DMD) for wavelength selection and a single-point detector. By sequentially scanning through the columns of the DMD, a particular wavelength of light is directed to the detector and captured. This NIR scanner supports both Bluetooth low energy and USB communications, which enable mobile and computer lab measurements. For NIR data collection, we employed the DLP NIRscan Nano GUI v2.1.0, a software that came with the device, to start the scanning process and transfer recorded spectra from the spectrometer to our Windows computer through a USB cable. We did not apply any calibration method. Regarding scanning methods, the Column method selects one wavelength at a time, while the Hadamard method creates a set with several wavelengths multiplexed at a time and then decodes the individual wavelengths. We have chosen the Hadamard method since it collects much more light and offers a greater signal-to-noise ratio than the Column one.
In the scanning process, part of the radiation in the NIR range emitted from the device was absorbed by the dissected samples. The remainder that is not absorbed is reflected back to the device sensor or transmitted through those substances. According to this, we could achieve absorbance, reflectance, and transmittance spectra simultaneously. Each spectrum consists of 228 wavelengths in the range of 900–1700 nm, i.e., a resolution of 3.5 nm per wavelength point. Among the three types of spectra, we decided to use the absorption spectrum to conduct experiments for the classification of urea content in fish.

2.2. Sample Collection

We collected 299 fish specimens, including 113 mackerel, 98 tuna, and 88 pompano samples. These specimens were sourced directly from offshore fishing vessels in Central Vietnam. The fish samples were immersed in ice flakes with the addition of three different concentrations of urea: 1%, 2%, and 3%.

2.3. NIR Measurement for Fish Samples

During an eight-hour period, a fish sample was removed from the soaking tank every two hours and allowed to equilibrate to room temperature, ranging from 25 °C to 35 °C. Following this, the samples were cleaned and dried using blotting paper. NIR spectra were recorded at four external locations on the fish’s skin: the nape, back, stomach, and tail. Subsequently, the fish was filleted, and NIR measurements were taken at four internal locations: again, the nape, back, stomach, and tail. These eight positions were selected to encompass the entire body of the fish and ensure stable measurements, avoiding the risk of fluctuating spectra from uneven surfaces, such as the gills, or highly humid regions, such as the eyes. Each of the eight positions was measured five times, resulting in a total of 40 distinct NIR spectrum samples per fish.
In this study, we simulated a scenario in which fishermen improperly use urea to preserve fish by soaking the samples in ice flakes supplemented with urea. To enhance the robustness of our findings, NIR spectra were measured under room temperature conditions without controlling ambient humidity. The dataset utilized in this study comprises 11,960 samples of NIR absorption spectra collected from 299 fish specimens.

2.4. NIR Dataset Labeling and Division

After NIR measurement, the filleted fish was ground using a blender. Then, its urea content was determined using a high-pressure liquid chromatography (HPLC) method described in [6]. The principle of this method is that urea in the fish sample is derivatized with xanthydrol (9H-xanthen-9-ol) to form N-9H-xanthen-9-ylurea. This derivative is then analyzed using an HPLC system with a fluorescence detector, with an excitation wavelength of 213 nm and an emission wavelength of 308 nm. Forty NIR spectra were then assigned a safety label according to the urea content of the fish sample. In the event that the urea content of the fish fell below the established threshold of 1000 ppm, the NIR spectra associated with that fish were classified as “Safe”; conversely, if the urea content exceeded the permissible limit, the NIR spectra were classified as “Unsafe”.
Finally, the whole NIR spectrum dataset was divided into three subsets for the training, validating, and evaluating classification models, including training, validation, and test sets at the ratio of 3:1:1. The data division was carried out to satisfy the following two criteria: a fish sample and its associated spectrum samples only belonged to one subset, and the urea content distributions of the training, validation, and test sets were similar. These requirements were met to assure the objectiveness of the model building and evaluation processes.

2.5. Data Pre-Processing

In the pre-processing stage, we performed three techniques in a row, including missing data handling, data normalization, and data smoothing. If a wavelength of an absorption spectrum was missing, the missing absorbance value was replaced by the average of the absorbance values of the two neighboring wavelengths. Then, standard normal variate correction (i.e., z-score normalization) was applied to every single spectrum of the dataset to eliminate the deviations caused by particle size and scattering, making the NIR data consistent. Eventually, the NIR spectra were streamed through a Savitzky–Golay (SG) filter with a window length of 13 points and a polynomial order of five to smooth the spectra, thereby removing part of the noise [32]. The pre-processing steps were conducted by using the Scipy v1.14.1 library.
What is especially notable about our dataset is the severe imbalance between the two safety classes. The number of NIR samples belonging to the “Safe” class is nearly six times higher than the “Unsafe” class. This can cause a classification model to be biased towards the majority class with the “Safe” label. To solve this problem, we leveraged the SMOTE technique to handle data imbalance. SMOTE specifically generates new data points for the minority class with the “Unsafe” label. It analyzes existing minority data points and generates new ones similar to them. By adding these synthetic samples, SMOTE balances the data, giving the model a better capability to learn the minority class. After applying SMOTE on the training subset, the number of NIR samples belonging to the “Unsafe” class is equal to that of the “Safe” class. The details of the SMOTE algorithm can be found in [30]. We used the Python package named imbalanced-learn v0.11.0 to perform SMOTE. The synthetic spectrum samples were also normalized and smoothed in the same way as the original ones.

2.6. Feature Extraction

Relevant features need to be chosen for building classification models. For a fish sample, its pre-processed NIR spectrum is a certain choice for the feature vector for safety classification. We further examined the derivatives of the pre-processed spectrum to see if they can help to differentiate labels of safety. We investigated six types of feature vectors based on the concatenation of the pre-processed spectrum and its derivatives, as described in Table 1.

2.7. Model Training and Validation

We used both the traditional ML and modern deep learning (DL) approaches to build classification models and compared their performances for the purpose of classifying a fish sample as safe or unsafe based on its urea content, which is reflected by its extracted NIR spectral features. For the traditional ML approach, four algorithms were experimented including decision tree (DT) [33], k-nearest neighbors (KNN) [34], support vector machine (SVM) [35], and extreme gradient boosting (XGB) [36]. For the DL approach, we employed a convolutional neural network (CNN) [37] and proposed suitable architectures depending on the experiments. The model training and hyperparameter tuning processes were conducted by using the scikit-learn v1.4.0 toolkit for the conventional ML algorithms and the Keras v2.10.0 framework for the CNN models. After the optimal models were determined, their performances were evaluated on the common test set.

2.8. Improved Detection Setup

As each combination of the input feature type and the measurement position (and thus the corresponding NIR sub-dataset) leads to a different configuration of the CNN model, we only present the process of constructing and evaluating the CNN model, which achieved the highest classification accuracy to make this article concise. Figure 3 describes the proposed CNN architecture in this case. The model includes one input layer, which contains 456 neurons as input data, representing the feature vector of size 456 × 1, which is of the type “prep + der1” (i.e., pre-processed spectrum concatenated with its first derivative). It consists of two convolutional layers, each of them followed by a pooling layer. The convolutional layers have kernels of size 8 × 1. They are alternated with two max-pooling layers with the pool size 2 × 1 and Rectified Linear Units (ReLUs) as the activation functions. The output of the final max pooling layer is streamed through a flattened layer in order to convert multi-dimensional data into one-dimensional data, which are then entered into the two fully connected (i.e., dense) layers. The first dense layer consists of eight neurons and a ReLU activation function. A dropout layer is placed before the two dense layers. Finally, the last dense layer contains two neurons where softmax classifier activation is used to predict the output (i.e., the safety label) of the model. The proposed CNN model consists of 7482 parameters.
The training process of this model was implemented using the Keras framework with the Adam optimizer and the initial learning rate at 0.001. The learning rate was set to be reduced by a factor of 0.8 when the training result was not progressing. The validation set was used to stop the training process. Given the substantial parameter count associated with the initial CNN architecture and the limited availability of training samples, the issue of overfitting emerged as a significant concern. Consequently, the incorporation of a dropout layer was deemed necessary in order to mitigate this challenge effectively.
Figure 4 shows how the cross-entropy-based loss function of the CNN model varied on the training and validation sets over training epochs. We stopped the training process after 50 epochs to prevent overfitting since the model had their losses converged on the validation set at this point.

3. Results

We carried out several experiments to find out the most effective model for detecting the safety label associated with a fish sample. There are two types of models. The first type includes those models that were built and evaluated solely on the NIR data obtained from a predetermined location on the fish’s body (hereafter referred to as “position-dependent”). Sub-datasets were utilized, each comprising only one-eighth of the complete dataset in terms of sample size. Figure 5 illustrates the representative spectra of the pompano, displaying the mean and 95% confidence interval of absorbance values aggregated across all pompano samples in the dataset, according to the measurement positions on the fish body. Notably, the absorbance values exhibited significant variation across different parts of the pompano, a trend that was similarly observed in the tuna and mackerel samples. In contrast, the second type of model includes those that were built and evaluated by employing the entire NIR dataset obtained from all eight measurement positions (referred to as “position-independent”). Figure 6 illustrates the average NIR absorption spectra of fish samples in the whole dataset with respect to fish types and safety labels.

3.1. Data Description for the Training, Validation, and Test Sets

As described in Section 2.4, the whole NIR dataset was divided into training, validation, and test sets for the building and evaluation of classification models. Figure 7 illustrates the urea content distributions of the training, validation, and test sets. It can be observed that these data distributions exhibit considerable similarity. Table 2 shows several basic statistics of the urea content of fish samples belonging to these three data subsets and the two safety classes. It can be seen that the within-class statistics are quite similar among the three data subsets, as expected. Within each of these data subsets, while both of the data distributions of the two safety classes exhibit right skewness, the dispersion of the Unsafe class is larger than that of the Safe class due to the coefficient of variation (CV) of the former being almost doubled that of the latter.

3.2. Traditional Machine Learning Models for Urea Content Classification

Table 3 presents the accuracy of the optimally tuned DT models when being evaluated on the test sets according to measurement positions and feature types. It can be seen that the DT classifier achieved the highest accuracy of 79.6% when “Skin, nape” was used as the measurement position and “prep + der2” was chosen as the feature vector. The position-independent experiment obtained the highest accuracy of 75.8% when the feature type “prep” was selected.
Table 4 presents the accuracy of the optimally tuned KNN models when being evaluated on the test sets according to measurement positions and feature types. It can be seen that the KNN classifier achieved the highest accuracy of 78.8% when “Skin, stomach” was used as the measurement position and “prep + der2” was chosen as the feature vector. The position-independent experiment obtained the highest accuracy of 78.9% when the feature type “der1” or “prep + der2” was selected.
Table 5 presents the accuracy of the optimally tuned SVM models when being evaluated on the test sets according to measurement positions and feature types. It can be seen that the SVM classifier achieved the highest accuracy of 78.1% when “Skin, stomach” was used as the measurement position and “prep” was chosen as the feature vector. The position-independent experiment obtained the highest accuracy of 75.1% when the feature type “prep” was also selected.
Table 6 presents the accuracy of the optimally tuned XGB models when being evaluated on the test sets according to measurement positions and feature types. It can be seen that the XGB classifier achieved the highest accuracy of 81.6% when “Skin, stomach” was used as the measurement position and “prep + der1” was chosen as the feature vector. The position-independent experiment obtained the highest accuracy of 80.3% when the feature type “der1” was selected.

3.3. Convolutional Neural Network Model for Urea Content Classification

Similar to traditional machine learning models, the classification performance of CNN models is contingent upon both the type of input feature vectors and the measurement position. Table 7 presents the accuracy of the optimally tuned CNN models when being evaluated on the test sets according to measurement positions and feature types. It can be seen that the CNN classifier gained the highest accuracy of 83.9% when “Skin, stomach” was used as the measurement position and “prep + der1” was chosen as the feature vector. For the position-independent experiment, it attained the highest accuracy of 72.3% when the feature type “der1” was selected.
In order to comprehensively assess the efficacy of the proposed CNN model described in Section 2.8 (i.e., the one which achieved the highest classification accuracy and marked with an asterisk in Table 7) in addressing the binary classification problem with imbalanced data, the following metrics were employed as evaluation measures on the test set:
  • Accuracy = T P + T N T P + F P + T N + F N = 83.9%
  • Recall = T P T P + F N = 83.9%
  • Specificity = T N T N + F P = 83.9%
where:
  • TP (True Positive): The total number of samples where the model correctly predicts the positive class, i.e., when the actual class is Unsafe, and the model also predicts it as Unsafe.
  • TN (True Negative): The total number of samples where the model correctly predicts the negative class, i.e., when the actual class is Safe, and the model also predicts it as Safe.
  • FP (False Positive): The total number of samples where the model predicts the positive class incorrectly, i.e., the actual class is Safe, but the model predicts it as Unsafe.
  • FN (False Negative): The total number of samples where the model predicts the negative class incorrectly, i.e., the actual class is Unsafe, but the model predicts it as Safe.
The evaluation of the proposed CNN model reveals not only a significantly high level of accuracy but also almost equally high specificity and sensitivity (or recall) values. This outcome establishes the model as highly effective and well-suited for addressing the binary classification problem at hand.
Lastly, we evaluated the impact of the SMOTE technique on the performance of the proposed CNN model by trying not to use SMOTE. Table 8 indicates remarkable decreases in accuracy and recall scores (by 5.9% and 11.0%, respectively) of the model when not using the SMOTE technique for balancing class distribution in the training set. This result confirms the essential use of SMOTE in dealing with a highly imbalanced dataset such as the one in our study.

4. Discussion

4.1. Comparison among Different Classifiers

While DT and KNN are two of the simplest traditional ML algorithms, SVM and XGB are more complicated and considered more powerful in many ML applications. Among the selected classifiers, CNN is the most complex one, involving many hyperparameters controlling the size, structure, and learning process of the model. CNN has shown its capability to learn complex data such as images, audio, text, genes, etc. [37].
As model hyperparameters can dramatically influence the performance of the conventional ML and CNN algorithms, hyperparameter tuning procedures on the common validation set were carried out to produce optimal models. Table 9 lists the set of hyperparameters used in the grid searching for the optimal ML models. These hyperparameters are the most significant influencers of the model-building process. Meanwhile, the process of optimization for CNN models involves adjusting two key components: the hyperparameters and the layers. While tuning the latter proves to be more challenging compared to the former, the former shares similarities with conventional ML algorithms. In the context of CNN models, the hyperparameters subject to tuning encompass the number of neurons, activation function, optimizer, learning rate, batch size, and epochs. The subsequent step involves fine-tuning the number of layers, a characteristic absent in other conventional ML algorithms. The number of layers employed on a CNN can significantly impact its accuracy. Insufficient layering may yield an underfitting outcome, whereas an excessive number of layers can lead to overfitting.
Table 10 summarizes the best performances of the investigated classifiers in the two experiments: position-independent and position-dependent. It can be observed from Table 10 that the position-dependent models always attained higher classification accuracy (from 1.3% with XGB to 11.6% with CNN) than the position-independent ones (at least nearly equal with KNN), with the best position for NIR measurement being the “Skin, stomach” part of the fish regardless of the classifiers (only one exception in the case of DT). This suggests that we should collect NIR spectra outside the skin and on the stomach for fish safety classification. Among the position-dependent models, the proposed CNN model described in Section 2.8 combined with the feature vector consisting of the pre-processed spectrum coupled with its first derivative (i.e., “prep + der1”) proved to be superior to the others. This ML pipeline achieved the highest classification accuracy of 83.9% and the same level of specificity and recall scores.

4.2. Comparison with Other Rapid Detection Methods

The best-performing ML pipeline, when deployed on a laptop with a 2.9 GHz Dual-Core Intel Core i5 processor and 8 GB of memory, demonstrated an average detection time of 1.7 seconds for classifying the NIR spectrum of a fish sample. This processing speed is notably faster compared to other rapid detection kits, such as those referenced in [7,9], which require several minutes to complete the classification. Furthermore, a significant advantage of the proposed approach is the absence of sample preparation, a step that is often necessary in alternative methods.
Despite these advantages, certain limitations must be acknowledged. The initial investment in a NIR scanner and computing infrastructure for real-time sample sensing and inference remains relatively high, and the classification accuracy is currently suboptimal. However, ongoing advancements in the development of low-cost NIR sensors and miniaturized computing systems are expected to reduce the cost of implementing a rapid, on-site detection system based on NIR spectroscopy and ML [38]. Additionally, it is anticipated that the collection of larger NIR datasets will further enhance the performance of the ML model.

5. Conclusions

The results of this study provide important insights into the application of NIR spectroscopy combined with ML techniques for classifying fish safety based on urea content. By comparing position-dependent and position-independent measurements, as well as different feature extraction methods and classifiers, the study has highlighted the critical factors influencing model performance and the potential for NIR-based approaches in food safety assessment.

5.1. Importance of Measurement Location

One of the most significant findings was the superior performance of position-dependent models, particularly those utilizing NIR data collected from the skin at the stomach region of the fish. Across all classifiers, this specific location consistently yielded higher accuracy, suggesting that the stomach area may provide more relevant spectral information for detecting urea content, possibly due to the concentration or distribution of chemical compounds in that region. This insight is crucial as it indicates that, for practical applications of NIR spectroscopy in fish safety, careful consideration must be given to the anatomical site of measurement.

5.2. Performance of Machine Learning Models

The study demonstrated that traditional ML models, such as Decision Trees (DT), K-Nearest Neighbors (KNN), Support Vector Machines (SVM), and Extreme Gradient Boosting (XGB), could effectively classify fish samples with varying degrees of accuracy depending on the feature type and measurement position. However, the Convolutional Neural Network (CNN) model, particularly when combined with the “prep + der1” feature extraction technique, outperformed these traditional methods. The CNN model’s ability to achieve an accuracy of 83.9% underscores the potential of DL techniques in handling complex spectral data, where subtle patterns in the NIR spectra can be leveraged for more accurate classification.

5.3. Role of Feature Extraction

The effectiveness of different feature extraction methods varied across models, with combined features (e.g., pre-processed spectrum with its first derivative) generally leading to better performance. This suggests that incorporating multiple levels of spectral information helps in capturing more discriminative features, which is particularly beneficial for complex models like CNNs. The superior performance of the “prep + der1” combination in the CNN model highlights the importance of selecting appropriate feature vectors that align with the model’s architecture and learning capacity.

5.4. Implications for Practical Application

The findings from this study have practical implications for the development of NIR-based fish safety testing tools. The high accuracy achieved by the CNN model, particularly at the stomach region, suggests that such models could be integrated into rapid, non-destructive testing devices. These devices could offer food safety authorities and industry stakeholders a cost-effective alternative to traditional laboratory methods, allowing for on-site testing and quicker decision-making regarding fish safety.
However, the study also points to limitations, such as the relatively small dataset and the use of a low-cost NIR scanner, which may affect the generalizability of the results. Despite efforts to mitigate this through techniques like dropout and SMOTE, the potential for overfitting in CNN models is another consideration that warrants further exploration.

5.5. Future Research Directions

To build on these findings, future research should focus on expanding the dataset in terms of both sample size and species diversity and exploring the use of higher-quality NIR equipment. Additionally, investigating other safety-related compounds in fish, such as histamine or borax, would help validate the broader applicability of NIR spectroscopy combined with ML/DL methods. Further research could also explore the integration of chemometrics and multivariate data analysis to enhance feature extraction and model performance, potentially enabling more sophisticated classification systems capable of distinguishing among multiple safety classes.
To summarize, this study has laid a strong foundation for the use of NIR spectroscopy and machine learning in fish safety assessment, with significant implications for both research and practical applications in food safety.

Author Contributions

Conceptualization, D.K.N. and N.L.T.; methodology, D.K.N. and K.D.P.; software, K.D.P.; validation, T.T.A.N., M.N.D. and F.F.; investigation, D.K.N. and T.T.A.N.; data curation, D.K.N. and M.N.D.; writing—original draft preparation, D.K.N. and M.N.D.; writing—review and editing, D.K.N. and K.D.P.; supervision, N.L.T. and F.F.; project administration, N.L.T. and F.F. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Ministry of Science and Technology of Vietnam under project number ĐTĐL.CN-33/20.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The raw data supporting the conclusions of this article will be made available by first corresponding author on request.

Acknowledgments

This work was supported by the Ministry of Science and Technology of Vietnam in the project “Application of quick analysis methods combining multi-dimensional data processing and machine learning in quality control of some types of seafood” (Project No.: ĐTĐL.CN-33/20).

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. The State of World Fisheries and Aquaculture 2024. FAO. Available online: https://openknowledge.fao.org/handle/20.500.14283/cd0683en (accessed on 15 March 2024).
  2. Institute of Marine Research. Report on the Results of the Marine Seafood Resources Survey in Vietnam, 2011–2015; IMR: Hanoi, Vietnam, 2018. (In Vietnamese) [Google Scholar]
  3. Legal Documents. Available online: https://vntr.moit.gov.vn/legal-documents?doc_code=27/2012/TT-BYT (accessed on 15 January 2024).
  4. Codex General Standard for Food Additives (GSFA) Online Database. Available online: https://www.fao.org/fao-who-codexalimentarius/codex-texts/dbs/gsfa/en/ (accessed on 15 January 2024).
  5. Tran, D. Food Safety; Hanoi Publishing House: Hanoi, Vietnam, 2007; pp. 509–521. (In Vietnamese) [Google Scholar]
  6. Clark, S.; Francis, P.S.; Conlan, X.A.; Barnett, N.W. Determination of urea using high-performance liquid chromatography with fluorescence detection after automated derivatisation with xanthydrol. J. Chromatogr. 2007, 1161, 207–213. [Google Scholar] [CrossRef] [PubMed]
  7. Urea/Ammonia Assay Kit (Rapid). Available online: https://www.megazyme.com/urea-ammonia-assay-kit (accessed on 25 June 2024).
  8. Portnoy, M.; Coon, C.; Barbano, D.M. Performance evaluation of an enzymatic spectrophotometric method for milk urea nitrogen. J. Dairy Sci. 2021, 104, 11422–11431. [Google Scholar] [CrossRef] [PubMed]
  9. Urea Quick Test Kit—UT12. Available online: https://npsc.vn/cua-hang/kit-kiem-tra-nhanh-urea-ut12/ (accessed on 10 June 2024). (In Vietnamese).
  10. Osborne, B.G. Near-Infrared Spectroscopy in Food Analysis. In Encyclopedia of Analytical Chemistry; Meyers, R.A., McGorrineds, R.J., Eds.; John Wiley & Sons: Hoboken, NJ, USA, 2006. [Google Scholar] [CrossRef]
  11. Zhang, W.; Kasun, L.C.; Wang, Q.J.; Zheng, Y.; Lin, Z. A Review of Machine Learning for Near-Infrared Spectroscopy. Sensors 2022, 22, 9764. [Google Scholar] [CrossRef]
  12. Wenqian, Y. Applications of near-infrared spectroscopy for fish and fish products quality: A review. IOP Conf. Ser. Earth Environ. Sci. 2021, 657, 012115. [Google Scholar]
  13. Ding, R.; Huang, X.; Han, F.; Dai, H.; Teye, E.; Xu, F. Rapid and nondestructive evaluation of fish freshness by near infrared reflectance spectroscopy combined with chemometrics analysis. Anal. Methods 2014, 6, 9675–9683. [Google Scholar] [CrossRef]
  14. Kimiya, T.; Sivertsen, A.H.; Heia, K. VIS/NIR spectroscopy for non-destructive freshness assessment of Atlantic salmon (Salmo salar L.) fillets. J. Food Eng. 2013, 116, 758–764. [Google Scholar] [CrossRef]
  15. Shim, K.; Jeong, Y. Freshness evaluation in chub mackerel (Scomber japonicus) using near-infrared spectroscopy determination of the cadaverine content. J. Food Prot. 2019, 82, 768–774. [Google Scholar] [CrossRef]
  16. Sivertsen, A.H.; Kimiya, T.; Heia, K. Automatic freshness assessment of cod (Gadus morhua) fillets by Vis/Nir spectroscopy. J. Food Eng. 2011, 103, 317–323. [Google Scholar] [CrossRef]
  17. Zhou, J.J.; Wu, X.Y.; Chen, Z.; You, J.; Xiong, S.B. Evaluation of freshness in freshwater fish based on near infrared reflectance spectroscopy and chemometrics. LWT-Food Sci. Technol. 2019, 106, 145–150. [Google Scholar] [CrossRef]
  18. Isaksson, T.; Tøgersen, G.; Iversen, A.; Hildrum, K.I. Non-destructive determination of fat, moisture and protein in salmon fillets by use of near-infrared diffuse spectroscopy. J. Sci. Food Agric. 1995, 69, 95–100. [Google Scholar] [CrossRef]
  19. Khodabux, K.; L’Omelette, M.S.S.; Jhaumeer-Laulloo, S.; Ramasami, P.; Rondeau, P. Chemical and near-infrared determination of moisture, fat and protein in tuna fishes. Food Chem. 2007, 102, 669–675. [Google Scholar] [CrossRef]
  20. Wold, J.P.; Isaksson, T. Non-destructive determination of fat and moisture in whole atlantic salmon by near-infrared diffuse spectroscopy. J. Food Sci. 1997, 62, 734–736. [Google Scholar] [CrossRef]
  21. Lv, H.; Xu, W.; You, J.; Xiong, S. Classification of freshwater fish species by linear discriminant analysis based on near infrared reflectance spectroscopy. J. Near Infrared Spectrosc. 2017, 25, 54–62. [Google Scholar] [CrossRef]
  22. Cozzolino, D.; Chree, A.; Scaife, J.R.; Murray, I. Usefulness of near-infrared reflectance (NIR) spectroscopy and chemometrics to discriminate fishmeal batches made with different fish species. J. Agric. Food Chem. 2005, 53, 4459–4463. [Google Scholar] [CrossRef]
  23. Ghidini, S.; Varrà, M.O.; Dall’Asta, C.; Badiani, A.; Ianieri, A.; Zanardi, E. Rapid authentication of European sea bass (Dicentrarchus labrax L.) according to production method, farming system, and geographical origin by near infrared spectroscopy coupled with chemometrics. Food Chem. 2019, 280, 321–327. [Google Scholar] [CrossRef]
  24. Liu, Y.; Ma, D.-H.; Wang, X.-C.; Liu, L.-P.; Fan, Y.-X.; Cao, J.-X. Prediction of chemical composition and geographical origin traceability of Chinese export tilapia fillets products by near infrared reflectance spectroscopy. LWT-Food Sci. Technol. 2015, 60, 1214–1218. [Google Scholar] [CrossRef]
  25. Varrà, M.O.; Ghidini, S.; Ianieri, A.; Zanardi, E. Near infrared spectralfingerprinting: A tool against origin-related fraud in the sector of processed anchovies. Food Control 2021, 123, 107778. [Google Scholar] [CrossRef]
  26. Xiccato, G.; Trocino, A.; Tulli, F.; Tibaldi, E. Prediction of chemical composition and origin identification of european sea bass (Dicentrarchus labrax L.) by near infrared reflectance spectroscopy (NIRS). Food Chem. 2004, 86, 275–281. [Google Scholar] [CrossRef]
  27. López-Maestresalas, A.; Insausti, K.; Jarén, C.; Pérez-Roncal, C.; Urrutia, O.; Beriain, M.J.; Arazuri, S. Detection of minced lamb and beef fraud using NIR spectroscopy. Food Control 2019, 98, 465–473. [Google Scholar] [CrossRef]
  28. Dos Santos Pereira, E.V.; de Sousa Fernandes, D.D.; De Araújo, M.C.; Diniz, P.H.; Maciel, M.I. Simultaneous determination of goat milk adulteration with cow milk and their fat and protein contents using NIR spectroscopy and PLS algorithms. LWT 2020, 127, 109427. [Google Scholar] [CrossRef]
  29. Wang, H.; Peng, J.; Xie, C.; Bao, Y.; He, Y. Fruit quality evaluation using spectroscopy technology: A review. Sensors 2015, 15, 11889–11927. [Google Scholar] [CrossRef] [PubMed]
  30. Chawla, N.V.; Bowyer, K.W.; Hall, L.O.; Kegelmeyer, W.P. SMOTE: Synthetic minority over-sampling technique. J. Artif. Intell. Res. 2002, 16, 321–357. [Google Scholar] [CrossRef]
  31. DLP® NIRscan™ Nano Evaluation Module. Available online: https://www.ti.com/tool/DLPNIRNANOEVM (accessed on 27 April 2024).
  32. Savitzky, A.; Golay, M.J.E. Smoothing and Differentiation of Data by Simplified Least Squares Procedures. Anal. Chem. 1964, 36, 1627–1639. [Google Scholar] [CrossRef]
  33. Quinlan, J.R. Simplifying decision trees. Int. J. Man Mach. Stud. 1987, 27, 221–234. [Google Scholar] [CrossRef]
  34. Cover, T.; Hart, P. Nearest neighbor pattern classification. IEEE Trans. Inf. Theory 1967, 13, 21–27. [Google Scholar] [CrossRef]
  35. Cortes, C.; Vapnik, V. Support-vector network. Mach. Learn. 1995, 20, 273–297. [Google Scholar] [CrossRef]
  36. Chen, T.; Guestrin, C. XGBoost: A Scalable Tree Boosting System. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD ‘16), Association for Computing Machinery, New York, NY, USA, 13–17 August 2016; pp. 785–794. [Google Scholar]
  37. Alzubaidi, L.; Zhang, J.; Humaidi, A.J.; Al-Dujaili, A.; Duan, Y.; Al-Shamma, O.; Santamaría, J.; Fadhel, M.A.; Al-Amidie, M.; Farhan, L. Review of deep learning: Concepts, CNN architectures, challenges, applications, future directions. J. Big Data 2021, 8, 53. [Google Scholar] [CrossRef]
  38. Lajom, M.P.; Remigio, J.P.; Arboleda, E.; Sacala, R.J. Design and Development of Eggplant Fruit and Shoot Borer (Leucinodes orbonalis) Detector Using Near-Infrared Spectroscopy. J. Eng. Sustain. Dev. 2024, 28, 439–454. [Google Scholar] [CrossRef]
Figure 1. The complete workflow of our study.
Figure 1. The complete workflow of our study.
Applsci 14 08586 g001
Figure 2. The NIR device (left). An example of spectrum measurement on a fish’s body (right).
Figure 2. The NIR device (left). An example of spectrum measurement on a fish’s body (right).
Applsci 14 08586 g002
Figure 3. The proposed CNN architecture that attains the best classification rate.
Figure 3. The proposed CNN architecture that attains the best classification rate.
Applsci 14 08586 g003
Figure 4. Loss variations in training and validation sets of the proposed CNN over training epochs.
Figure 4. Loss variations in training and validation sets of the proposed CNN over training epochs.
Applsci 14 08586 g004
Figure 5. The absorbance values vary significantly across different parts of the pompano.
Figure 5. The absorbance values vary significantly across different parts of the pompano.
Applsci 14 08586 g005
Figure 6. Average NIR absorption spectra of fish samples with respect to fish types and safety labels.
Figure 6. Average NIR absorption spectra of fish samples with respect to fish types and safety labels.
Applsci 14 08586 g006
Figure 7. Urea content distributions of three subsets (X axis uses a base-10 logarithmic scale).
Figure 7. Urea content distributions of three subsets (X axis uses a base-10 logarithmic scale).
Applsci 14 08586 g007
Table 1. Six feature types of the NIR spectrum.
Table 1. Six feature types of the NIR spectrum.
Feature TypeVector SizeDescription
orig228 × 1Original spectrum
prep228 × 1Pre-processed spectrum
der1228 × 11st derivative of pre-processed spectrum
der2228 × 12nd derivative of pre-processed spectrum
prep + der1456 × 1Pre-processed spectrum + its 1st derivative
prep + der2456 × 1Pre-processed spectrum + its 2nd derivative
Table 2. Several basic statistics of urea content of fish samples belonging to three data subsets and two safety classes.
Table 2. Several basic statistics of urea content of fish samples belonging to three data subsets and two safety classes.
SubsetMean (ppm)Median (ppm)Std (ppm)CV (%)
SafeUnsafeSafeUnsafeSafeUnsafeSafeUnsafe
Training238.33798.6129.31632.8251.77512.7105198
Validation241.34001.1123.41783.8258.07856.0107196
Test234.53560.4126.31544.6253.86934.9108195
Std stands for standard deviation, while CV stands for coefficient of variation. The latter is defined as the ratio of the standard deviation to the mean and expressed as a percentage.
Table 3. Accuracy (%) on test sets of optimally tuned DT models.
Table 3. Accuracy (%) on test sets of optimally tuned DT models.
PositionFeature Type
origprepder1der2prep + der1prep + der2
Skin, nape74.577.571.367.574.879.6
Skin, back71.074.476.572.877.274.8
Skin, tail69.675.767.374.970.475.2
Skin, stomach77.877.374.676.377.877.1
Internal, nape76.476.573.170.375.175.5
Internal, back74.473.172.171.774.874.8
Internal, tail68.974.468.973.167.270.7
Internal, stomach72.674.371.470.672.171.6
All positions73.775.873.973.673.273.1
Table 4. Accuracy (%) on test sets of optimally tuned KNN models.
Table 4. Accuracy (%) on test sets of optimally tuned KNN models.
PositionFeature Type
orgiprepder1der2prep + der1prep + der2
Skin, nape75.573.675.473.471.970.2
Skin, back76.269.977.071.075.268.3
Skin, tail76.272.173.572.872.469.8
Skin, stomach78.478.475.577.375.578.8
Internal, nape77.375.572.474.773.871.7
Internal, back76.172.773.975.672.471.7
Internal, tail77.577.674.170.670.276.5
Internal, stomach75.775.674.473.473.772.4
All positions76.177.678.978.477.378.9
Table 5. Accuracy (%) on test sets of optimally tuned SVM models.
Table 5. Accuracy (%) on test sets of optimally tuned SVM models.
PositionFeature Type
orgiprepder1der2prep + der1prep + der2
Skin, nape70.570.166.468.269.264.2
Skin, back71.271.169.969.168.369.7
Skin, tail70.570.365.271.171.071.9
Skin, stomach77.878.177.075.673.274.4
Internal, nape63.566.368.372.370.370.2
Internal, back67.367.165.770.967.570.1
Internal, tail63.865.170.367.769.368.2
Internal, stomach64.262.267.667.364.267.7
All positions74.7 75.170.066.971.572.4
Table 6. Accuracy (%) on test sets of optimally tuned XGB models.
Table 6. Accuracy (%) on test sets of optimally tuned XGB models.
PositionFeature Type
orgiprepder1der2prep + der1prep + der2
Skin, nape70.470.969.770.966.169.5
Skin, back66.268.272.069.168.669.2
Skin, tail70.671.271.166.966.465.5
Skin, stomach81.080.980.181.181.681.1
Internal, nape77.177.273.873.470.169.5
Internal, back76.272.876.574.175.177.4
Internal, tail70.169.972.472.168.764.3
Internal, stomach65.564.176.766.162.568.9
All positions80.180.080.380.179.179.7
Table 7. Accuracy (%) on test sets of optimally tuned CNN models.
Table 7. Accuracy (%) on test sets of optimally tuned CNN models.
PositionFeature Type
orgiprepder1der2prep + der1prep + der2
Skin, nape77.280.082.279.381.077.3
Skin, back69.170.477.374.272.668.8
Skin, tail61.273.464.166.966.358.5
Skin, stomach81.782.581.583.783.9 *81.7
Internal, nape80.078.978.973.880.075.5
Internal, back74.274.966.570.469.774.2
Internal, tail66.570.064.866.966.565.1
Internal, stomach65.967.770.264.470.864.2
All positions68.371.372.370.471.869.2
* The highest classification accuracy among CNN models.
Table 8. Efficiency comparison of the proposed model while using SMOTE and not using SMOTE.
Table 8. Efficiency comparison of the proposed model while using SMOTE and not using SMOTE.
PositionRecall (%)Accuracy (%)
Yes83.983.9
No72.978.0
Table 9. Set of hyperparameters used in the grid searching for the optimal traditional ML models.
Table 9. Set of hyperparameters used in the grid searching for the optimal traditional ML models.
ModelSet of Hyperparameters
DTmaximum depth of the tree, minimum number of samples at a leaf node
KNNnumber of neighbors
SVMregularization parameter, kernel type
XGBnumber of decision trees, maximum depth of a tree, learning rate
Table 10. Summary of the best cases of different classifiers.
Table 10. Summary of the best cases of different classifiers.
ClassifierPosition-IndependentPosition-Dependent
Accuracy (%)FeatureAccuracy (%)PositionFeature
DT75.8prep79.6Skin, napeprep + der2
KNN78.9der1/prep + der278.8Skin, stomachprep + der2
SVM75.1prep78.1Skin, stomachprep
XGB80.3der181.6Skin, stomachprep + der1
CNN72.3der183.9Skin, stomachprep + der1
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ninh, D.K.; Phan, K.D.; Nguyen, T.T.A.; Dang, M.N.; Le Thanh, N.; Ferrero, F. Classification of Urea Content in Fish Using Absorbance Near-Infrared Spectroscopy and Machine Learning. Appl. Sci. 2024, 14, 8586. https://doi.org/10.3390/app14198586

AMA Style

Ninh DK, Phan KD, Nguyen TTA, Dang MN, Le Thanh N, Ferrero F. Classification of Urea Content in Fish Using Absorbance Near-Infrared Spectroscopy and Machine Learning. Applied Sciences. 2024; 14(19):8586. https://doi.org/10.3390/app14198586

Chicago/Turabian Style

Ninh, Duy Khanh, Kha Duy Phan, Thu Thi Anh Nguyen, Minh Nhat Dang, Nhan Le Thanh, and Fabien Ferrero. 2024. "Classification of Urea Content in Fish Using Absorbance Near-Infrared Spectroscopy and Machine Learning" Applied Sciences 14, no. 19: 8586. https://doi.org/10.3390/app14198586

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop