AI Unit 3
AI Unit 3
AI Unit 3
The term fuzzy refers to things that are not clear or are vague. In the real world many times we
encounter a situation when we can’t determine whether the state is true or false, their fuzzy logic
provides very valuable flexibility for reasoning. In this way, we can consider the inaccuracies and
uncertainties of any situation.
Fuzzy Logic is a form of many-valued logic in which the truth values of variables may be any real
number between 0 and 1, instead of just the traditional values of true or false. It is used to deal with
imprecise or uncertain information and is a mathematical method for representing vagueness and
uncertainty in decision-making.
Fuzzy Logic is based on the idea that in many cases, the concept of true or false is too restrictive, and
that there are many shades of gray in between. It allows for partial truths, where a statement can be
partially true or false, rather than fully true or false.
Fuzzy Logic is used in a wide range of applications, such as control systems, image processing, natural
language processing, medical diagnosis, and artificial intelligence.
The fundamental concept of Fuzzy Logic is the membership function, which defines the degree of
membership of an input value to a certain set or category. The membership function is a mapping from
an input value to a membership degree between 0 and 1, where 0 represents non-membership and 1
represents full membership.
Fuzzy Logic is implemented using Fuzzy Rules, which are if-then statements that express the
relationship between input variables and output variables in a fuzzy way. The output of a Fuzzy Logic
system is a fuzzy set, which is a set of membership degrees for each possible output value.
In summary, Fuzzy Logic is a mathematical method for representing vagueness and uncertainty in
decision-making, it allows for partial truths, and it is used in a wide range of applications. It is based on
the concept of membership function and the implementation is done using Fuzzy rules.
In the boolean system truth value, 1.0 represents the absolute truth value and 0.0 represents the
absolute false value. But in the fuzzy system, there is no logic for the absolute truth and absolute false
value. But in fuzzy logic, there is an intermediate value too present which is partially true and partially
false.
ARCHITECTURE
Its Architecture contains four parts :
• RULE BASE: It contains the set of rules and the IF-THEN conditions provided by the experts to
govern the decision-making system, on the basis of linguistic information. Recent developments in
fuzzy theory offer several effective methods for the design and tuning of fuzzy controllers. Most of
these developments reduce the number of fuzzy rules.
• FUZZIFICATION: It is used to convert inputs i.e. crisp numbers into fuzzy sets. Crisp inputs are
basically the exact inputs measured by sensors and passed into the control system for processing,
such as temperature, pressure, rpm’s, etc.
• INFERENCE ENGINE: It determines the matching degree of the current fuzzy input with
respect to each rule and decides which rules are to be fired according to the input field. Next, the
fired rules are combined to form the control actions.
• DEFUZZIFICATION: It is used to convert the fuzzy sets obtained by the inference engine into a
crisp value. There are several defuzzification methods available and the best-suited one is used
with a specific expert system to reduce the error.
Membership function
Definition: A graph that defines how each point in the input space is mapped to membership value
between 0 and 1. Input space is often referred to as the universe of discourse or universal set (u),
which contains all the possible elements of concern in each particular application.
There are largely three types of fuzzifiers:
1) Singleton fuzzifier
2) Gaussian fuzzifier
3) Trapezoidal or triangular fuzzifier
What is Fuzzy Control?
1) It is a technique to embody human-like thinkings into a control system.
2) It may not be designed to give accurate reasoning but it is designed to give acceptable
reasoning.
3) It can emulate human deductive thinking, that is, the process people use to infer conclusions
from what they know.
4) Any uncertainties can be easily dealt with the help of fuzzy logic.
Advantages of Fuzzy Logic System
1) This system can work with any type of inputs whether it is imprecise, distorted or noisy input
information.
2) The construction of Fuzzy Logic Systems is easy and understandable.
3) Fuzzy logic comes with mathematical concepts of set theory and the reasoning of that is quite
simple.
4) It provides a very efficient solution to complex problems in all fields of life as it resembles
human reasoning and decision-making.
5) The algorithms can be described with little data, so little memory is required.
Disadvantages of Fuzzy Logic Systems
1) Many researchers proposed different ways to solve a given problem through fuzzy logic which
leads to ambiguity. There is no systematic approach to solve a given problem through fuzzy
logic.
2) Proof of its characteristics is difficult or impossible in most cases because every time we do not
get a mathematical description of our approach.
3) As fuzzy logic works on precise as well as imprecise data so most of the time accuracy is
compromised.
Application
1) It is used in the aerospace field for altitude control of spacecraft and satellites.
2) It has been used in the automotive system for speed control, traffic control.
3) It is used for decision-making support systems and personal evaluation in the large company
business.
4) It has application in the chemical industry for controlling the pH, drying, chemical distillation
process.
5) Fuzzy logic is used in Natural language processing and various intensive applications in Artificial
Intelligence.
6) Fuzzy logic is extensively used in modern control systems such as expert systems.
7) Fuzzy Logic is used with Neural Networks as it mimics how a person would make decisions, only
much faster. It is done by Aggregation of data and changing it into more meaningful data by
forming partial truths as Fuzzy sets.
Fuzzy operations
Fuzzy operations are performed on fuzzy sets, whereas crisp operations are performed on
crisp sets. Fuzzy operations are very useful in the design of a Fuzzy Logic Controller. It
allows the manipulation of fuzzy variables by different means.
Union:
In the case of the union of crisp sets, we simply have to select repeated elements only
once. In the case of fuzzy sets, when there are common elements in both fuzzy sets, we
should select the element with the maximum membership value.
C = A ∪ B = {(x, μA ∪ B (x)) | ∀x ∈ X}
Graphically, we can represent union operations as follows: Red and Blue membership
functions represent the fuzzy value for elements in sets A and B, respectively. Wherever
these fuzzy functions overlap, we have to consider the point with the maximum
membership value.
Fuzzy union
Example of Fuzzy Union:
C = A ∪ B = {(x, μA ∪ B (x)) | ∀x ∈ X}
A = { (x1, 0.2), (x2, 0.5), (x3, 0.6), (x4, 0.8), (x5, 1.0) }
B = { (x1, 0.8), (x2, 0.6), (x3, 0.4), (x4, 0.2), (x5, 0.1) }
So, A ∪ B = { (x1, 0.8), (x2, 0.6), (x3, 0.6), (x4, 0.8), (x5, 1.0) }
Intersection:
In the case of the intersection of crisp sets, we simply have to select common elements
from both sets. In the case of fuzzy sets, when there are common elements in both fuzzy
sets, we should select the element with minimum membership value.
C = A ∩ B = {(x, μA ∩ B (x)) | ∀x ∈ X}
Graphically, we can represent the intersection operation as follows: Red and blue
membership functions represent the fuzzy value for elements in sets A and B,
respectively. Wherever these fuzzy functions overlap, we have to consider the point with
the minimum membership value.
Fuzzy intersection
Example of Fuzzy Intersection:
C = A ∩ B = {(x, μA ∩ B (x)) | ∀x ∈ X}
A = { (x1, 0.2), (x2, 0.5), (x3, 0.6), (x4, 0.8), (x5, 1.0) }
B = { (x1, 0.8), (x2, 0.6), (x3, 0.4), (x4, 0.2), (x5, 0.1) }
So, A ∩ B = { (x1, 0.2), (x2, 0.5), (x3, 0.4), (x4, 0.2), (x5, 0.1) }
Complement:
Fuzzy complement is identical to crisp complement operation. The membership value of
every element in the fuzzy set is complemented with respect to 1, i.e. it is subtracted from
1.
AC (x) = 1 – μA(x)
Fuzzy complement
Example of Fuzzy Complement:
AC (x) = 1 – μA(x)
A = { (x1, 0.2), (x2, 0.5), (x3, 0.6), (x4, 0.8), (x5, 1.0) }
AC = { (x1, 0.8), (x2, 0.5), (x3, 0.4), (x4, 0.2), (x5, 0.0) }
A ⋃ AC = { (x1, 0.8), (x2, 0.5), (x3, 0.6), (x4, 0.8), (x5, 1.0) } ≠ X
A ∩ AC = { (x1, 0.2), (x2, 0.5), (x3, 0.4), (x4, 0.2), (x5, 0.0) } ≠ Φ
Unlike crisp sets, fuzzy sets do not hold the law of contradiction and the law of excluded
middle.
A = { (x1, 0.4), (x2, 0.5), (x3, 0.2), (x4, 0.4), (x5, 0.8) }
B = { (x1, 1.0), (x2, 0.3), (x3, 0.5), (x4, 0.7), (x5, 0.1) }
Probabilistic reasoning in Artificial intelligence
Uncertainty:
Till now, we have learned knowledge representation using first-order logic and
propositional logic with certainty, which means we were sure about the predicates.
With this knowledge representation, we might write A→B, which means if A is true then
B is true, but consider a situation where we are not sure about whether A is true or not
then we cannot express this statement, this situation is called uncertainty.
So to represent uncertain knowledge, where we are not sure about the predicates, we
need uncertain reasoning or probabilistic reasoning.
Causes of uncertainty:
Following are some leading causes of uncertainty to occur in the real world.
In the real world, there are lots of scenarios, where the certainty of something is not
confirmed, such as "It will rain today," "behavior of someone for some situations," "A
match between two teams or two players." These are probable sentences for which we
can assume that it will happen but not sure about it, so here we use probabilistic
reasoning.
Probability: Probability can be defined as a chance that an uncertain event will occur. It
is the numerical measure of the likelihood that an event will occur. The value of
probability always remains between 0 and 1 that represent ideal uncertainties.
Sample space: The collection of all possible events is called sample space.
Random variables: Random variables are used to represent the events and objects in the
real world.
Posterior Probability: The probability that is calculated after all evidence or information
has taken into account. It is a combination of prior probability and new information.
Conditional probability:
Conditional probability is a probability of occurring an event when another event has
already happened.
Let's suppose, we want to calculate the event A when event B has already occurred,
"the probability of A under the conditions of B", it can be written as:
If the probability of A is given and we need to find the probability of B, then it will be
given as:
In a class, there are 70% of the students who like English and 40% of the students who
likes English and mathematics, and then what is the percent of students those who like
English also like mathematics?
Solution:
Bayes' theorem was named after the British mathematician Thomas Bayes. The
Bayesian inference is an application of Bayes' theorem, which is fundamental to
Bayesian statistics.
It is a way to calculate the value of P(B|A) with the knowledge of P(A|B).
Bayes' theorem was named after the British mathematician Thomas Bayes. The
Bayesian inference is an application of Bayes' theorem, which is fundamental to
Bayesian statistics.
Example: If cancer corresponds to one's age then by using Bayes' theorem, we can
determine the probability of cancer more accurately with the help of age.
Bayes' theorem can be derived using product rule and conditional probability of event A
with known event B:
It shows the simple relationship between joint and conditional probabilities. Here,
P(A|B) is known as posterior, which we need to calculate, and it will be read as
Probability of hypothesis A when we have occurred an evidence B.
P(B|A) is called the likelihood, in which we consider that hypothesis is true, then we
calculate the probability of evidence.
P(A) is called the prior probability, probability of hypothesis before considering the
evidence
In the equation (a), in general, we can write P (B) = P(A)*P(B|Ai), hence the Bayes' rule
can be written as:
Question: what is the probability that a patient has diseases meningitis with a stiff neck?
Given Data:
A doctor is aware that disease meningitis causes a patient to have a stiff neck, and it
occurs 80% of the time. He is also aware of some more facts, which are given as follows:
P(a|b) = 0.8
P(b) = 1/30000
P(a)= .02
Example-2:
Question: From a standard deck of playing cards, a single card is drawn. The probability
that the card is king is 4/52, then calculate posterior probability P(King|Face), which
means the drawn face card is a king card.
Solution:
It is used to calculate the next step of the robot when the already executed step is given.
Bayes' theorem is helpful in weather forecasting.
Hidden Markov models
A stochastic process is a collection of random variables that are indexed by some mathematical
sets. That is, each random variable of the stochastic process is uniquely associated with an
element in the set. The set that is used to index the random variables is called the index set and
the set of random variables forms the state space. A stochastic process can be classified in many
ways based on state space, index set, etc.
When the stochastic process is interpreted as time, if the process has a finite number of elements
such as integers, numbers, and natural numbers then it is Discrete Time.
Stochastic Model
It is a discrete-time process indexed at time 1,2,3,…that takes values called states which are
observed.
Weather for 4 days can be a sequence => {z1=hot, z2 =cold, z3 =cold, z4 =hot}
Markov and Hidden Markov models are engineered to handle data which can be represented as
‘sequence’ of observations over time. Hidden Markov models are probabilistic frameworks
where the observed data are modeled as a series of outputs generated by one of several (hidden)
internal states.
Markov Assumptions
Markov models are developed based on mainly two assumptions.
Limited Horizon assumption: Probability of being in a state at a time t depend only on the state at
the time (t-1).
2. Stationary Process Assumption: Conditional (probability) distribution over the next state,
given the current state, doesn't change over time.