AI_Unit-4_Notes
AI_Unit-4_Notes
• Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.
• Events: Events are the actions which occur in our world.
• Performance: It describe behavior which involves knowledge about how to do things.
• Meta-knowledge: It is knowledge about what we know.
• Facts: Facts are the truths about the real world and what we represent.
• Knowledge-Base: The central component of the knowledge-based agents is the
knowledge base. It is represented as KB. The Knowledgebase is a group of the Sentences
(Here, sentences are used as a technical term and not identical with the English
language).
Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and
situations. Following are the types of knowledge in artificial intelligence:
Types of knowledge
1. Declarative Knowledge:
3. Meta-knowledge:
Knowledge about the other types of knowledge is called Meta-knowledge.
4. Heuristic knowledge:
AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent
behaviour:
• Perception
• Learning
• Knowledge Representation and Reasoning
• Planning
• Execution
The above diagram is showing how an AI system can interact with the real world and what
components help it to show intelligence. AI system has Perception component by which it
retrieves information from its environment. It can be visual, audio or another form of sensory
input. The learning component is responsible for learning from data captured by Perception
comportment. In the complete cycle, the main components are knowledge representation and
Reasoning. These two components are involved in showing the intelligence in machine-like
humans. These two components are independent with each other but also coupled together. The
planning and execution depend on analysis of Knowledge representation and reasoning.
Approaches to knowledge representation:
There are mainly four approaches to knowledge representation, which are given below:
• It is the simplest way of storing facts which uses the relational method, and each fact
about a set of the object is set out systematically in columns.
• This approach of knowledge representation is famous in database systems where the
relationship between different entities is represented.
• This approach has little opportunity for inference.
2. Inheritable knowledge:
• In the inheritable knowledge approach, all data must be stored into a hierarchy of
classes.
• All classes should be arranged in a generalized form or a hierarchal manner.
• In this approach, we apply inheritance property.
• Elements inherit values from other members of a class.
• This approach contains inheritable knowledge which shows a relation between instance
and class, and it is called instance relation.
• Every individual frame can represent the collection of attributes and its value.
• In this approach, objects and values are represented in Boxed nodes.
• We use Arrows which point from objects to their values.
Example:
3. Inferential knowledge:
man(Marcus)
∀x = man (x) --------- > mortal (x)s
4. Procedural knowledge:
• Procedural knowledge approach uses small programs and codes which describes how to
do specific things, and how to proceed.
• In this approach, one important rule is used which is If-Then rule.
• In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
• We can easily represent heuristic or domain-specific knowledge using this approach.
• But it is not necessary that we can represent all cases in this approach.
Requirements for knowledge Representation system:
A good knowledge representation system must possess the following properties.
1. Representational Accuracy:
KR system should have the ability to represent all kind of required knowledge.
2. Inferential Adequacy:
KR system should have ability to manipulate the representational structures to produce new
knowledge corresponding to existing structure.
3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most productive directions
by storing appropriate guides.
4. Acquisitional efficiency- The ability to acquire the new knowledge easily using automatic
methods.
Techniques of knowledge representation
There are mainly four ways of knowledge representation which are given as follows:
• Logical Representation
• Semantic Network Representation
• Frame Representation
• Production Rules
1. Logical
Representation
Logical representation is a language with some concrete rules which deals with propositions and
has no ambiguity in representation. Logical representation means drawing a conclusion based
on various conditions. This representation lays down some important communication rules. It
consists of precisely defined syntax and semantics which supports the sound inference. Each
sentence can be translated into logics using syntax and semantics.
Syntax:
• Syntaxes are the rules which decide how we can construct legal sentences in the logic.
• It determines which symbol we can use in knowledge representation.
• How to write those symbols.
Semantics:
• Semantics are the rules by which we can interpret the sentence in the logic.
• Semantic also involves assigning a meaning to each sentence.
• Propositional Logics
• Predicate logics
• Semantic networks take more computational time at runtime as we need to traverse the
complete network tree to answer some questions. It might be possible in the worst case
scenario that after traversing the entire tree, we find that the solution does not exist in
this network.
• Semantic networks try to model human-like memory (Which has 1015 neurons and
links) to store the information, but in practice, it is not possible to build such a vast
semantic network.
• These types of representations are inadequate as they do not have any equivalent
quantifier, e.g., for all, for some, none, etc.
• Semantic networks do not have any standard definition for the link names.
• These networks are not intelligent and depend on the creator of the system.
• A frame is a record like structure which consists of a collection of attributes and its values
to describe an entity in the world. Frames are the AI data structure which divides
knowledge into substructures by representing stereotypes situations. It consists of a
collection of slots and slot values. These slots may be of any type and sizes. Slots have
names and values which are called facets.
• Facets: The various aspects of a slot is known as Facets. Facets are features of frames
which enable us to put constraints on the frames. Example: IF-NEEDED facts are called
when data of any particular slot is needed. A frame may consist of any number of slots,
and a slot may include any number of facets and facets may have any number of values.
A frame is also known as slot-filter knowledge representation in artificial intelligence.
• Frames are derived from semantic networks and later evolved into our modern-day
classes and objects. A single frame is not much useful. Frames system consist of a
collection of frames which are connected. In the frame, knowledge about an object or
event can be stored together in the knowledge base. The frame is a type of technology
which is widely used in various applications including Natural language processing and
machine visions.
• The frame knowledge representation makes the programming easier by grouping the
related data.
• The frame representation is comparably flexible and used by many applications in AI.
• It is very easy to add slots for new attribute and relations.
• It is easy to include default data and to search for missing values.
• Frame representation is easy to understand and visualize.
Disadvantages of frame representation:
• Production rules system consist of (condition, action) pairs which mean, "If condition
then action". It has mainly three parts:
• The set of production rules
• Working Memory
• The recognize-act-cycle
• In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part of the
rule determines which rule may be applied to a problem. And the action part carries out
the associated problem-solving steps. This complete process is called a recognize-act
cycle.
• The working memory contains the description of the current state of problems-solving
and rule can write knowledge to the working memory. This knowledge match and may
fire other rules.
• If there is a new situation (state) generates, then multiple production rules will be fired
together, this is called conflict set. In this situation, the agent needs to select a rule from
these sets, and it is called a conflict resolution.
Example:
IF (at bus stop AND bus arrives) THEN action (get into the bus)
IF (on the bus AND paid AND empty seat) THEN action (sit down).
IF (on bus AND unpaid) THEN action (pay charges).
IF (bus arrives at destination) THEN action (get down from the bus).
Advantages of Production rule:
The production rules are expressed in natural language.
The production rules are highly modular, so we can easily remove, add or modify an individual
rule.
Disadvantages of Production rule:
• Production rule system does not exhibit any learning capabilities, as it does not store the
result of the problem for the future uses.
• During the execution of the program, many rules may be active hence rule-based
production systems are inefficient.
Drawbacks in Semantic representation:
• Semantic networks take more computational time at runtime as we need to traverse the
complete network tree to answer some questions. It might be possible in the worst case
scenario that after traversing the entire tree, we find that the solution does not exist in
this network.
• Semantic networks try to model human-like memory (Which has 1015 neurons and
links) to store the information, but in practice, it is not possible to build such a vast
semantic network.
• These types of representations are inadequate as they do not have any equivalent
quantifier, e.g., for all, for some, none, etc.
• Semantic networks do not have any standard definition for the link names.
• These networks are not intelligent and depend on the creator of the system.
• Advantages of Semantic network:
• Semantic networks are a natural representation of knowledge.
• Semantic networks convey meaning in a transparent manner.
• These networks are simple and easily understandable.
3. Frame Representation
• A frame is a record like structure which consists of a collection of attributes and its values
to describe an entity in the world. Frames are the AI data structure which divides
knowledge into substructures by representing stereotypes situations. It consists of a
collection of slots and slot values. These slots may be of any type and sizes. Slots have
names and values which are called facets.
• Facets: The various aspects of a slot is known as Facets. Facets are features of frames
which enable us to put constraints on the frames. Example: IF-NEEDED facts are called
when data of any particular slot is needed. A frame may consist of any number of slots,
and a slot may include any number of facets and facets may have any number of values.
A frame is also known as slot-filter knowledge representation in artificial intelligence.
• Frames are derived from semantic networks and later evolved into our modern-day
classes and objects. A single frame is not much useful. Frames system consist of a
collection of frames which are connected. In the frame, knowledge about an object or
event can be stored together in the knowledge base. The frame is a type of technology
which is widely used in various applications including Natural language processing and
machine visions.
Advantages of frame representation:
• The frame knowledge representation makes the programming easier by grouping the
related data.
• The frame representation is comparably flexible and used by many applications in AI.
• It is very easy to add slots for new attribute and relations.
• It is easy to include default data and to search for missing values.
• Frame representation is easy to understand and visualize.
Disadvantages of frame representation:
• In frame system inference mechanism is not be easily processed.
• Inference mechanism cannot be smoothly proceeded by frame representation.
• Frame representation has a much generalized approach.
4. Production Rules
• Production rules system consist of (condition, action) pairs which mean, "If condition
then action". It has mainly three parts:
• The set of production rules
• Working Memory
• The recognize-act-cycle
• In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part of the
rule determines which rule may be applied to a problem. And the action part carries out
the associated problem-solving steps. This complete process is called a recognize-act
cycle.
• The working memory contains the description of the current state of problems-solving
and rule can write knowledge to the working memory. This knowledge match and may
fire other rules.
• If there is a new situation (state) generates, then multiple production rules will be fired
together, this is called conflict set. In this situation, the agent needs to select a rule from
these sets, and it is called a conflict resolution.
Example:
IF (at bus stop AND bus arrives) THEN action (get into the bus)
IF (on the bus AND paid AND empty seat) THEN action (sit down).
IF (on bus AND unpaid) THEN action (pay charges).
IF (bus arrives at destination) THEN action (get down from the bus).
• Production rule system does not exhibit any learning capabilities, as it does not store the
result of the problem for the future uses.
• During the execution of the program, many rules may be active hence rule-based
production systems are inefficient.
Example:
a) It is Sunday.
b) The Sun rises from West (False proposition)
c) 3+3= 7(False proposition)
d) 5 is a prime number.
The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
• Atomic Propositions
• Compound propositions
• Atomic Proposition: Atomic propositions are the simple propositions. It consists of a
single proposition symbol. These are the sentences which must be either true or false.
Example:
a) 2+2 is 4, it is an atomic proposition as it is a true fact.
b) "The Sun is cold" is also a proposition as it is a false fact.
Compound proposition: Compound propositions are constructed by combining simpler or
atomic propositions, using parenthesis and logical connectives.
Example:
a) "It is raining today, and street is wet."
b) "Ankit is a doctor, and his clinic is in Mumbai."
Example:
a) "It is raining today, and street is wet."
b) "Ankit is a doctor, and his clinic is in Mumbai."
Properties of Operators:
• Commutativity:
• P𝖠 Q= Q 𝖠 P, or
• P ∨ Q = Q ∨ P.
• Associativity:
• (P 𝖠 Q) 𝖠 R= P 𝖠 (Q 𝖠 R),
• (P ∨ Q) ∨ R= P ∨ (Q ∨ R)
• Identity element:
• P 𝖠 True = P,
• P ∨ True= True.
• Distributive:
• P𝖠 (Q ∨ R) = (P 𝖠 Q) ∨ (P 𝖠 R).
• P ∨ (Q 𝖠 R) = (P ∨ Q) 𝖠 (P ∨ R).
• DE Morgan's Law:
• ¬ (P 𝖠 Q) = (¬P) ∨ (¬Q)
• ¬ (P ∨ Q) = (¬ P) 𝖠 (¬Q).
• Double-negation elimination:
• ¬ (¬P) = P.
• We cannot represent relations like ALL, some, or none with propositional logic.
Example:
• All the girls are intelligent.
• Some apples are sweet.
• Propositional logic has limited expressive power.
• In propositional logic, we cannot describe statements in terms of their properties or
logical relationships.
Wumpus world:
• The Wumpus world is a simple world example to illustrate the worth of a knowledge-
based agent and to represent knowledge representation. It was inspired by a video
game Hunt the Wumpus by Gregory Yob in 1973.
• The Wumpus world is a cave which has 4/4 rooms connected with passageways. So there
are total 16 rooms which are connected with each other. We have a knowledge- based
agent who will go forward in this world. The cave has a room with a beast which is called
Wumpus, who eats anyone who enters the room. The Wumpus can be shot by the agent,
but the agent has a single arrow. In the Wumpus world, there are some Pits rooms which
are bottomless, and if agent falls in Pits, then he will be stuck there forever. The exciting
thing with this cave is that in one room there is a possibility of finding a heap of gold. So
the agent goal is to find the gold and climb out the cave without fallen into Pits or eaten
by Wumpus. The agent will get a reward if he comes out with gold, and he will get a penalty
if eaten by Wumpus or falls in the pit.
• Following is a sample diagram for representing the Wumpus world. It is showing some
rooms with Pits, one room with Wumpus and one agent at (1, 1) square location of the
world.
There are also some components which can help the agent to navigate the cave. These
components are given as follows:
• The rooms adjacent to the Wumpus room are smelly, so that it would have some stench.
• The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he will
perceive the breeze.
• There will be glitter in the room if and only if the room has gold.
• The Wumpus can be killed by the agent if the agent is facing to it, and Wumpus will emit
a horrible scream which can be heard anywhere in the cave.
• Performance measure:
+1000 reward points if the agent comes out of the cave with the gold.
-1000 points penalty for being eaten by the Wumpus or falling into the pit.
-1 for each action, and -10 for using an arrow.
The game ends if either agent dies or came out of the cave.
• Environment:
A 4*4 grid of rooms.
The agent initially in room square [1, 1], facing toward the right.
Location of Wumpus and gold are chosen randomly except the first square [1,1].Each
square of the cave can be a pit with probability 0.2 except the first square.
• Actuators:
Left turn,
Right turn
Move forward
Grab
Release
Shoot.
• Sensors:
The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not diagonally).
The agent will perceive breeze if he is in the room directly adjacent to the Pit.
The agent will perceive the glitter in the room where the gold is present.
The agent will perceive the bump if he walks into a wall.
When the Wumpus is shot, it emits a horrible scream which can be perceived anywhere in the
cave.
These percepts can be represented as five element list, in which we will have differentindicators
for each sensor.
Example if agent perceives stench, breeze, but no glitter, no bump, and no scream then it can be
represented as:
[Stench, Breeze, None, None, None].
• Partially observable: The Wumpus world is partially observable because the agent can
only perceive the close environment such as an adjacent room.
• Deterministic: It is deterministic, as the result and outcome of the world are already
known.
• Sequential: The order is important, so it is sequential.
• Static: It is static as Wumpus and Pits are not moving.
• Discrete: The environment is discrete.
• One agent: The environment is a single agent as we have one agent only and Wumpus is
not considered as an agent.
Exploring the Wumpus world:
Now we will explore the Wumpus world and will determine how the agent will find its goal by
applying logical reasoning.
Agent's First step:
Initially, the agent is in the first room or on the square [1,1], and we already know that this
room is safe for the agent, so to represent on the below diagram (a) that room is safe we will
add symbol OK. Symbol A is used to represent agent, symbol B for the breeze, G for Glitter or
gold, V for the visited room, P for pits, W for Wumpus.
At Room [1,1] agent does not feel any breeze or any Stench which means the adjacent squares
are also OK.
Agent's second Step:
Now agent needs to move forward, so it will either move to [1, 2], or [2,1]. Let's suppose agent
moves to the room [2, 1], at this room agent perceives some breeze which means Pit is around
this room. The pit can be in [3, 1], or [2,2], so we will add symbol P? to say that, is this Pit room?
Now agent will stop and think and will not make any harmful move. The agent will go back to
the [1, 1] room. The room [1,1], and [2,1] are visited by the agent, so we will use symbol V to
represent the visited squares.
Agent's third step:
At the third step, now agent will move to the room [1,2] which is OK. In the room [1,2] agent
perceives a stench which means there must be a Wumpus nearby. But Wumpus cannot be in the
room [1,1] as by rules of the game, and also not in [2,2] (Agent had not detected any stench when
he was at [2,1]). Therefore agent infers that Wumpus is in the room [1,3], and in current state,
there is no breeze which means in [2,2] there is no Pit and no Wumpus. So it is safe, and we will
mark it OK, and the agent moves further in [2,2].
Syntax
Semantics
Syntax of First-Order logic:
The syntax of FOL determines which collection of symbols is a logical expression in first-order
logic. The basic syntactic elements of first-order logic are symbols. We write statements in
short-hand notation in FOL.
Basic Elements of First-order logic:
Following are the basic elements of FOL syntax:
Variables x, y, z, a, b,....
Connectives 𝖠, ∨, ¬, ⇒, ⇔
Equality ==
Quantifier ∀, ∃
Atomic sentences:
• Atomic sentences are the most basic sentences of first-order logic. These sentences are
formed from a predicate symbol followed by a parenthesis with a sequence of terms.
• We can represent atomic sentences as Predicate (term1, term2, ...... , term n).
• Example: Ravi and Ajay are brothers: => Brothers(Ravi, Ajay).
Chinky is a cat: => cat (Chinky).
Complex Sentences:
Existential Quantifier:
• Existential quantifiers are the type of quantifiers, which express that the statement
within its scope is true for at least one instance of something.
• It is denoted by the logical operator ∃, which resembles as inverted E. When it is used
with a predicate variable then it is called as an existential quantifier.
• If x is a variable, then existential quantifier will be ∃x or ∃(x). And it will be read as:
• There exists a 'x.'
• For some 'x.'
• For at least one 'x.'
• Example:
• Some boys are intelligent.
∃x: boys(x) 𝖠 intelligent(x)
It will be read as: There are some x where x is a boy who is intelligent.
Some Examples of FOL using quantifier:
1. All birds fly.
In this question the predicate is "fly(bird)."
And since there are all birds who fly so it will be represented as follows.
∀x bird(x) →fly(x).
2. Every man respects his parent.
In this question, the predicate is "respect(x, y)," where x=man, and y= parent.
Since there is every man so will use ∀, and it will be represented as follows:
∀x man(x) → respects (x, parent).
What is Unification?
• Predicate symbol must be same, atoms or expression with different predicate symbol
can never be unified.
• Number of Arguments in both expressions must be identical.
• Unification will fail if there are two similar variables present in the same expression.
Unification Algorithm:
Algorithm: Unify(Ψ1, Ψ2)
a) Call Unify function with the ith element of Ψ1 and ith element of Ψ2, and put the
result into S.
b) If S = failure then returns Failure
c) If S ≠ NIL then do,
a. Apply S to the remainder of both L1 and L2.
b. SUBST= APPEND(S, SUBST).
• Deductive reasoning
• Inductive reasoning
• Abductive reasoning
• Common Sense Reasoning
• Monotonic Reasoning
• Non-monotonic Reasoning
1. Deductive reasoning:
2. Inductive Reasoning:
• Inductive reasoning is a form of reasoning to arrive at a conclusion using limited sets of
facts by the process of generalization. It starts with the series of specific facts or data and
reaches to a general statement or conclusion.
• Inductive reasoning is a type of propositional logic, which is also known as cause-effect
reasoning or bottom-up reasoning.
• In inductive reasoning, we use historical data or various premises to generate a generic
rule, for which premises support the conclusion.
• In inductive reasoning, premises provide probable supports to the conclusion, so the
truth of premises does not guarantee the truth of the conclusion.
Example:
Premise: All of the pigeons we have seen in the zoo are white.
• Abductive reasoning is a form of logical reasoning which starts with single or multiple
observations then seeks to find the most likely explanation or conclusion for the
observation.
• Abductive reasoning is an extension of deductive reasoning, but in abductive reasoning,
the premises do not guarantee the conclusion.
• Example:
• Implication: Cricket ground is wet if it is raining
• Axiom: Cricket ground is wet.
• Conclusion It is raining.
4. Common Sense Reasoning
• Common sense reasoning is an informal form of reasoning, which can be gained through
experiences.
• Common Sense reasoning simulates the human ability to make presumptions about
events which occurs on every day.
• It relies on good judgment rather than exact logic and operates on heuristic
knowledge and heuristic rules.
• Example:
• One person can be at one place at a time.
• If I put my hand in a fire, then it will burn.
• The above two statements are the examples of common sense reasoning which a human
mind can easily understand and assume.
5. Monotonic Reasoning:
• In monotonic reasoning, once the conclusion is taken, then it will remain the same even
if we add some other information to existing information in our knowledge base. In
monotonic reasoning, adding knowledge does not decrease the set of prepositions that
can be derived.
• To solve monotonic problems, we can derive the valid conclusion from the available
facts only, and it will not be affected by new facts.
• Monotonic reasoning is not useful for the real-time systems, as in real time, facts get
changed, so we cannot use monotonic reasoning.
• Monotonic reasoning is used in conventional reasoning systems, and a logic-based
system is monotonic.
• Any theorem proving is an example of monotonic reasoning.
• Example:
• Earth revolves around the Sun.
• It is a true fact, and it cannot be changed even if we add another sentence in knowledge
base like, "The moon revolves around the earth" Or "Earth is not round," etc.
Advantages of Monotonic Reasoning:
• For real-world systems such as Robot navigation, we can use non-monotonic reasoning.
• In Non-monotonic reasoning, we can choose probabilistic facts or can make
assumptions.
• Disadvantages of Non-monotonic Reasoning:
• In non-monotonic reasoning, the old facts may be invalidated by adding new sentences.
• It cannot be used for theorem proving.
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.
• Bayes' rule
• Bayesian Statistics
We can find the probability of an uncertain event by using the below formula.
•
• Where P(A⋀B)= Joint probability of a and B
• P(B)= Marginal probability of B.
• If the probability of A is given and we need to find the probability of B, then it will be
given as:
•
• It can be explained by using the below Venn diagram, where B is occurred event, so
sample space will be reduced to set B, and now we can only calculate event A whenevent
B is already occurred by dividing the probability of P(A⋀B) by P( B ).
Example:
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:
Let, A is an event that a student likes Mathematics
B is an event that a student likes English.
Hence, 57% are the students who like English also like Mathematics.
Bayes' theorem in Artificial intelligence
Bayes' theorem:
• Bayes' theorem is also known as Bayes' rule, Bayes' law, or Bayesian reasoning, which
determines the probability of an event with uncertain knowledge.
• In probability theory, it relates the conditional probability and marginal probabilities of
two random events.
• 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 allows updating the probability prediction of an event by observing new
information of the real world.
• 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:
• As from product rule we can write:
• P(A ⋀ B)= P(A|B) P(B) or
• Similarly, the probability of event B with known event A:
• P(A ⋀ B)= P(B|A) P(A)
• Equating right hand side of both the equations, we will get:
• The above equation (a) is called as Bayes' rule or Bayes' theorem. This equation is basic
of most modern AI systems for probabilistic inference.
• 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
• P(B) is called marginal probability, pure probability of an 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:
• Where A1, A2, A3, ....... , An is a set of mutually exclusive and exhaustive events.
• Applying Bayes' rule:
• Bayes' rule allows us to compute the single term P(B|A) in terms of P(A|B), P(B), and
P(A). This is very useful in cases where we have a good probability of these three terms
and want to
• determine the fourth one. Suppose we want to perceive the effect of some unknown
cause, and want to compute that cause, then the Bayes' rule becomes:
Example-1:
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:
The Known probability that a patient has meningitis disease is 1/30,000.
The Known probability that a patient has a stiff neck is 2%.
Let a be the proposition that patient has stiff neck and b be the proposition that patient has
meningitis. , so we can calculate the following as:
P(a|b) = 0.8
P(b) = 1/30000
P(a)= .02
Hence, we can assume that 1 patient out of 750 patients has meningitis disease with a stiff neck.
Bayesian Belief Network in artificial intelligence
• Bayesian belief network is key computer technology for dealing with probabilistic events
and to solve a problem which has uncertainty. We can define a Bayesian networkas:
• "A Bayesian network is a probabilistic graphical model which represents a set of
variables and their conditional dependencies using a directed acyclic graph."
• It is also called a Bayes network, belief network, decision network, or Bayesian model.
• Bayesian networks are probabilistic, because these networks are built from
a probability distribution, and also use probability theory for prediction and anomaly
detection.
• Real world applications are probabilistic in nature, and to represent the relationship
between multiple events, we need a Bayesian network. It can also be used in various tasks
including prediction, anomaly detection, diagnostics, automated insight, reasoning, time
series prediction, and decision making under uncertainty.
• Bayesian Network can be used for building models from data and experts opinions, and
it consists of two parts:
• Directed Acyclic Graph
• Table of conditional probabilities.
The generalized form of Bayesian network that represents and solve decision problems under
uncertain knowledge is known as an Influence diagram.
A Bayesian network graph is made up of nodes and Arcs (directed links), where:
Each node corresponds to the random variables, and a variable can be continuous or discrete.
Arc or directed arrows represent the causal relationship or conditional probabilities between
random variables. These directed links or arrows connect the pair of nodes in the graph.
These links represent that one node directly influence the other node, and if there is no directed
link that means that nodes are independent with each other
In the above diagram, A, B, C, and D are random variables represented by the nodes of the
network graph.
If we are considering node B, which is connected with node A by a directed arrow, then node Ais
called the parent of Node B.
Node C is independent of node A.
The Bayesian network has mainly two components:
• Causal Component
• Actual numbers
Each node in the Bayesian network has condition probability distribution P(Xi |Parent(Xi) ),
which determines the effect of the parent on that node.
Bayesian network is based on Joint probability distribution and conditional probability. So let's
first understand the joint probability distribution:
Joint probability distribution:
If we have variables x1, x2, x3, .... , xn, then the probabilities of a different combination of x1, x2,
x3.. xn, are known as Joint probability distribution.
P[x1, x2, x3,.... , xn], it can be written as the following way in terms of the joint probability
distribution.
= P[x1| x2, x3,....., xn]P[x2, x3, .... , xn]
= P[x1| x2, x3,....., xn]P[x2|x3,....., xn] ... P[xn-1|xn]P[xn].
In general for each variable Xi, we can write the equation as:
P(Xi|Xi-1, ........, X1) = P(Xi |Parents(Xi ))
Earthquake(E)
Alarm(A)
David Calls(D)
Sophia calls(S)
We can write the events of problem statement in the form of probability: P[D, S, A, B, E], can
rewrite the above probability statement using joint probability distribution:
P[D, S, A, B, E]= P[D | S, A, B, E]. P[S, A, B, E]
=P[D | S, A, B, E]. P[S | A, B, E]. P[A, B, E]
= P [D| A]. P [ S| A, B, E]. P[ A, B, E]
Let's take the observed probability for the Burglary and earthquake component:P(B=
True) = 0.002, which is the probability of burglary.
P(B= False)= 0.998, which is the probability of no burglary.
P(E= True)= 0.001, which is the probability of a minor earthquake
P(E= False)= 0.999, Which is the probability that an earthquake not occurred.
We can provide the conditional probabilities as per the below tables:
Conditional probability table for Alarm A:
The Conditional probability of Alarm A depends on Burglar and earthquake:
B E P(A= True) P(A= False)
The Conditional probability of David that he will call depends on the probability of Alarm.
From the formula of joint distribution, we can write the problem statement in the form of
probability distribution:
P(S, D, A, ¬B, ¬E) = P (S|A) *P (D|A)*P (A|¬B ^ ¬E) *P (¬B) *P (¬E).