# Explanation of Air Quality Data Using Takagi-Sugeno Fuzzy Inference System
## 4 Takagi-Sugeno Fuzzy Inference System  
The Takagi-Sugeno fuzzy inference system was created to analyse data that are describable by linear functions in certain parts of the domain of definition. This leads to the fact that the data need to be approximated in the remaining parts of the definition domain (see [6]). To work with such data, IF-THEN rules are created. These rules consist of assumptions (the IF part of the rules), in which input linguistic variables are represented by fuzzy sets, and consequences (the THEN part of the rules), in which output linguistic variables are represented by linear functions. In specific problems, there is a possibility to use constant functions as the consequence functions. Here is an example of the rules used in the Takagi-Sugeno fuzzy inference system:  
\[R_{k}:\;IF\;X_{1}\;is\;A_{1k}\;AND\;X_{2}\;is\;A_{2k}\;AND\ldots\;AND\;X_{n} \;is\;A_{nk},THEN\;Y\;is\;f(x_{1},x_{2},\ldots x_{n}). \tag{5}\]  
Above, \(R_{k}\;(k=1,2,\ldots,K)\) are the rules, \(X_{i}\;(i=1,2,\ldots,n)\) are input linguistic variables, \(A_{ik}\) are the values of the input variables expressed by fuzzy sets, \(Y\) is an output linguistic variable, \(f\) is the linear or constant function which represents the value of the output variable, and \(x_{i}\;(i=1,2,\ldots,n)\) are specific, measured values of input variables. The rules can be created by experts from the considered area or can be obtained by analysing a large number of known data. Of course, these two approaches can be combined. Let us mention some methods usable when analysing a large number of data. These methods are based on the design and subsequent optimisation of the rules. In the scope of MATLAB software, there are two possible methods for the creation of the Takagi-Sugeno fuzzy inference system. The first one, the so-called Grid Partition method, is based on the principle that the definition scope of each input variable is divided into the required number of parts. In this way, the definition scope of an \(n\)-dimensional cuboid of inputs is divided into smaller parts (\(n\)-dimensional cuboids), and to each part (cuboid), the output value is assigned. The number of rules is equal to the number of cuboids the domain is divided into. Such an approach is suitable if a small number of input variables is used. The second one, the Subtractive Clustering method, is based on a specific clustering method where the points with the largest number of neighbours are chosen as cluster centres (see [26]). To each cluster centre, some output value is assigned. Then, the rules are created in such a way that the values of the input variables are computed from the values of cluster centres and the output values are the same as the values assigned to the output values of the cluster centres. Depending on the parameters set by the user, the method determines the number of cluster centres. With the change in the method parameters, it is possible to achieve a smaller/larger number of cluster centres and thus also a smaller/larger number of rules, which leads to the possibility of the optimisation of the number of rules in the system. In the next step, the parameters of input and output variables need to be optimised (see Section 3). Several techniques have been developed for the parameter optimisation of Takagi-Sugeno FISs. For example, evolutionary algorithms (see [27]) or artificial neural networks (see [28]) can be used. We worked with an adaptive network-based fuzzy inference system (ANFIS), which is an optimisation method using artificial neural network principles (see [28]). The ANFIS consists of a neural network of five layers, where two of the layers are adaptive (one of them optimises the parameters of the input variables, and the other optimises the parameters of the output variables) and the rest of the layers are computational. As an input of the ANFIS, some Takagi-Sugeno FIS is given. Then, as a result, a new Takagi-Sugeno FIS with the same number of rules but with new variable parameters is obtained.