# Ensemble Method of Triple Naive Bayes for Plastic Type Prediction in Sorting System Automation
## 2 Materials and Methods
### Methods
The posterior probability is determined according to the Bayes theorem, which is based on the assumption that the predictor variables are independent in a naive (strong) manner. Let \(Y_{j}\) be the target variable that denotes the \(j\)-th class of plastic type, \(P\left(Y_{j}\right)\) be the \(j\)-th class or type prior probability, \(P\left(X_{1},\cdots,X_{D}\middle|Y_{j}\right)\) be the likelihood function of the \(D\) predictor variables, and \(P\left(X_{1},\cdots,X_{D}\right)\) be the joint distribution function of the plastic type. The posterior probability of the plastic type is written as follows [18; 22]:  
\[ \begin{array}{ll}P\left(Y_{j}|X_{1},\cdots,X_{D}\right)&=\frac{P\left(Y_{j} \right)\,P\left(X_{1},\cdots,X_{D}\middle|Y_{j}\right)}{P\left(X_{1},\cdots,X_{ D}\right)}\\ &=\frac{P\left(Y_{j}\right)\,\prod_{d=1}^{D}P\left(X_{d}\middle|Y_{j}\right)}{ \prod_{d=1}^{D}P\left(X_{d}\right)}\end{array}  \tag{3}\]  
To involve discretization in the naive [PERSON] method, either crisp or fuzzy discretization, the predictor variables need to be of categorical type, so Equation (3) is adjusted to become Equation (4) [22; 36]:  
\[P\left(Y_{j}|X_{1},\cdots,X_{D}\right)=\frac{\sum_{d=1}^{D}n\left(X_{d} \middle|Y_{j}\right)+1}{n\left(Y_{j}\right)+D}\prod_{d=1}^{D}\frac{\sum_{k}^{m }n_{k}\left(X_{d}\middle|Y_{j}\right)+1}{n\left(X_{d}\middle|Y_{j}\right)+m} \tag{4}\]where \(n\left(X_{d}|Y_{j}\right)\) is the amount of plastic images associated to the \(j\)-th class in all variables \(X\), \(n\left(Y_{j}\right)\) is the amount of plastic images in the \(j\)-th class, \(n_{c}\left(X_{d}|Y_{j}\right)\) is the amount of plastic images associated to the \(j\)-th class in a variable \(X_{d}\) with category \(k\), and \(m\) is the number of categories in the variable \(X_{d}\). The \(j\)-th likelihood function and the \(j\) -th class or type prior probability, respectively, can be expressed as follows [18; 22; 36]:  
\[P\left(X_{d}|Y_{j}\right)=\frac{\sum_{k}^{m}n_{k}\left(X_{d}|Y_{j}\right)+1}{n \left(X_{d}|Y_{j}\right)+m} \tag{5}\]  
\[P\left(Y_{j}\right)=\frac{\sum_{d=1}^{D}n\left(X_{d}|Y_{j}\right)+1}{n\left(Y _{j}\right)+D} \tag{6}\]  
The following assumptions are needed to integrate fuzzy discretization into naive Bayes. Suppose \(\widetilde{X}_{d}=\left\{x_{f_{1}},\ x_{f_{1}}\cdots,x_{f_{Z}}\right\}\) is the fuzzy sample information space of the red, green, and blue as predictor variables of \(X_{d}\), \(x_{f_{z}}\in X\) is the independent event, and \(\mu_{\widetilde{X}_{d}}\left(x_{f_{z}}\right)\) is the fuzzy membership function of \(X_{d}\), then the fuzzy sample conditional probability function is formulated as \(P\left(\widetilde{X}_{d}\left|Y_{j}\right.\right)=\sum_{z=1}^{Z}P\left(x_{f_{ z}}\left|Y_{j}\right)\mu_{\widetilde{X}_{d}}\left(x_{f_{z}}\right)\), and the prior probability of the predictor variable is \(P\left(\widetilde{X}_{d}\right)=\sum_{z=1}^{Z}P\left(x_{f_{z}}\right)\mu_{ \widetilde{X}_{d}}\left(x_{f_{z}}\right)\). Since the evidence is not fixed in the fuzzy set and the Laplace smoothing effect, the posterior probability is as follows [22; 39]:  
\[P\left(Y_{j}|X_{1},\cdots,X_{D}\right) = \frac{P\left(Y_{j}\right)\prod_{d=1}^{D}P\left(\widetilde{X}_{d} \left|Y_{j}\right.\right)}{\prod_{d=1}^{D}P\left(\widetilde{X}_{d}\right)}\] \[= \frac{P\left(Y_{j}\right)\prod_{d=1}^{D}\sum_{z=1}^{Z}P\left(x_{f _{z}}\left|Y_{j}\right.\right)\mu_{\widetilde{X}_{d}}\left(x_{f_{z}}\right)+ \frac{1}{Z}}{\prod_{d=1}^{D}\sum_{z=1}^{Z}P\left(x_{f_{z}}\right)\mu_{ \widetilde{X}_{d}}\left(x_{f_{z}}\right)+\frac{1}{Z}} \tag{7}\]  
The development of the naive Bayes model using fuzzy discretization includes two different combinations of fuzzy membership functions. First, a combination of triangular functions and linear functions (decreasing, increasing). Second, a combination of trapezoidal functions and linear functions (also decreasing and increasing).