Vous êtes sur la page 1sur 71

CS6659 Artificial Intelligence

Session VII 18-03-2016


Reasoning with Fuzzy logic and Bayesian systems

Dr. Bama S
Assistant Professor
Department of Information Science and Technology
CEG Campus
Anna University

1 / 39
Fuzzy Logic Introduction

2 / 39
Fuzzy Logic Introduction
1 We say something like “it is sunny and warm today”

2 / 39
Fuzzy Logic Introduction
1 We say something like “it is sunny and warm today”
2 And “If it is sunny and warm today, I can walk outside”

2 / 39
Fuzzy Logic Introduction
1 We say something like “it is sunny and warm today”
2 And “If it is sunny and warm today, I can walk outside”
3 From the above statements we automatically infer “I can
walk outside”

2 / 39
Fuzzy Logic Introduction
1 We say something like “it is sunny and warm today”
2 And “If it is sunny and warm today, I can walk outside”
3 From the above statements we automatically infer “I can
walk outside”

4 Definition: A form of knowledge representation suitable for


notions that cannot be defined precisely, but which depend
upon their contexts.

2 / 39
Representation in Classical Logic
-Adapted from Shane Warren & Brittney Ballard slides

3 / 39
Representation in Fuzzy Logic
-Adapted from Shane Warren & Brittney Ballard slides

4 / 39
Representation in Fuzzy Logic Contd.,
-Adapted from Shane Warren & Brittney Ballard slides

5 / 39
Origins
-Adapted from Shane Warren & Brittney Ballard slides

6 / 39
Fuzzy control system
-Adapted from Shane Warren & Brittney Ballard slides

7 / 39
Fuzzy Temperature controller
-Adapted from Shane Warren & Brittney Ballard slides

8 / 39
Fuzzy Control System - Block diagram

9 / 39
Crisp vs Fuzzy sets

Crisp variables. Eg - x = 3.1415296, A ∈ {0, 1}

10 / 39
Crisp vs Fuzzy sets

Crisp variables. Eg - x = 3.1415296, A ∈ {0, 1}

The proposition is either True or False.

10 / 39
Crisp vs Fuzzy sets

Crisp variables. Eg - x = 3.1415296, A ∈ {0, 1}

The proposition is either True or False.

Example: “If King Richard is greedy, then he is evil”. In


predicate logic,

10 / 39
Crisp vs Fuzzy sets

Crisp variables. Eg - x = 3.1415296, A ∈ {0, 1}

The proposition is either True or False.

Example: “If King Richard is greedy, then he is evil”. In


predicate logic,

king(Richard) ∧ greedy (Richard) → Evil(Richard).

10 / 39
Crisp vs Fuzzy sets

Crisp variables. Eg - x = 3.1415296, A ∈ {0, 1}

The proposition is either True or False.

Example: “If King Richard is greedy, then he is evil”. In


predicate logic,

king(Richard) ∧ greedy (Richard) → Evil(Richard).

Richard is either greedy or he isn’t:

Greedy (Richard) ∈ {0, 1}


10 / 39
Fuzzy sets

11 / 39
Fuzzy sets

What if Richard is somewhat greedy?

11 / 39
Fuzzy sets

What if Richard is somewhat greedy?

The degree to which the greediness or not greediness can


b represented using a fuzzy set.

11 / 39
Fuzzy sets

What if Richard is somewhat greedy?

The degree to which the greediness or not greediness can


b represented using a fuzzy set.

Fuzzy sets have values in the range [0, 1].

11 / 39
Fuzzy sets

What if Richard is somewhat greedy?

The degree to which the greediness or not greediness can


b represented using a fuzzy set.

Fuzzy sets have values in the range [0, 1].

11 / 39
Fuzzy Control system - Example

12 / 39
Fuzzy Control system - Example

Two inputs: Temperature and Cloud Cover.

12 / 39
Fuzzy Control system - Example

Two inputs: Temperature and Cloud Cover.

Output: Control the driving speed.

12 / 39
Fuzzy Control system - Example

Two inputs: Temperature and Cloud Cover.

Output: Control the driving speed.

If the temperature is warm and the cover is sunny, then


drive fast.

12 / 39
Fuzzy Control system - Example

Two inputs: Temperature and Cloud Cover.

Output: Control the driving speed.

If the temperature is warm and the cover is sunny, then


drive fast.

If the temperature is freezing and the cover is partly, drive


very slow.

12 / 39
Fuzzy Linguistic Variables - Inputs

13 / 39
Fuzzy Linguistic Variables - Inputs

14 / 39
Fuzzy Linguistic Variables - Output

15 / 39
Rules

If it’s sunny and warm, drive Fast.

16 / 39
Rules

If it’s sunny and warm, drive Fast.

sunny (cover ) ∧ warm(temp) → Fast(speed)

16 / 39
Rules

If it’s sunny and warm, drive Fast.

sunny (cover ) ∧ warm(temp) → Fast(speed)

If it’s cloudy and cool, drive slow.

16 / 39
Rules

If it’s sunny and warm, drive Fast.

sunny (cover ) ∧ warm(temp) → Fast(speed)

If it’s cloudy and cool, drive slow.

cloudy (cover ) ∧ cool(temp) → slow(speed)

16 / 39
Rules

If it’s sunny and warm, drive Fast.

sunny (cover ) ∧ warm(temp) → Fast(speed)

If it’s cloudy and cool, drive slow.

cloudy (cover ) ∧ cool(temp) → slow(speed)

Driving speed is the combination of ouput of these rules...

16 / 39
Example speed calculation
How fast will one drive if it is:
65◦ F

17 / 39
Example speed calculation
How fast will one drive if it is:
65◦ F

25% cloud cover

17 / 39
Fuzzification

18 / 39
Fuzzification

19 / 39
Fuzzy operators

20 / 39
Fuzzy disjunction

21 / 39
Fuzzy conjunction

22 / 39
Fuzzy conjunction

23 / 39
Fuzzy conjunction

24 / 39
Fuzzy conjunction

25 / 39
Fuzzy conjunction

26 / 39
Back to example

27 / 39
Defuzzification

28 / 39
Defuzzification

29 / 39
Defuzzification

30 / 39
Defuzzification

31 / 39
Defuzzification

32 / 39
Benefits
-Adapted from Shane Warren & Brittney Ballard slides

33 / 39
Source

Most of the slides are adapted from Andrew L. Nelson’s slides


of Introduction to Fuzzy Logic Control

34 / 39
Reasoning with probability

Used for predicting models

35 / 39
Reasoning with probability

Used for predicting models

Prior Distribution: use probability to quantify uncertainty


about unknown quantities (parameters)

35 / 39
Reasoning with probability

Used for predicting models

Prior Distribution: use probability to quantify uncertainty


about unknown quantities (parameters)

Likelihood: relates all variables into a full probability model

35 / 39
Reasoning with probability

Used for predicting models

Prior Distribution: use probability to quantify uncertainty


about unknown quantities (parameters)

Likelihood: relates all variables into a full probability model

Posterior Distribution: result of using data to update


information about unknown quantities (parameters)

35 / 39
Bayes Theorem

(P(B|A)P(A)
P(A|B) =
P(B)

where P(B), P(B) - Prior probability,


P(B/A) - Likelihood
P(A/B) - Posterior probability
If E1 , E2 ..., En are n-mutually exclusive events with P(Aj ) > 0 for
all i. Then for any event A which is a subset of S, Bayes
theorem is given by:

P(Ei ).P(A/Ei )
P(Ei /A) =
∑ni=1 P(Ei )P( EAi )

36 / 39
Example 1

An urn B1 contains 2 white and 3 black balls and another urn


B2 contains 3 white and 4 black balls. One urn is selected at
random and a ball is drawn from it. If the ball drawn is found
black, find the probability that the urn chosen was B1.

37 / 39
Example 1

An urn B1 contains 2 white and 3 black balls and another urn


B2 contains 3 white and 4 black balls. One urn is selected at
random and a ball is drawn from it. If the ball drawn is found
black, find the probability that the urn chosen was B1.
Let B1 and B2 denote urns 1 and 2, respectively.
pause
P(B1 ) = P(B2 ) = 12 .

37 / 39
Example 1

An urn B1 contains 2 white and 3 black balls and another urn


B2 contains 3 white and 4 black balls. One urn is selected at
random and a ball is drawn from it. If the ball drawn is found
black, find the probability that the urn chosen was B1.
Let B1 and B2 denote urns 1 and 2, respectively.
pause
P(B1 ) = P(B2 ) = 12 .
P(B1 |Black ) =?

37 / 39
Example 1

An urn B1 contains 2 white and 3 black balls and another urn


B2 contains 3 white and 4 black balls. One urn is selected at
random and a ball is drawn from it. If the ball drawn is found
black, find the probability that the urn chosen was B1.
Let B1 and B2 denote urns 1 and 2, respectively.
pause
P(B1 ) = P(B2 ) = 12 .
P(B1 |Black ) =?
P(Black |B1 ) = 35 , P(Black |B2 ) = 74

37 / 39
Example 1

An urn B1 contains 2 white and 3 black balls and another urn


B2 contains 3 white and 4 black balls. One urn is selected at
random and a ball is drawn from it. If the ball drawn is found
black, find the probability that the urn chosen was B1.
Let B1 and B2 denote urns 1 and 2, respectively.
pause
P(B1 ) = P(B2 ) = 12 .
P(B1 |Black ) =?
P(Black |B1 ) = 35 , P(Black |B2 ) = 74
(Black |B1 )P(B1 )
P(B1 |Black ) =
P(B1 )P(Black |B1 ) + P(B2 )P(Black |B2 )

37 / 39
Example 1

An urn B1 contains 2 white and 3 black balls and another urn


B2 contains 3 white and 4 black balls. One urn is selected at
random and a ball is drawn from it. If the ball drawn is found
black, find the probability that the urn chosen was B1.
Let B1 and B2 denote urns 1 and 2, respectively.
pause
P(B1 ) = P(B2 ) = 12 .
P(B1 |Black ) =?
P(Black |B1 ) = 35 , P(Black |B2 ) = 74
(Black |B1 )P(B1 )
P(B1 |Black ) =
P(B1 )P(Black |B1 ) + P(B2 )P(Black |B2 )

( 35 )( 12 ) 21
= =
( 12 )( 35 ) + ( 12 )( 74 ) 41
37 / 39
Example 2

A is known to tell the truth in 5 cases out of 6 and he states that


a white ball was drawn from a bag containing 8 blacks and 1
white ball. Find the probability that the white ball was drawn.

38 / 39
Example 2

A is known to tell the truth in 5 cases out of 6 and he states that


a white ball was drawn from a bag containing 8 blacks and 1
white ball. Find the probability that the white ball was drawn.
P(truth) = 65 , P(¬truth) = 16 , Total balls = 9, P(w) = 91 ,
where w - white ball.

38 / 39
Example 2

A is known to tell the truth in 5 cases out of 6 and he states that


a white ball was drawn from a bag containing 8 blacks and 1
white ball. Find the probability that the white ball was drawn.
P(truth) = 65 , P(¬truth) = 16 , Total balls = 9, P(w) = 91 ,
where w - white ball.
P(w|truth) =?

P(truth|w)P(w)
P(w|truth) =
P(truth|w)P(w) + P(¬truth|w)P(¬w)

38 / 39
Example 2

A is known to tell the truth in 5 cases out of 6 and he states that


a white ball was drawn from a bag containing 8 blacks and 1
white ball. Find the probability that the white ball was drawn.
P(truth) = 65 , P(¬truth) = 16 , Total balls = 9, P(w) = 91 ,
where w - white ball.
P(w|truth) =?

P(truth|w)P(w)
P(w|truth) =
P(truth|w)P(w) + P(¬truth|w)P(¬w)

( 56 )( 19 ) 5
= =
( 56 )( 19 ) + ( 16 )( 98 ) 13

38 / 39
Example3

The urns contain 6 green, 4 black; 4 green, 6 black and 5


green, 5 black balls respectively. Randomly selected an urn
and a ball is drawn from it. If the ball drawn is Green, find the
probability that it is drawn from the first urn.

39 / 39

Vous aimerez peut-être aussi