**2. Methodology**

#### **2.1 Case study**

The mayonnaise is one of the most common seasoning products, it is used in a wide variety of food dishes (such as salads, sandwiches, hamburgers, among others). The traditional formulation consists of oil (up to 80% of the product), vinegar or lime juice, egg yolk, sugar, salt, and pepper. Nevertheless, there are some variations of this sort of products like low-fat mayonnaise, egg-free mayonnaise, virgin oil mayonnaise, among others [18]. These varieties have different ingredients such as stabilizers,

emulsifiers, and thickening agents [19] which makes challenging the prediction of the sensory attributes.

The present case of study is to estimate the acceptability of mayonnaises using the formulation, physical attributes, and sensory evaluation scores. To achieve the objective, a dataset of different features of the mayonnaises was generated and two different algorithms were used: a Multivariate Linear Regression Model (MLRM) and an Adaptive Neuro-Fuzzy Inference System (ANFIS).

### **2.2 Software and equipment**

The database processing, the models' development, and the data visualization were done with Python 3.8.1 using Spyder (v 5.1.1) in Anaconda Navigator for Windows (v. 2.0.4). The libraries used for the database processing were Pandas (v. 1.2.5) and Statsmodels (v. 0.12.2). The MLRM was constructed using Scikit-Learn library (v. 0.24.2) and the ANFIS model was developed with Keras (v. 2.4.3) and Tensorflow (v. 2.5). The data visualization (Figures) was done with Matplotlib (v. 3.3.4).

The computational equipment was a laptop with a processor Intel core i5 10th gen (Quad-core at 2.5 GHz), 16 GB RAM at 2933 MHz, and a NVIDIA GeForce GTX 1660ti GPU (6 GB of VRAM, 1770 MHz and 1536 CUDA cores).

#### **2.3 Database development**

The product formulation and some physical characteristics were selected to develop the database considering that these features have an impact in the sensory properties, and they could be used for the acceptability prediction. The data was retrieved from published research articles, around 34 studies were found with the desired characteristics, which included all formulation of the mayonnaise, viscosity or texture analysis, and sensory evaluations. The research papers with incomplete data (i.e.: incomplete texture analysis, incomplete rheological analysis, without acceptability determination) were discarded. After the information filtering, the experimental data of 22 research papers were included.

The database obtained included the formulation (oil content, egg yolk, water content, flavorings, and vinegar), viscosity, taste score, texture score, and acceptability score; furthermore, a correlation matrix was generated to select the most pertinent data for the models. The whole database was comprised of 64 observations and 10 features (matrix 64 x 10), nevertheless, it was separated in the following sets:


#### **2.4 Development of machine learning models**

#### *2.4.1 Multivariate linear regression model (MLRM)*

Multivariate linear regression is a common mathematical approach to modeling data where a dependent variable, usually, has a direct association with the

independent variables. Then, the dependent variable is fitted with the independent variables in a mathematical function (Eq. (1)), which is used to predict the new data. The MLRM training and test split was done with 85/15% (respectively) of the data from the training-testing set.

$$Y = \beta\_0 + \beta\_1 \mathbf{x}\_1 + \beta\_2 \mathbf{x}\_2 + \dots \beta\_n \mathbf{x}\_n \tag{1}$$

Where *Y* is the output variable, *β<sup>0</sup>* is the intercept, *β<sup>n</sup> xn* are the coefficient and the independent variable, respectively.

#### *2.4.2 Adaptive neuro-fuzzy inference system (ANFIS) model*

The ANFIS is a method developed in 1993 by Jang [20], this model (ANFIS) combines the fuzzy logic learning (if-then rules) to convert the input data into a desired output through several interconnections in an artificial neural network. Along these interconnections, several if-then rules are set to stablish a relationship between the inputs and the output [21]. The architecture of the model is complex, in **Figure 1** is shown a schematic representation of two inputs and the interconnections between the layers, usually, the ANFIS architecture contains 5 layers as follows.

In the first layer (Layer 1), known as the input layer, is where the membership functions are determined for the input nodes by the premise parameters. The membership functions (MF) help to define the degree of truth (e.g.: IF "x" is True and "y" is False THEN "z = ƒ (x, y)") for a crisp value in a scale from 0 to 1, where 0 is False and 1 is True. Each membership function (*μ*) was calculated by the algorithm following the gaussian MF equation (Eq. (2)).

$$\mu\_{\text{Ai}}(X) = \mathbf{e}^{-\frac{1}{2}\left(\frac{x-c}{\sigma}\right)^2} \tag{2}$$

Where *A* is the layer node, *X* is the input variable, *c* and *σ* represent the premise parameters.

Layer 2 is the fuzzifier or rule layer, where the firing strengths (*w*i) for the membership functions are determined. The firing strengths represents the degree of

the effect of each membership function to the output variable. The firing strengths were calculated as shown in Eq. (3).

$$
\mu\_i = \mu\_{\rm Ai}(X) \* \mu\_{\rm Bi}(Y) \tag{3}
$$

Where *w* is the firing strength and *μ* is the membership function. A and B represent the input nodes and *X* and *Y* the input variables.

In the third layer (Layer 3), the firing strengths are normalized (*wi*) as the ratio of the nth fire strength to the total firing strengths. This could be expressed as follows (Eq. (4)).

$$\overline{w\_i} = \frac{w\_i}{w\_1 + w\_2 + w\_3 + w\_4} \tag{4}$$

Where *wn* corresponds to each of the firing strengths calculated in the second layer.

Layer 4 is known as the defuzzification layer, in this layer, the weighted values of rules are calculated. This is expressed by the following equation (Eq. (5)).

$$
\overline{w\_{\dot{\vartheta}}} \dot{\mathbf{y}}\_i = \overline{w\_i} (p\_i \mathbf{x} + q\_{\dot{\vartheta}} \mathbf{y} + r\_i) \tag{5}
$$

*wi* represents the output of the third layer and *p*, *q*, *r* are the consequence parameters.

Layer 5 is the output layer, the output is a summatory of all outputs of the fourth layer, as it is shown in Eq. (6).

$$\sum\_{i} \overline{w\_{i}} f\_{i} = \frac{\Sigma\_{i} w\_{i} f\_{i}}{\Sigma\_{i} w\_{i}} \tag{6}$$

The source code for the ANFIS was adapted from a repository on Github [22]. All the data was scaled (from 0 to 1), and the results obtained were re-scaled to original values using the MinMaxScaler function of Scikit-Learn library (v. 0.24.2). The optimization of the algorithm was done using the Adam optimizer, and the mean squared error was used as loss value function. The parameters of the ANFIS model were set after varying the number of membership functions (4–16) and the training and test data split was set at the same conditions as the MLRM (train and test split at 85/15% of the training-tasting set).

#### **2.5 Models evaluation**

The models performance was evaluated with the validation set (8 unseen data points) [17], comparing the adjustment (r<sup>2</sup> ) and the mean squared error (mse) in the predicted values with Eqs. (7) and (9), respectively.

$$r^2 = 1 - \frac{\sum\_{i=1}^{N} [O\_i - T\_i]^2}{\sum\_{i=1}^{N} [O\_i - T\_m]^2} \tag{7}$$

Where *Oi* is the real value,*Ti* is the predicted value, *N* the number of data, and *Tm* is the ratio of the real values and *N* (Eq. (8)).

$$T\_m = \frac{\sum\_{i=1}^{N} \mathcal{O}\_i}{N} \tag{8}$$

$$mse = \frac{1}{N} \sum\_{i=1}^{N} \left( O\_i - T\_i \right)^2 \tag{9}$$
