# Ensemble Method of Triple Naive Bayes for Plastic Type Prediction in Sorting System Automation
## 2 Materials and Methods
### Methods
In both combinations, decreasing and increasing linear functions are used to discretize the first and third categories for each predictor variable, while triangular and trapezoidal functions are used to discretize the second category in each combination. The fuzzy membership functions are presented in Equations (8)-(11). Assume that \(a\) is the least conspicuous domain entry with a membership value of 1, and \(b\) is the most conspicuous domain entry with a membership value of 0. The decreasing linear function is expressed as follows [22; 40]:  
\[\mu_{\widetilde{X}_{d}}\left(x_{f};a,b\right)= \begin{cases}1&x_{f}\leq a\\ \frac{b-x_{f}}{b-a}&a\leq x_{f}\leq b\\ 0&x_{f}\geq b\end{cases}  \tag{8}\]  
Let \(a\) be the least conspicuous domain entry with a membership value of 0, and \(b\) be the most conspicuous domain entry with a membership value of 1. The increasing linear function can be written as follows [22; 40]:  
\[\mu_{\widetilde{X}_{d}}\left(x_{f};a,b\right)= \begin{cases}0&x_{f}\leq a\\ \frac{x_{f}-a}{b-a}&a\leq x_{f}\leq b\\ 1&x_{f}\geq b\end{cases}  \tag{9}\]For the triangular membership function, assume that \(a\) is the least conspicuous domain entry with a membership value of 0, \(b\) is a domain entry with a membership value of 1, and \(c\) is the most conspicuous domain element with a membership value of 0. The function can be formulated as follows [22; 29; 41]:  
\[\mu_{\widetilde{X}_{d}}\left(x_{f};a,b,c\right)= \begin{cases}0&x_{f}\leq a\\ \frac{x_{f}-a}{b-a}&a\leq x_{f}\leq b\\ \frac{c-x_{f}}{c-b}&b\leq x_{f}\leq c\\ 0&x_{f}\geq c\end{cases}  \tag{10}\]  
Let \(a\) be the least conspicuous domain entry with a membership value of 0, \(b\) be a domain entry with a membership value of 1, \(c\) be a domain entry with a membership value of 1, and \(d\) be the most conspicuous domain entry with a membership value of 0. The trapezoidal membership function is represented as follows [22; 41]:  
\[\mu_{\widetilde{X}_{d}}\left(x_{f};a,b,c,d\right)= \begin{cases}0&x_{f}\leq a \\ \frac{x_{f}-a}{b-a}&a\leq x_{f}\leq b\\ 1&b\leq x_{f}\leq c\\ \frac{d-x_{f}}{d-c}&c\leq x_{f}\leq d\\ 0&x_{f}\geq d\end{cases}  \tag{11}\]  
In the machine learning concept, the prediction model performance is validated for unseen data, so the data must be split into training or modeling and test data. This research applied the k-fold cross-validation with k = 5 in the split dataset. The dataset was randomly separated into five folds of similar size, with one fold allocated as testing data and the remaining four assigned as modeling data. Each of the five iterations contained distinct data compositions for modeling and testing with a ratio of 80:20. The final model performance was the average of the five iterations [42; 43]. The 5 fold was less biased compared to other numbers of folds [44] and capable of evaluating the quality and the stability of the model as well as preventing overfitting without reducing the quantity of learning data used [42]. The ensemble prediction model performance was then tested to obtain prediction results, as are all basic models. Let TP\({}_{j}\) be the true positive prediction at \(j\)-th class, TN\({}_{j}\) be the true negative prediction at \(j\)-th class, FP\({}_{j}\) be the false positive prediction at \(j\)-th class, and FN\({}_{j}\) be the false negative prediction at \(j\)-th class. For the first class, all of the true and the false predictions are given in Table 1, and the other classes can be found similarly. The evaluation metrics of model performance for \(J\) classes of plastic type are given in (12)-(14) [20; 45]. \[\text{Accuracy}=\frac{\sum_{j=1}^{J}\frac{\text{TP}_{j}+\text{TN}_{j}}{\text{ TP}_{j}+\text{FP}_{j}+\text{FN}_{j}+\text{TN}}}{J} \tag{12}\]  
\[\text{Precision}=\frac{\sum_{j=1}^{J}\frac{\text{TP}_{j}}{\text{TP}_{j}+\text{ FP}_{j}}}{J} \tag{13}\]