# Prediction of Arsenic Removal from Contaminated Water Using Artificial Neural Network Model
## 2 Materials and Methods
### ANFIS Model  
The ANFIS model was introduced as a combination of the neural network model and fuzzy logic [33; 34; 35; 36; 37; 38]. The ANFIS model showed a better performance in processing a small size of training datasets when compared to ANN [39]. A typical architecture of the ANFIS model has five layers: fuzzification, rule, normalization, defuzzification, and aggregation [40; 41; 42; 43]. In this study, the Takagi-Sugeno function and if-then rules were used to represent the non-linear relationship between the input and the output parameters [44; 45].  
A fuzzy inference system with two inputs and one output is used in describing the ANFIS model. The rules of the fuzzy inference system are shown as follows:  
\[Rule1:if\;x\;is\;A_{1}\;and\;y\;is\;B_{1},\;then\;f_{1}=p_{1}x+q_{1}y+r_{1} \tag{1}\]  
\[Rule1:if\;x\;is\;A_{2}\;and\;y\;is\;B_{2},\;then\;f_{1}=p_{2}x+q_{2}y+r_{2} \tag{2}\]  
where:  
\(A_{1}\), \(A_{2}\), \(B_{1}\), and \(B_{2}\) are the fuzzy sets;  
\(x\), and \(y\) are the input variables;  
\(p_{1}\), \(p_{2}\), \(q_{1}\), \(q_{2}\), \(r_{1}\), and \(r_{2}\): are the linear polynomial parameters; and  
\(f\) is the output of the ANFIS model.  
The layers of the ANFIS model used for the current study are described below and illustrated in Figure 1.  
**Layer 1:** This layer is called the fuzzification layer. In this layer, the fuzzy inference system uses a membership function to convert the input parameters into a fuzzy set. Among different types of membership functions, the Gaussian-shape membership function was applied in this work to map the training values between [0,1].  
\[O_{1,i}=\mu\;A_{i}(x_{i}) \tag{3}\]  
for \(i=1,2\)  
\[O_{1,i}=\mu\;B_{i}(y_{i}) \tag{4}\]  
for \(i=1,2\)  
\[\mu\;A_{i}(x_{i})=\frac{1}{1+\left(\frac{x_{i}-c_{i}}{\left|\frac{x_{i}-c_{i} }{\left|x_{i}\right|}\right)^{2b_{i}}}} \tag{5}\]where:  
\(O_{1,i}\) is the output of layer 1;  
\(\mu\) is the Gaussian-shape membership function;  
\(A_{i}\), and \(B_{i}\) represent the linguistic variables;  
\(x\) and \(y\) are the input variables; and  
\(\sigma_{i}\), \(b_{i}\), and \(c_{i}\) are the constants of the Gaussian-shape function.  
**Layer 2:** This layer has fixed nodes. The output of this layer is attained by multiplying all the receiving signals from the input layer. The output is represented by \(w_{i}\)  
\[O_{2,i}=w_{i}=\mu A_{i}(x)*\mu B_{i}(y),\ i=1,\ 2. \tag{6}\]  
**Layer 3:** The nodes in this layer are fixed and labeled as \(N\). In this layer, the outputs are obtained using the firing strength inference system rules.  
\[O_{3,i}=\overline{w}_{i}=\frac{w_{i}}{w_{1+w_{2}}},\ i=1,\ 2 \tag{7}\]  
where:  
\(O_{3,i}\) is the output of layer 3; and  
\(\overline{w}\) is the normalized firing strength of the inference system rules.  
**Layer 4:** This layer has adaptive nodes. It has three parameters used to adjust the adaptive nodes.  
\[O_{4,i}=\overline{w}_{i}.f_{i}=\overline{w}_{i}.(p_{i}x+q_{i}y+r_{i}) \tag{8}\]  
where:  
\(O_{4,i}\) is the output of layer 4; and  
\(p_{i},\ q_{i}\), and \(r_{i}\) are the parameters of the inference system.  
**Layer 5:** This layer is the inference layer, which is used to obtain the overall output based on the previous layers.  
\[O_{5,i}overall\ output=\sum\overline{w}_{i}f_{i}=\frac{\sum_{i}\overline{w}_{i}f _{i}}{\sum_{i}w_{i}} \tag{9}\]  
Earlier, the ANFIS model demonstrated a good performance in predicting the removal efficiency of some heavy metals other than \(As\) from aqueous solutions [25; 26; 27].