## 3 Machine Learning Based Methodology  
A machine learning (ML) algorithm based on multivariate polynomial regression (MPR) analysis was adopted to identify the relationship between variables and allowed the prediction of the mixing index.  
The MPR used to estimate the coefficient values for different variables in the mixing process was derived from a Second Order Multiple Polynomial Regression expressed as:  
\[y=\beta_{0}+\beta_{1}x_{1}+\beta_{2}x_{2}+\beta_{11}x_{1}^{2}+\beta_{22}x_{2}^{2 }+\varepsilon \tag{1}\]  
where \(\beta_{1}\) and \(\beta_{2}\) are called as linear effect parameters, \(\beta_{11}\) and \(\beta_{22}\) are called as quadratic effect parameters, \(\beta_{0}\) is the bias, and \(\varepsilon\) is the error in the normal distribution.  
According to [22], the Regression Function is given in Equation (2):  
\[E(y)=\beta_{0}+\beta_{1}x_{1}+\beta_{2}x_{2}+\beta_{11}x_{1}^{2}+\beta_{22}x_{ 2}^{2} \tag{2}\]  
The representation of the polynomial regression in a matrix form is given in (3):  
\[Y=\beta X+\varepsilon \tag{3}\]  
The estimated parameters can be computed as in Equation (4):  
\[\hat{\beta}=\left(X^{\prime}X\right)^{-1}X^{\prime}Y \tag{4}\]  
And the Computed Regression Equation is represented in (5):  
\[\hat{y}=\hat{\beta}_{0}+\hat{\beta}_{1}x_{1}+\hat{\beta}_{2}x_{2}+\hat{\beta}_ {11}x_{1}^{2}+\hat{\beta}_{22}x_{2}^{2} \tag{5}\]  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Design** & **Surfactant** & **Sodium** & **Sodium** & **Coloured** & **Liquid** & **Nonionic** \\
**Point** & **Particle** & **Carbonate** & **Sulphate** & **Speckle** & **Surfactant** \\ \hline
1 & 25.0 & 0.9 & 72.1 & 1.0 & 1.0 \\
2 & 25.0 & 0.9 & 68.7 & 1.0 & 4.4 \\
3 & 25.0 & 0.9 & 73.1 & 0.0 & 1.0 \\
4 & 25.0 & 0.9 & 69.7 & 0.0 & 4.4 \\
5 & 25.0 & 36.7  
In order to assess the accuracy of the predicted values obtained by the regression-based ML model, the most used traditional metrics can be adopted [23]. _MAPE_ (mean absolute percentage error), _MAE_ (mean absolute error), _RMSE_ (root mean square error), and \(R^{2}\) (coefficient of determination) metrics were calculated as in Equations (6)-(9):  
\[MAPE=\frac{100}{n}{\sum}_{i=1}^{n}\left|\frac{y_{i}-\hat{y}_{i}}{y_{i}}\right| \tag{6}\]  
\[MAE=\frac{1}{n}{\sum}_{i=1}^{n}|y_{i}-\hat{y}_{i}| \tag{7}\]  
\[RMSE=\sqrt{\frac{1}{n}{\sum}_{i=1}^{n}(y_{i}-\hat{y}_{i})^{2}} \tag{8}\]  
\[R^{2}=1-\frac{{\sum}_{i=1}^{n}(y_{i}-\hat{y}_{i})^{2}}{{\sum}_{i=1}^{n}\left(y _{i}-\overline{y}_{i}\right)^{2}};\overline{y}_{i}=\frac{1}{n}{\sum}_{i=1}^{n} y_{i} \tag{9}\]  
where \(y_{i}\) is the actual value, \(\hat{y}_{i}\) is the predicted value, and n is the number of data points.  
Figure 4 shows the flowchart of the methodology defined to predict the mixing index of the mixing process. The DEM model created is used to obtain the dataset. According the 25 design points listed in Table 4 and considering a time every 5 s from 5 to 60 s, a dataset of 300 data points was created. Each data point is composed by values of the inputs and the output. For the predictive model, the inputs are time and mass fraction of surfactant, carbonate, speckle and nonionic, and the output is the mixing index. The sulphate mass fraction is not considered an input because it depends on the total amount of the other components.  
The dataset is divided into 2 parts. A total of 280 data points are used to train and test the predictive model. The other 20 data points are used to perform an independent validation of the model. In this process of training and validation, the accuracy of the predictive  
Figure 4: Flowchart of the methodology.  
model results is assessed by calculating the error metrics indicated in Equations (6)-(9). Finally, the predictive model is obtained and allows us to predict the mixing index for any allowable combination of the components.