A Novel Approach to Evaluate the Quality of Life in Urban Environments by using Fuzzy classifiers Wojciech Barciński1 , Jan Dylik1 1 Silesian University of Technology, Faculty of Applied Mathematics, Kaszubska 23, 44-100 Gliwice, Poland Abstract In this paper, we present our fuzzy classifier, built from scratch, and test how well it performs a task of classifying cities to either ’better’ or ’worse’ category, based on their numerical ratings of various aspects of living there. We check several combinations of norms and defuzzyfying methods, compare the results with three different fixed classifications - based on weighted sum, GDP per capita and human expert judgement. We also tried out few different classifiers, such as KNN, naive Bayes and soft set based classifier to see which one yields best results for this task. Keywords Fuzzy classifier, Teleport’s city quality of life, Expert systems, Type 1 fuzzy sets 1. Introduction attributes of the examined city and produces a numeri- cal value from 1 to 100 alongside with linguistical value The latest trends in the creation of modern IT systems are ’better’ or ’worse’, all based on comparison with expert based on the use of artificial intelligence systems [1, 2]. knowledge database, written in form of if-then rules with A very important part of the application are solutions chained linguistical values describing selected attributes based on [3, 4, 5, 6, 7] neural networks. The use of neural of city’s conditions. We conducted a range of tests to see networks is related to the protection of health [8], the the influence of different parameters, rulesets, datasets detection of various, often not obvious for a human, fea- and other classifiers on effectiveness of this approach. tures [9, 10, 11]. The use of neural networks in machine learning [12, 13] is also very popular. This work will be devoted to the applications of fuzzy sets [14, 15, 16] 2. Overview which have many different applications, including in car systems [17] or in computational intelligence [18, 19, 20] 2.1. Introduction to fuzzy logic systems also applied to the field of smart home [21] and The main idea between fuzzy logic is that there are some environment [22]. phenomena which are best interpreted by humans when In this day and the age, due to modern technology and they are described with words, not numbers, therefore expansion of the Internet, people have access to much some kind of system must exist in order to connect nu- more data than ever before[23, 24, 25], which grants the merical data to linguistic terms, to then perform all the possibility of greatly empowering their decision making reasoning and at the end be able to convert the result processes. However, in the sheer amount and size of the back to number, if necessary. Because the process of rea- available informations lies its biggest problem – it is un- soning, mostly referred to as inference, happens with the reasonable for single person to do as much research as it sole use of words, so linguistic values, it is managable is necessesary for an informed decision. Solution to this for human experts to inject their reasoning into the sys- problem appears in form of centralized and focused data tem, even in vague terms, to reliably simulate intuitive sources, where information is easily available, grouped and realistic judgements. For example, a fuzzy system and distilled into its most relevant form for laymen, and gets some the measurement of the temperature, let’s say recommendation systems, which aim to take the process 20∘ C, is able to translate it to linguisitc value "hot", it step further, and directly asks users about their needs sees that expert defined behavior "if temperature is hot in order to compile list of best answers. It is this type then don’t use heating system" then concludes that there of solution, which captured our interest. We created a is no need for heater to be enabled, so it shuts it off. classifier based on fuzzy logic, which takes in a vector with numerical ratings (scale from 0 to 1.0) of various 2.2. Fuzzy logic flow SYSYEM 2022: 8th Scholar’s Yearly Symposium of Technology, Engi- neering and Mathematics, Brunek, July 23, 2022 1. Preparations - expert defines rules for evaluation, and " wojcbar530@polsl.pl (W. Barciński); dylik530@polsl.pl all the antecedents and consequents as well as their (J. Dylik) membership functions. Antecedents refer to cate- © 2022 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). gories of fuzzy variables, so the variables that have CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) 26 Wojciech Barciński et al. CEUR Workshop Proceedings 26–32 Figure 1: Flowchart of the fuzzy system numerical and linguistical interpretations, for exam- 2.3. Membership functions ple ratings of Housing and Taxation. Consequents Degree of membership of each variable to a linguistic cat- refer to potential outcomes from the system, for ex- egory is contained within a numerical value from range ample Good, Average, Bad. [0, 1]. It is a result of passing numerical value, in our 2. Input - numerical input, usually vector of numeric implementation min-max normalized, to a predefined values, is provided. It will be referred to as "crisp function of membership of its category. Fuzzy logic pro- value" vides many versitale functions for such a process, with the most popular ones, and the ones used in our project, 3. Fuzzification - crisp values from inputted vector are being triangular and trapezoidal. being used as arguments for each membership func- Triangular: tion of the linguistic category they refer to. Member- ship function with highest value from each category 0, if 𝑥 ≤ 𝑎 ⎧ ⎪ will define which linguistic value will be bound to ⎪ ⎪ 𝑥 − 𝑎 , if 𝑎 < 𝑥 ≤ 𝑏 ⎪ ⎪ corresponding attribute of the input vector. ⎪ 𝑏−𝑎 ⎨ 𝜇trimf (𝑥) = (1) 𝑐−𝑥 4. Inference - numerical interpretations of degrees of , if 𝑏 < 𝑥 ≤ 𝑐 ⎪ ⎪ 𝑐−𝑏 ⎪ membership from fuzzification step are being used in ⎪ ⎪ ⎪ if 𝑥 > 𝑐 ⎩ calculation of each rule’s level of fulfilment. Evalua- 0, tion process includes numerical interpretation of logi- Trapezoidal: cal operations between rule requirements. For each possible linguistic value of an outcome its highest ac- ⎧ 0, if 𝑥 ≤ 𝑎 tivated rule value, so a result of former evaluations, ⎪ ⎪ ⎪𝑥 − 𝑎 ⎪ is being saved. , if 𝑎 < 𝑥 ≤ 𝑏 ⎪ ⎪ ⎨𝑏−𝑎 ⎪ ⎪ ⎪ 5. Defuzzification - a function is being made, by com- 𝜇trapmf (𝑥) = 1, if 𝑏 < 𝑥 ≤ 𝑐 (2) bining all the consequent membership functions and ⎪ ⎪ 𝑑−𝑥 , if 𝑐 < 𝑥 ≤ 𝑑 ⎪ ⎪ maximas of their corresponding rule activation results. ⎪ ⎪𝑑−𝑐 ⎪ ⎪ Based on this function’s set of values, given defuzzifi- ⎪ if 𝑥 > 𝑑 ⎩ 0, cation method generates single numerical value. It is the outcome of the procedure. There exists a possibility of defining different types of Flow of the fuzzy logic is presented in figure 1. membership functions for each linguistic value within a category (figure 2). It is sometimes a good practice to do such a thing, especially when operating on a few thin triangular functions, as there is a need to cover wide 27 Wojciech Barciński et al. CEUR Workshop Proceedings 26–32 range of extreme values, which we want to guarantee to yield as a result (figure 3). Figure 4: Center of areas Figure 2: Consequent membership functions (triangulars) conjunction and alternative. We tested three different norms. • Manger’s Norm (Extended) – ’a & b’ → 𝑎 * 𝑏 – ’a | b’ → 𝑎 + 𝑏 − 𝑎 * 𝑏 • Zadeh’s Norm – ’a & b’ → 𝑚𝑖𝑛(𝑎, 𝑏) – ’a | b’ → 𝑚𝑎𝑥(𝑎, 𝑏) • Łukasiewicz’s Norm – ’a & b’ → 𝑚𝑎𝑥(0, 𝑎 + 𝑏 − 1) – ’a | b’ → 𝑚𝑖𝑛(1, 𝑎 + 𝑏) Figure 3: Housing antecedent membership functions (trape- zoidal, triangular, trapezoidal) 2.6. Rules One of the stages of inference is usage of rules system. Single rule takes linguistic values of observation’s 2.4. Defuzzification methods attributes, processes them checking multiple conditions There are numberous defuzzification methods, which linked with themselves by mathematical logic and if operate in very different ways. For our research, we were all conditions are fulfilled, certain linguistic value that focusing on FOM (First Of Maxima), MOM (Middle Of determines class is returned. Maxima), LOM (Last Of Maxima) and centroid middle of Our rules system is based on division of attributes on area. The first three return as their result the first, mean two main categories – important and less important of or last occurance of highest activated function values, ones. We assessed that some of observation’s qualities and the centroid one operates in a way described below: are absolutely essential for every citizen (Housing, Cost of living, Safety, Healthcare, Travel connectivity) and some are not (Education, Environmental quality, ∑︀𝑛 𝑥𝑖 𝜇(𝑥 𝑖 ) ∑︀𝑖=1 𝑛 (3) Economy, Taxation, Internet access, Leisure and culture, 𝑖=1 𝜇(𝑥 𝑖 ) Commute). For example healthcare is something that a Visualization of an example output of center of areas lot of people are going to use in a critical situation that defuzzification is presented in figure 4. threathen them with death while education concerns only the younger citizens and culture is something that 2.5. Norms does not decide about survival and is additional bonus, not strategical factor. We created nine rules, where each Norms refer to the different ways of numerically inter- three are built under the same pattern and the only preting logical operations on linguistic values, such as varying element is linguistic value. 28 Wojciech Barciński et al. CEUR Workshop Proceedings 26–32 First rule states that any three among the five essential dataset’s label - GDP per capita - was obtained from ex- qualities, if their linguistic value is identical, determine ternal source. The last dataset’s label was defined by returned linguistic value: authors by themselves and was based solely on their knowledge and intuition. If (𝑥1 𝑖𝑠 𝑎 and 𝑥2 𝑖𝑠 𝑎 and 𝑥3 𝑖𝑠 𝑎) or We checked results which were given by various combi- nations of norms (Zadeh norm, modified Manger norm, (𝑥1 𝑖𝑠 𝑎 and 𝑥2 𝑖𝑠 𝑎 and 𝑥4 𝑖𝑠 𝑎) or ... Łukasiewicz norm) with defuzzification methods (First then 𝑧 𝑖𝑠 𝑎 of maxima, Last of maxima, Middle of maxima, centroid middle of area) applied within fuzzy system and a few where (x1 , x2 , x3 , x4 , x5 ) are five essential qualities, other classifiers (KNN, Naïve Bayes, Softset). By results (y1 , y2 , y3 , y4 , y5 , y6 , y7 ) are seven non-essential we mean four basic rates of model quality: accuracy, pre- qualities, 𝑧 is returned value and 𝑎 is certain linguisitic cision, recall and sensitivity. Except for accuracy, we value. decided to prioritize high scores of precision due to our That rule contains all possible variations of three chosen attempts to achieve as little false positive cases as possi- attributes among the total five. ble. The reason was that we did not want to propose a When four or five qualities have the same linguistic city as a potential proper location to live while it is not. value, according to this logic that fact also determines On all of the plots letter ’Z’ denotes Zadeh norm, let- returned value so it does not need to be handled by ter ’M’ denotes modified Manger norm, letter ’L’ denotes separate rule because it is intercepted by the first rule. Łukasiewicz norm. Second rule states that if two essential qualities have Results (figures 5 and 6) from the first dataset (weighted the same value, any two among the seven non-essential sum) show us a decent outcome from all of the differ- attributes with same value guarantee returned value ent kinds of fuzzy system. They are very repetable and equalled to theirs: depend on used defuzzification methods, regardless of norms. Comparing it to the rest of classifiers, one may If ((𝑥1 𝑖𝑠 𝑎 and 𝑥2 𝑖𝑠 𝑎) or (𝑥2 𝑖𝑠 𝑎 and 𝑥3 𝑖𝑠 𝑎) or ...) notice considerably lower performance of KNN, similar and ((𝑦1 𝑖𝑠 𝑎 and 𝑦2 𝑖𝑠 𝑎) or (𝑦2 𝑖𝑠 𝑎 and 𝑦3 𝑖𝑠 𝑎) or ...) one of Softset and high result of Bayes. then 𝑧 𝑖𝑠 𝑎 That rule contains all variations of two attributes among the five and seven accordingly. Third rule states that if only one essential quality have certain value, we need five non-essential attributes with this value to qualify returned value as identical to theirs: If ((𝑥1 𝑖𝑠 𝑎 and 𝑥2 𝑖𝑠 𝑛𝑜𝑡 𝑎 and 𝑥3 𝑖𝑠 𝑛𝑜𝑡 𝑎 and 𝑥4 𝑖𝑠 𝑛𝑜𝑡 𝑎 and 𝑥5 𝑖𝑠 𝑛𝑜𝑡 𝑎) or ...) and ((𝑦1 𝑖𝑠 𝑎 and 𝑦2 𝑖𝑠 𝑎 and 𝑦3 𝑖𝑠 𝑎 and 𝑦4 𝑖𝑠 𝑎 and 𝑦5 𝑖𝑠 𝑎) or ...) then 𝑧 𝑖𝑠 𝑎 This rule contains all variations of one positive and four Figure 5: Accuracy rates for dataset with weighted sum negative qualities among the five essential ones and five among seven non-essential ones. Second dataset (GDP per capita, figures 7 and 8) gen- erated lower results of fuzzy system than that based on 3. Tests and experiments weighted sum. Again, individual cases are repetitive in similar way. This time KNN achieved better performance To test our fuzzy system properly, we used three datasets, while Softset remains close to fuzzy outcomes. Bayes is to which labels were assigned differently every time. La- still unmatched. All non-fuzzy models reached higher bel of first dataset was created by constructing weighted precision rates. sum of attributes where each quality did not contribute Third dataset (subjective classes, figures 9 and 10) pro- equally. Weight of the most of them was equal to 1, but duced similar outcomes to second one for fuzzy system - some - more important to final decision in our opinion decent accuracy with poor precision. KNN and SoftSet - were equal to 1.5 and one was equal to 0.5. Second have close results to themselves and Bayes as always 29 Wojciech Barciński et al. CEUR Workshop Proceedings 26–32 Figure 6: Precision rates for dataset with weighted sum Figure 8: Precision rates for dataset with GDP turned out to be the best model. Figure 9: Accuracy rates for dataset with subjective classes Figure 7: Accuracy rates for dataset with GDP 4. Conclusion Fuzzy system achieved good results, especially using First of maxima and Middle of maxima defuzzification methods. Different norms were not a considerable factor, defuzzification pretty much defined the result by itself. The rest of the models reached mostly decent outcomes, sometimes even outperforming fuzzy system. Particu- larly Bayesian classifier turned out to have the highest score in nearly every case (considering accuracy and pre- cision collectively). However, fuzzy system would likely achieve higher results in case of designing more accu- Figure 10: Precision rates for dataset with subjective classes rate and factful system of rules by real expert or more adequate division into classes. Although fuzzy system did not bring the best results enough and consistent enough ratings to be used in any from the bunch, we would argue that it provided good 30 Wojciech Barciński et al. CEUR Workshop Proceedings 26–32 software, that would be able to capitalize on its strengths, by means of end-to-end visual target navigation such as flexibility of rulesets, enabling different user cri- and reinforcement learning approaches, in: CEUR teria, and no reliance on other data samples. Workshop Proceedings, volume 3118, CEUR-WS, 2021, pp. 51–63. [11] H. G. Hong, M. B. Lee, K. R. Park, Convolutional References neural network-based finger-vein recognition using nir image sensors, Sensors 17 (2017) 1297. [1] M. A. Sanchez, O. Castillo, J. R. Castro, Generalized [12] A. T. Özdemir, B. Barshan, Detecting falls with type-2 fuzzy systems for controlling a mobile robot wearable sensors using machine learning tech- and a performance comparison with interval type- niques, Sensors 14 (2014) 10691–10708. 2 and type-1 fuzzy systems, Expert Systems with [13] K. G. Liakos, P. Busato, D. Moshou, S. Pearson, Applications 42 (2015) 5904–5914. D. Bochtis, Machine learning in agriculture: A [2] Q.-b. Zhang, P. Wang, Z.-h. Chen, An improved review, Sensors 18 (2018) 2674. particle filter for mobile robot localization based on [14] Y. Li, W. Dong, Q. Yang, S. Jiang, X. Ni, J. Liu, Auto- particle swarm optimization, Expert Systems with matic impedance matching method with adaptive Applications 135 (2019) 181–193. network based fuzzy inference system for wpt, IEEE [3] V. S. Dhaka, S. V. Meena, G. Rani, D. Sinwar, M. F. Transactions on Industrial Informatics 16 (2019) Ijaz, M. Woźniak, A survey of deep convolutional 1076–1085. neural networks applied for prediction of plant leaf [15] F. Qu, J. Liu, H. Zhu, D. Zang, Wind turbine condi- diseases, Sensors 21 (2021) 4749. tion monitoring based on assembled multidimen- [4] F. Bonanno, G. Capizzi, G. Lo Sciuto, C. Napoli, sional membership functions using fuzzy inference G. Pappalardo, E. Tramontana, A cascade neural system, IEEE Transactions on Industrial Informat- network architecture investigating surface plasmon ics 16 (2019) 4028–4037. polaritons propagation for thin metals in openmp, [16] A. Carpenzano, R. Caponetto, L. Lo Bello, Lecture Notes in Computer Science (including sub- O. Mirabella, Fuzzy traffic smoothing: An ap- series Lecture Notes in Artificial Intelligence and proach for real-time communication over ethernet Lecture Notes in Bioinformatics) 8467 LNAI (2014) networks, in: 4th IEEE International Workshop on 22 – 33. Factory Communication Systems, IEEE, 2002, pp. [5] G. Capizzi, C. Napoli, L. Paternò, An innovative 241–248. hybrid neuro-wavelet method for reconstruction of [17] M. Woźniak, A. Zielonka, A. Sikora, Driving sup- missing data in astronomical photometric surveys, port by type-2 fuzzy logic control model, Expert Lecture Notes in Computer Science (including sub- Systems with Applications 207 (2022) 117798. series Lecture Notes in Artificial Intelligence and [18] M. Woźniak, D. Połap, C. Napoli, E. Tramontana, Lecture Notes in Bioinformatics) 7267 LNAI (2012) Graphic object feature extraction system based on 21 – 29. cuckoo search algorithm, Expert Systems with Ap- [6] F. Bonanno, G. Capizzi, G. Lo Sciuto, A neuro plications 66 (2016) 20–31. doi:10.1016/j.eswa. wavelet-based approach for short-term load fore- 2016.08.068. casting in integrated generation systems, in: 4th [19] D. Połap, M. Woźniak, C. Napoli, E. Tramontana, International Conference on Clean Electrical Power: R. Damaševičius, Is the colony of ants able to rec- Renewable Energy Resources Impact, ICCEP 2013, ognize graphic objects?, Communications in Com- 2013, p. 772 – 776. puter and Information Science 538 (2015) 376–387. [7] N. Brandizzi, V. Bianco, G. Castro, S. Russo, A. Wa- doi:10.1007/978-3-319-24770-0_33. jda, Automatic rgb inference based on facial emo- [20] M. Woźniak, D. Połap, M. Gabryel, R. Nowicki, tion recognition, volume 3092, CEUR-WS, 2021, pp. C. Napoli, E. Tramontana, Can we process 2d 66–74. images using artificial bee colony?, in: Lecture [8] M. Woźniak, M. Wieczorek, J. Siłka, D. Połap, Body Notes in Artificial Intelligence (Subseries of Lec- pose prediction based on motion sensor data and ture Notes in Computer Science), volume 9119, recurrent neural network, IEEE Transactions on Springer Verlag, 2015, pp. 660–671. doi:10.1007/ Industrial Informatics 17 (2020) 2101–2111. 978-3-319-19324-3_59. [9] O. Dehzangi, M. Taherisadr, R. ChangalVala, Imu- [21] M. Woźniak, A. Zielonka, A. Sikora, M. J. Piran, based gait recognition using convolutional neural A. Alamri, 6g-enabled iot home environment con- networks and multi-sensor fusion, Sensors 17 (2017) trol using fuzzy rules, IEEE Internet of Things 2735. Journal 8 (2020) 5442–5452. [10] N. Dat, V. Ponzi, S. Russo, F. Vincelli, Supporting [22] S. Russo, S. Illari, R. Avanzato, C. Napoli, Reduc- impaired people with a following robotic assistant ing the psychological burden of isolated oncological 31 Wojciech Barciński et al. CEUR Workshop Proceedings 26–32 patients by means of decision trees, in: CEUR Work- shop Proceedings, volume 2768, CEUR-WS, 2020, pp. 46–53. [23] M. Woźniak, D. Połap, R. Nowicki, C. Napoli, G. Pap- palardo, E. Tramontana, Novel approach toward medical signals classifier, volume 2015-September, Institute of Electrical and Electronics Engineers Inc., 2015. doi:10.1109/IJCNN.2015.7280556. [24] R. Avanzato, F. Beritelli, M. Russo, S. Russo, M. Vac- caro, Yolov3-based mask and face recognition al- gorithm for individual protection applications, in: CEUR Workshop Proceedings, volume 2768, CEUR- WS, 2020, pp. 41–45. [25] G. Iannizzotto, L. Lo Bello, A. Nucita, G. M. Grasso, A vision and speech enabled, customizable, virtual assistant for smart environments, in: 2018 11th International Conference on Human System Inter- action (HSI), IEEE, 2018, pp. 50–56. 32