{'fraction_non_alphanumeric': 0.029185245237130116, 'fraction_numerical': 0.011511957843534657, 'mean_word_length': 5.076847290640394, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Development of non-destructive mango assessment using Handheld Spectroscopy and Machine Learning Regression

Quality determines the shelf-life and selling prices of fresh mango, and therefore quality observation and control of fresh mango are of utmost significance in the processing and management of its supply chain. Mango fruit (mangifera indica) quality methods are mostly destructive in nature. Different mechanical, electromagnetic and non-destructive methods are increasingly important nowadays because of the ease of operation, speed, and reliability of the process. This project aims to develop a non-destructive assessment of mango quality using handheld micro NIR (near-infrared) spectroscopic device. NIR spectra data and Brix levels, which indicate the sugar content of the plant, i.e. indicating the sweetness of the mango, were collected from three different types of Mango (Chokanan, Rainbow, and Kai Te), resulting 80 samples (i.e. 60 samples for training and 20 samples for testing) in this project. NIR spectra can be converted mathematically to obtain quantitative information of chemical and physical nature by multivariate calibration. The spectra data is pre-processed using Gaussian smoothing and extended multiplicative signal correction (EMSC) for the elimination of uncontrollable path length or scattering effects. These samples were then used to develop a predictive model using both Support Vector Machine (SVM) regression and Partial Least Squares regression (PLS) methods. The coefficient of determination (R2) obtained from SVM for training/calibration and testing dataset are 0.96 and 0.95 respectively. Meanwhile, the coefficient of determination (R2) obtained from PLS for calibration/training and testing dataset are 0.89 and 0.86 respectively. The results obtained from this project indicate that the handheld NIR has potential use for non-destructive assessment of mango fruits quality.


Introduction
Mango (Mangifera indica) is one of the highest nutrients of carbs, proteins, fats, minerals, and vitamins contained in fruits. As mangoes mature, glucose, fructose, and sucrose levels rise, while vitamin C levels decrease [3]. Fruit quality can be classified as an external and internal component in two common groups. Interior quality may include texture, flavors, the value of nutrition and factor defects. Sizing, shape, and color are generally recognized as factors of external quality.
Several methods for measuring the internal quality of fruits have been tried, but most of these techniques still are invasive, requiring a lot of time and labor. Some research has examined an accelerated and simpler method of evaluating fruit quality using technology for optical spectroscopy. Near-infrared spectroscopy [NIR, (750-2500 nm)] shows the best results compared to other  [4]. NIR spectroscopy is used to analyze ingredients, intermediates, and final products compositionally, functionally and sensitively. It is used in food and feed, farm, dairy, pharmaceutical, and chemical industries which are constantly under pressure to produce products which satisfy customer demands while increasing plant production and profitability [4].
NIR can be used in quantitative analysis (substance concentrations determination), qualitative testing and process control (raw material identification, intermediate and finished product identification). It can provide moisture, protein, fat, and starch content information. In each industry, NIR applications vary and are tailored to suit different companies and their products and needs [1,2,5]. In assessing the fruit maturation of mango and as a guide to final food quality, short wave near-infrared spectroscopy (NIR) (900-1700 nm) has been investigated. To obtain a predictive model using spectroscopy data, real data needed to be collected so that it can be used to calibrate and validate the accuracy of the prediction model. Refractometer -A device used to measure the refractive index of plant juices in order to determine the mineral/sugar ratio of the plant cell protoplasm. The refractometer measured in units called Brix. NIRS is used to predict the Brix values in mango fruit. The mango fruits used as samples are of three different types namely: Chokonan, Rainbow, and Kai Te.

Spectra data collection
For this project, three different types of mango fruit were selected namely Chokonan, Rainbow, and Kai Te. Total of 60 samples was prepared to be scanned by the spectrometer. Samples were scanned by using handheld NIR spectrometer with a wavelength range of 900nm to 1700nm. Figure 1 is the picture of the handheld NIR spectrometer used in this research develop with Texas Instruments electronics board.
The samples were scanned in reflectance mode to record the absorbance spectra data. Each sample spectrum was measured for 3 seconds in reflectance mode. Some samples were scanned two times in different environment, and some were scanned only one time. A total of 80 spectra were collected from 60 samples. Spectral data was transfer in a form of the datasheet to both Orange software and MATLAB® simulation software for analysis.
The data measured by the spectrometer contains irrelevant data and affected by noise and scattering [6]. Per-processing spectral data is essential to get an efficient and accurate model [6], [7]. For this paper, Extended multiplicative signal correction (EMSC) is used to pre-process the spectra of polynomial order of 2. It is effective for elimination of uncontrollable path length or scattering effects. Under ideal conditions, the absorbance spectra data ( , ℎ ) can be seen as a sum of the contributions from the different chemical constituents with spectra ={ , =1,2,..., } and concentrations ={ , =1,2,..., }: EMSC can be expressed as follows [1]: Where is a measured spectrum, , ℎ is the ideal spectrum, is the identity matrix, is the wavelength, and , , , and are scalar parameters obtained by calibration. Spectrum , ℎ may be rewritten as a deviation from a reference spectrum , which could be, for example, the average of a set of empirical spectra as follows: where ∆ , represents the deviations in the analyte and interference concentration compared with that of the reference sample.

Brix level collection
Real data need to be collected to calibrate and validate the predictive model accurately to achieve a predictive model by using spectroscopy data. Refractometer-A tool used to measure plant juices refractive index to determine the plant cell protoplasm mineral/sugar ratio.
The MA871 is an optical instrument that employs the measurement of the refractive index to determine the % Brix of sugar in aqueous solutions as shown in Figure 2 [8]. The method is both simple and quick. Samples are measured after a simple user calibration with deionized or distilled water. Within seconds the instrument measures the refractive index of the sample and converts it to % Brix concentration units. The MA871 digital refractometer eliminates the uncertainty associated with mechanical refractometers and is easily portable for measurements in the field [8].
The measurement technique and temperature compensation employ methodology recommended in the ICUMSA Methods Book (Internationally recognized body for Sugar Analysis). Temperature (in °C or °F) is displayed simultaneously with the measurement on the large dual-level display along with icons for low power and other helpful message codes.

Support vector machine (SVM)
Support vector machines (SVM) could provide a learning method that is used for both regression and classification, with a fast algorithm that yields good results for many learning tasks [10]. Support vectors are the training examples that comprise the support vector machine [11]. Support vector machines cannot handle nominal data, necessitating pre-processing that transforms the nominal data to numerical data. SVM models, which are based on the statistical learning theory, are a new class of models that can be used for predicting values.

Partial Least Squares regression (PLS)
Partial Least Squares Regression (PLS Regression) is a statistical method which has some relation to principal component regression; it finds a linear regression model by projecting the predicted variables and the variables observable into another space instead of finding hyperplanes of highest variance between responses and independent variables. Due to the projection of both X and Y data in new spaces, the PLS processes family are known as bilinear factor models. Partial least squares (PLS-DA) Discriminant Analysis is a variation used when the Y is classified as categorical.
PLS is used to identify basic relationships between two matrices (X and Y) i.e. a latent approach to modeling covariance structures in both spaces. A model PLS attempts to locate the multidimensional direction in the X space that explains the maximum multidimensional direction of variance in the Y space. PLS regression is particularly suitable when there are more variables than observations in the predictor matrix, and when the X values are multi-linear. In contrast, in such cases (unless it is regularized), standard regression will fail. [9], [12]

Pre-processing
The raw absorption spectra from 80 samples of 3 different types of mango acquired from the spectrometer of wavelength ranging from 900nm to 1700nm are all recorded in Figure 3. This spectral data is then preprocessed by Extended multiplicative signal correction (EMSC) to eliminate the uncontrollable path length or scattering effects from the spectra data of polynomial order of 2 as shown in Figure 4.

Support vector machine (SVM) Regression
The transformed data is then divided into two subsets where 80% of the data is used to train the SVM prediction model and the remaining 20% of the data are used for testing. Regression cost (C) set for 100 and Complexity bound (v) set to 0.50. The coefficient of determination (R 2 ) obtained from SVM for training and testing dataset are 0.96 and 0.95 respectively. Table 1 shows the results for the predictive values compared to the actual values.

Partial Least Squares regression (PLS) Regression
PLS regression methods were used to find a linear regression model which gave a linear relationship between the multivariate NIR data and the Brix levels. MATLAB® simulation software was used for generating PLS calibration models and testing these model's accuracy. The 80 samples pre-processed data is then divided into two subsets where 80% of the data is used to calibrate the PLS prediction model and the remaining 20% of the data are used for testing. The coefficient of determination (R 2 ) obtained from PLS for calibrating and predicting dataset are respectively 0.89 and 0.86. Table 2 shows the results for the predictive values compared to the actual values. This regression result for both predicted values and actual values is also shown in Figure 5. Furthermore, Table 3 shows the comparison for regression using both PLS and SVM that indicate that the SVM regression produces better result in this project in terms of coefficient of determination (R 2 ) and RMSE (root mean squared error).

Conclusions
Methods for mango fruit quality are normally destructive in nature. Several methods were attempted to measure the inner quality of fruits, but most of these techniques are still invasive and take a lot of time and work. The ease of operation, speed, and reliability of processes make various mechanical, electromagnetic, and non-destructive methods increasingly important today. Recent studies have investigated an accelerated and simpler technique of fruit quality assessment using optical spectroscopy technology.
The results in this study showed that the NIR spectroscopy technique can be a promising tool to assess fruits quality and other products non-destructively. The NIR spectral data collected from the mango fruits and Brix levels are interrelated. The coefficient of determination (R 2 ) obtained from SVM for calibration and testing dataset are 0.96 and 0.95 respectively. Meanwhile, the coefficient of determination (R 2 ) obtained from PLS for calibration and testing dataset are 0.89 and 0.86 respectively. This project will be further improved, for example adding additional mango samples and software integration to test the calibrated tool on-site.