# Rapid Assessment of Rice Quality Traits Using Low-Cost Digital Technologies
## 2 Materials and Methods
### Statistical Analysis and Machine Learning Modelling  
Two matrices were developed using only the significant correlations (_p_ < 0.05) between (i) the peak area of volatile aromatic compounds using GC-MS and e-nose sensor outputs for raw rice and (ii) the volatile aromatic compounds using GC-MS and e-nose, color, texture, and pH of cooked rice.  
Seven machine learning models were developed by testing 17 algorithms of artificial neural network (ANN) pattern recognition in Matlab 2021a using a code developed by the DAFW-UoM [67] to find the algorithm with the best accuracy and performance with no signs of under- and overfitting, followed by a neuron trimming test (ten, seven, five, and three neurons). Pattern recognition models of ANN were developed to classify the 17 commercial rice types according to their specific types, as described in Table 1. Figure 1 shows the diagram of the models used in the study to classify the rice using as inputs the first derivative of raw rice NIR absorbance values (Model 1) and the e-nose outputs of raw rice (Model 2). The Bayesian regularization (BR) algorithm was selected for these models. It had the highest accuracy with the lowest mean squared error (MSE) using 70% training and 30% testing with random data division.  
On the other hand, ANN regression models were used to predict the aromas and other physicochemical parameters (color, texture, and pH) of the rice, as shown in Figure 2. Models 3 and 4 were developed using the first derivative of NIR spectra obtained from the raw rice as inputs to predict the abundance of volatile aromatic compounds in raw and cooked rice samples, whereas Model 5 was constructed using the raw rice NIR inputs to predict the color, texture, and pH of the cooked rice. Based on the optimization, the BR algorithm was used to develop Models 3 and 4 using random data division with 70% for training and 30% for testing, whereas Model 5 was developed using a conjugate gradient with the Powell-Beale restarts (CGB) algorithm with a random data division of 60% training, 20% validation, and 20% testing. The e-nose readings of raw rice were used as inputs to predict the peak area of volatile aromatic compounds in raw (Model 6) and cooked (Model 7) rice samples. The BR (random data division: 70% training and 30% testing) and Levenberg-Marquardt (LM; random data division: 70% training, 15% validation, and 15% testing) algorithms were used to develop Models 6 and 7, respectively.  
The time required to train these ANN models depends on the characteristics of the specific computer used and the number of cores. The development of models from parameter engineering and testing of different machine learning algorithms, once all of the data are collected, can be around 2-4 h, depending on the number of models and the amount of data used. However, this process is not relevant for the deployment of the models, which can be in near-real-time. The process of the practical application of the proposed methods consists of (i) obtaining the sample, (ii) measuring with the e-nose or NIR device, and (iii) automated analysis with the machine learning model deployment. The time for this process is less than a second per sample.  
Figure 1: Classification models developed using (**a**) the first derivative of NIR absorbance values as inputs (Model 1) and (**b**) electronic nose sensors’ data as inputs (Model 2) to classify the 17 types of commercial rice. A description of the electronic nose sensors can be found in Table 2.