## Summary

Fuzzy logic is used in converting crisp (binary, definite) data into linguistic data using membership functions. Using the FIS (Fuzzy Inference System) method, my own created fuzzy knowledge base was applied on a real dataset where the result value varies depending on four different attributes, to predict the result value through four attributes. Predictions were made using the Mamdani methodology with CoA (Center of Area) and BoA (Bisector of Area) aggregation methods. As a result, an accuracy of up to 92% compared to real values was achieved.

## 1. Introduction

Fuzzy logic is used in converting crisp data into linguistic data using membership functions. Nowadays, we encounter FIS systems unaware in many places such as air conditioners, cars, trains, etc. The most significant determinant in FIS systems is expert knowledge.

## 2. FIS

FIS consists of four main components: fuzzifier, inference engine, defuzzifier, and fuzzy knowledge base. Figure 2.1 depicts the FIS schema.

### I. Fuzzy Knowledge Base

The most crucial thing to know when creating an FIS system is that expert knowledge is of paramount importance in constructing the fuzzy knowledge base. Membership functions created by experts and rules based on the selected method, either Mamdani or other, are found here. Otherwise, the FIS system can produce entirely incorrect results, which is the weakest point of FIS systems.

### II. Fuzzifier

It facilitates the fuzzification of your crisp data within the fuzzy knowledge base using your membership functions and generates fuzzy outputs as a result. Detailed discussion on creating membership functions is provided under the "Method" section in the paper. Membership functions were constructed by drawing Box Plot graphs of the datasets to obtain piecewise functions based on the smallest, largest, and median values.

### III. Inference Engine

It applies your rules within the fuzzy knowledge base to the fuzzy inputs obtained from the fuzzifier, generating a fuzzy output. The Mamdani Fuzzy Model is used in the paper. The Mamdani model is also known as "max-min implication." The rules created are of the "IF-THEN" type, and the values are linguistic values directly, unlike in another model like Sugeno. Additionally, rules are connected with connectors such as AND-OR-ELSE.

### IV. Defuzzifier

It combines the fuzzy outputs generated by the Inference Engine according to the membership function within the Fuzzy knowledge base and produces a result based on the aggregation method. The CoA (Center of Area) and BoA (Bisector of Area) methods are preferred as the aggregation methods in the paper.

## 3. Dataset

The dataset used consists of 4 features and 1 output value. These are:

- Iy (Load current)
- PF (Power Factor)
- e (Power factor error)
- dIf (Changing the excitation current of the synchronous machine)
- If (Excitation current of the synchronous machine)

A "If" value is measured for 4 features. The dataset contains 557 measurement data.

## 4. Method

Firstly, the features of the dataset should be plotted using Box Plot to obtain values such as median, Q1, Q3. To create membership functions with Box Plot, 5 data points are required for each attribute. These are: median, Q1, Q3, smallest value, largest value. Since graphical operations are simpler in Python, Python was used to draw Box Plot graphs.

For the Iy attribute, the values and Box Plot are as follows:

- Lowest: 3
- Largest: 6
- Median: 4.5
- Q1: 3.7
- Q3: 5.3

For the PF attribute, the values are as follows:

- Lowest: 0.65
- Largest: 1
- Median: 0.82
- Q1: 0.74
- Q3: 0.92

For the e attribute, the values are as follows:

- Lowest: 0
- Largest: 0.35
- Median: 0.18
- Q1: 0.08
- Q3: 0.26

For the dIf attribute, the values are as follows:

- Lowest: 0.037
- Largest: 0.769
- Median: 0.345
- Q1: 0.189
- Q3: 0.48625

For the If attribute, the values are as follows:

- Lowest: 1.217
- Largest: 1.949
- Median: 1.525
- Q1: 1.369
- Q3: 1.66625

Two methods exist for creating membership functions based on these values. The first method, which has been used for a long time, creates a three-piece membership function, while the second method, more recently proposed, creates a five-piece membership function. The five-piece membership function can be created using the piecewise functions shown in Figure 4.6.

As seen in Figure 4.6, the piecewise functions have been created using Box Plot metrics. However, since our dataset consists of 557 data points, if we were to use a five-piece membership set, at least $5^n$ (where n is the number of attributes), i.e., 625 rules, should be written. Due to the scarcity of data in the dataset, a three-piece membership function is preferred. Three-piece membership functions can be created with the piecewise functions seen in Figure 4.7.

The membership function created for the Iy attribute is given in Figure 4.8.

The membership function created for the PF attribute is given in Figure 4.9.

The membership function created for the e attribute is given in Figure 4.10.

The membership function created for the dIf attribute is given in Figure 4.11.

The membership function created for the If attribute is given in Figure 4.12.

After the creation of membership functions, they are defined with FCL as seen in Figure 4.13 (Cingolani & Alcala-Fdez, 2012).

In the Defuzzify part, to avoid the NaN situation if no value is obtained from the membership function, a DEFAULT value of 1.525, which is the median, is defined. Although we do not have data that would result in a NaN situation, other data besides these should not be ignored.

After completing the Fuzzify and Defuzzify sections, since we have four attributes and three-piece membership functions for each, at least $3^4$, i.e., 81 rules, should be created. Initially, all rules were created to indicate the result as "low" value and entirely with AND connectors. Later, the dataset was sorted according to the If values, so the resulting values would also be sorted. After sorting, pieces where the data coincided every five rows were identified, and the pieces indicated by the rules were updated to med and high values. After the update, error values for CoA were calculated as follows:

- MAE => 0.15719705272984164
- RMSE => 0.18592171065488275

To further reduce the error value, changes were made to the rules, but the method was changed. In the new method, the dataset was sorted based on the predict values, i.e., the difference between desired and predicted values, and at the bottom, there always remains the data that increases the error rate the most. Results values on rules affecting the data causing the most errors were changed, and changes were made to the connectors, resulting in the error values for the CoA method to regress to the following values:

- MAE => 0.07178920147606488
- RMSE => 0.08759046857426464

## 5. Conclusion

The error values obtained with CoA using the developed FIS system are as follows:

- MAE => 0.07178920147606488
- RMSE => 0.08759046857426464

For the BoA method, the error values are as follows:

- MAE => 0.06396308797127467
- RMSE => 0.08051538814306027

As seen, it has been demonstrated that the system can make predictions with success rates around 90%. However, the results obtained with the CoA method and the real values are presented in the same graph in Figure 5.1.

Similarly, for the BoA values and real values, there is a slight difference in error values, which is reflected in the graph. The graph for BoA values and real values is shown in Figure 5.2.

The error values for the MoM method are as follows:

- MAE => 1.4061101427930272
- RMSE => 1.4600037510978092

For the LoM method, the error values are as follows:

- MAE => 0.17602335727109497
- RMSE => 0.28191388723186933

And for the RoM method, the error values are as follows:

- MAE => 0.19051116696588882
- RMSE => 0.28938617827136487

As seen from the error values, while RoM, LoM, and MoM values experience significant deviations, a system with satisfactory prediction capability, generally over 90%, has been demonstrated with CoA and BoA methods.

## 6. References

Hasan, M.F. and Sobhan, M.A. (2020) Describing Fuzzy Membership Function and Detecting the Outlier by Using Five Number Summary of Data. American Journal of Computational Mathematics, 10, 410-424. doi: 10.4236/ajcm.2020.103022.

Asanka, PPG & Perera, Amal. (2017). DEFINING FUZZY MEMBERSHIP FUNCTION USING BOX PLOT. IJRCAR. 5. 1-10.

Cingolani, Pablo & Alcala-Fdez, Jesus. (2012). JFuzzyLogic: A robust and flexible Fuzzy-Logic inference system language implementation. IEEE International Conference on Fuzzy Systems. 1-8. 10.1109/FUZZ-IEEE.2012.6251215.

## SOURCES

## DISCLAIMER

This document is translated from Turkish to English using ChatGPT. The original document is written by the in Turkish. The translation may contain errors and inaccuracies.