# Explanation of Air Quality Data Using Takagi-Sugeno Fuzzy Inference System
## 5 Data Analysis
Therefore, we gradually increased the value of the parameter _Range of influence of the cluster centre_ from the value 0.5 to the value 0.8. Using the value 0.65, the algorithm determined 12 clusters and generated 12 rules. Such a number of rules is suitable for the explainability of the created system. In the next step, we used an ANFIS (as mentioned at the end of Section 4) to optimise the parameters of the created rules. When we optimised the rule base with 28 rules, we achieved a total RMSE equal to 9.0016. After the optimisation of the rule base with 12 rules using ANFIS, we achieved a new FIS (see Figure 4) with a total RMSE equal to 9.2817. To compare the obtained models with other models, we applied all regressors offered by MATLAB software to the examined data. MATLAB version R2018a offers the Regression Learner app, which includes four linear regression models, three types of regression trees, six methods using SVM, four types of Gaussian progress regression (GPR) models, and two types of ensemble tree models. We used all of them to determine which method produces the lowest error on our data (see Table 2). The lowest value of RMSE with the use of MATLAB-implemented models was reached by using Rational Quadratic Gaussian Progress Regression, where the error was equal to 9.2061. The second-best result was reached using Exponential Gaussian Progress Regression, where the RMSE was equal to 9.3088. Based on the comparison with the methods used by us, it is obvious that our model with 28 rules achieved the lowest error. Similarly, our model with 12 rules achieved the third-best result. All these results, together with some ideas to improve them, are mentioned in [8]. Now, we pay attention to the explainability of the created system. The problem with the obtained models is that the Subtractive Clustering method, which is implemented in MATLAB software, always assigns linear functions to the output variables. If we want to create an explainable system, it is appropriate for the output variables to be defined by constant functions. We tried to answer the question of whether it is possible to change the output variable function from linear to constant in such a way that the error rate inflates minimally. If, for a certain combination of our inputs, we assumed an output value of, for example, 45, then the rule with a constant output would look like this:  
\(R_{k}\): _IF The wind speed is high AND... AND The number of vehicles is low,_  
_THEN The value of \(PM_{10}\) is 45._  
Figure 4: Fuzzy rule base with linear outputs which consists of 12 rules. Each row represents one rule. The columns represent individual variables. The red lines represent specific input values. The output value of the system is shown in the upper right corner of the figure. We decided to use an already-created model with 12 rules. The research question was how to create constant output values if the input values are specified by using Gaussian membership functions (see Figure 4). The natural answer was that for each rule, we take the values of the position of the centres of the input Gaussian functions (position of their peaks) and insert them into the prescription of the output linear function. As mentioned before, in MATLAB software, we have been working on a graphical user interface called Fuzzy Logic Toolbox. Now, it is the time to look at the code of the created Takagi-Sugeno FIS. Figure 5 presents function parameters of some individual input and output variables created by MATLAB software. In Figure 5, the value of the position of the centre of the Gaussian function for the first input variable in the first rule is marked in yellow. Of course, we considered the values of the position of the centres of all the Gaussian functions that occurred in the first rule. We have ten values (let us label them \(x_{1,1},x_{1,2},\ldots,x_{1,10}\)). On the other hand, to each rule, an output in the form of 11 values was assigned (they are marked in green in Figure 5).