Uploaded by Hafiz Muhammad Saad Bin Ehtisham

AI Lab 09 Fuzzy Logic

advertisement
CS-322 Artificial Intelligence
Lab # 09 (Fuzzy Logic)
LAB # 09
Fuzzy Logic
Objective:
 Understand the concepts for solving problems using the fuzzy logic
 Implement the Fuzzy logic using Python
Theory:
Concepts:
Fuzzy logic is a form of multi-valued logic that deals with reasoning that is approximate rather than
fixed and exact. Fuzzy logic values range between 1 and 0. i.e the value may range from completely
true to completely false. In contrast, Boolean Logic is a two-valued logic: true or false usually denoted
1 and 0 respectively that deals with reasoning that is fixed and exact. Fuzzy logic tends to reflect how
people think and attempts to model our decision making hence it is now leading to new intelligent
systems (expert systems).
So, if we are comparing two strings using fuzzy logic, we would be trying to answer the question “How
similar are string A and string B?”, and rephrasing it as “Are string A and String B the same?” when
using the Boolean Logic.• States: Any arrangement of 0 to 8 queens on the board is a state
Need of Fuzzy Logic
 It controls machines and consumer products
 If not accurate reasoning. It at least provides acceptable reasoning
 This helps in dealing with uncertainty in engineering
Membership Function
 A fuzzy set is that allows it members to have different degree of membership, called
membership function, having interval [0,1].
 A membership function is denoted by µ symbol and a fuzzy set is denoted by à µA:X  [0,1]
 E.g. X = {s1,s2,s3,s4} be set of students à be fuzzy set of smart students, where smart is fuzzy
term
 Ã = {(s3,0.1),(s1,0.4), (s2, 0.8),(s4,1.0)}
Page 1 of 3
CS-322 Artificial Intelligence
Lab # 09 (Fuzzy Logic)
Architecture of Fuzzy Logic
Advantages








The structure of fuzzy logic systems is easy and understandable
It is widely used for commercial and practical purposes
It helps you to control machines and consumer products
It helps you to deal with the uncertainty in engineering
Mostly robust as no precise inputs required
If feedback sensor stops working, you can program it into the situation
You can easily modify it to improve or alter system performance
Inexpensive sensors can be used which helps you to keep the overall system cost and
complexity low
Page 2 of 3
CS-322 Artificial Intelligence
Lab # 09 (Fuzzy Logic)
Pitfall
 It is not always accurate
 It cannot recognize machine learning and neural network type patterns
 Validation and verification of a fuzzy knowledge-based system needs extensive testing with
hardware
 Setting exact fuzzy rules and membership functions is a difficult task
 Sometimes fuzzy logic is confused with probability theory
Fuzzy String Matching
Fuzzy String Matching, also known as Approximate String Matching, is the process of finding
strings that approximately match a pattern. The process has various applications such as spellchecking, DNA analysis and detection, spam detection, plagiarism detection e.t.c
Introduction to Fuzzywuzzy
Fuzzywuzzy is a python library that uses Levenshtein distance to calculate the differences between
sequences and patterns that were developed and also open-sourced by SeatGeek, a service that finds
event tickets from all over the internet and showcase them on one platform. The big problem they
were facing was the labeling of the same events. This is the same as the example where an entity such
as a person’s name can be labeled differently on different sources.
Lab Task:
1. Import the following libraries and ignore the warnings
a fuzz
b process
2. Write a code for the string to match from the list of strings that contains the following
Str2match = “apple inc”
strList = ["Apple Inc.", "apple park", "apple incorporated",
"iphone"]
3. Output the fuzzy value of each string object in the list.
Page 3 of 3
Download