36
Artificial Intelligence CIS 342 The College of Saint Rose David Goldschmidt, Ph.D.

Artificial Intelligence CIS 342

  • Upload
    loring

  • View
    15

  • Download
    1

Embed Size (px)

DESCRIPTION

Artificial Intelligence CIS 342. The College of Saint Rose David Goldschmidt, Ph.D. Fuzzy Logic. Expert knowledge often uses vague and inexact terms Fuzzy Logic describes fuzziness by specifying degrees - PowerPoint PPT Presentation

Citation preview

Page 1: Artificial Intelligence CIS 342

Artificial Intelligence

CIS 342

The College of Saint RoseDavid Goldschmidt, Ph.D.

Page 2: Artificial Intelligence CIS 342

Expert knowledge oftenuses vague and inexact terms

Fuzzy Logic describes fuzziness by specifying degrees – e.g. degrees of height, speed,

distance, temperature, beauty, intelligence, etc.

Fuzzy Logic

Page 3: Artificial Intelligence CIS 342

Unlike Boolean logic, fuzzy logic is multi-valued – Fuzzy logic represents degrees of

membershipand degrees of truth

– Things can be part true and part false at the same time

Fuzzy Logic

(a) Boolean Logic. (b) Multi-valued Logic0 1 10 0.2 0.4 0.6 0.8 1001 10

Page 4: Artificial Intelligence CIS 342

A linguistic variable is a fuzzy variable– e.g. the fact “John is tall” implies linguistic

variable “John” takes the linguistic value “tall”

– Use linguistic variables to form fuzzy rules:

Linguistic Variables

IF ‘project duration’ is longTHEN risk is high

IF risk is very highTHEN ‘project funding’ is very low

Page 5: Artificial Intelligence CIS 342

What about linguistic values with qualifiers?– e.g. very tall, extremely short, etc.

Hedges are qualifying terms that modifythe shape of fuzzy sets– e.g. very, somewhat, quite, slightly,

extremely, etc.

Qualifiers & Hedges

Page 6: Artificial Intelligence CIS 342

Representing Hedges

Hedge MathematicalExpression

A little

Slightly

Very

Extremely

Graphical Representation

[A(x)]1.3

[A(x)]1.7

[A(x)]2

[A(x)]3

Page 7: Artificial Intelligence CIS 342

Representing Hedges

Hedge MathematicalExpression

A little

Slightly

Very

Extremely

Graphical Representation

[A(x)]1.3

[A(x)]1.7

[A(x)]2

[A(x)]3

Hedge MathematicalExpression

A little

Slightly

Very

Extremely

Graphical Representation

[A(x)]1.3

[A(x)]1.7

[A(x)]2

[A(x)]3

Page 8: Artificial Intelligence CIS 342

Representing Hedges

Hedge MathematicalExpression Graphical Representation

Very very

More or less

Indeed

Somewhat

2 [A(x )]2

A(x)

A(x)

if 0 A 0.5

if 0.5 < A 1

1 2 [1 A(x)]2

[A(x)]4

Page 9: Artificial Intelligence CIS 342

Representing Hedges

Hedge MathematicalExpression Graphical Representation

Very very

More or less

Indeed

Somewhat

2 [A(x )]2

A(x)

A(x)

if 0 A 0.5

if 0.5 < A 1

1 2 [1 A(x)]2

[A(x)]4

Hedge MathematicalExpression Graphical Representation

Very very

More or less

Indeed

Somewhat

2 [A(x )]2

A(x)

A(x)

if 0 A 0.5

if 0.5 < A 1

1 2 [1 A(x)]2

[A(x)]4

Page 10: Artificial Intelligence CIS 342

Linguistic Variables & Hedges

Short

Very Tall

ShortTall

DegreeofMembership

150 210180 190 200

1.0

0.0

0.2

0.4

0.6

0.8

160 170

Height, cm

Average

TallVery Short Very Tall

write a function or method called very() that

modifies the degree of membershipe.g. double x = very( tall( 185 ) );

Page 11: Artificial Intelligence CIS 342

Crisp set operations developed by Georg Cantor in the late 19th century:

Crisp Set Operations

Intersection Union

Complement

NotA

A

Containment

AA

B

BA AA B

Page 12: Artificial Intelligence CIS 342

Crisp set operations developed by Georg Cantor in the late 19th century (continued):

Crisp Set Operations

Intersection Union

Complement

NotA

A

Containment

AA

B

BA AA B

Page 13: Artificial Intelligence CIS 342

Complement– To what degree do elements not belong to

this set?

Fuzzy Set Operations

Intersection Union

Complement

NotA

A

Containment

AA

B

BA AA B

Complement

0x

1

(x)

0x

1

Containment

0x

1

0x

1

AB

Not A

A

Intersection

0x

1

0x

AB

Union0

1

ABAB

0x

1

0x

1

B

A

B

A

(x)

(x) (x)

¬A(x) = 1 – A(x)

Page 14: Artificial Intelligence CIS 342

Containment– Which sets belong to other sets?

Fuzzy Set Operations

Intersection Union

Complement

NotA

A

Containment

AA

B

BA AA B

Complement

0x

1

(x)

0x

1

Containment

0x

1

0x

1

AB

Not A

A

Intersection

0x

1

0x

AB

Union0

1

ABAB

0x

1

0x

1

B

A

B

A

(x)

(x) (x)

Each element of the fuzzysubset has smaller membership

than in the containing set

Page 15: Artificial Intelligence CIS 342

Intersection– To what degree is the element in both sets?

Fuzzy Set Operations

Intersection Union

Complement

NotA

A

Containment

AA

B

BA AA B

Complement

0x

1

(x)

0x

1

Containment

0x

1

0x

1

AB

Not A

A

Intersection

0x

1

0x

AB

Union0

1

ABAB

0x

1

0x

1

B

A

B

A

(x)

(x) (x)

A∩B(x) = min[ A(x), B(x) ]

Page 16: Artificial Intelligence CIS 342

Union– To what degree is the element in either or

both sets?

Fuzzy Set Operations

Intersection Union

Complement

NotA

A

Containment

AA

B

BA AA B

Complement

0x

1

(x)

0x

1

Containment

0x

1

0x

1

AB

Not A

A

Intersection

0x

1

0x

AB

Union0

1

ABAB

0x

1

0x

1

B

A

B

A

(x)

(x) (x)

AB(x) = max[ A(x), B(x) ]

Page 17: Artificial Intelligence CIS 342

1965 paper: “Fuzzy Sets” (Lotfi Zadeh)– Apply natural language terms to a formal

system of mathematical logic– http://www.cs.berkeley.edu/~zadeh

1973 paper outlined a new approach to capturing human knowledge and designing expert systems using fuzzy rules

Fuzzy Rules

Page 18: Artificial Intelligence CIS 342

A fuzzy rule is a conditional statementin the familiar form:

IF x is ATHEN y is B

– x and y are linguistic variables– A and B are linguistic values determined by

fuzzy sets on the universe of discourses X and Y, respectively

Fuzzy Rules

Page 19: Artificial Intelligence CIS 342

A linguistic variable is a fuzzy variable– e.g. the fact “John is tall” implies linguistic

variable “John” takes the linguistic value “tall”

– Use linguistic variables to form fuzzy rules:

Linguistic Variables

IF ‘project duration’ is longTHEN ‘risk’ is high

IF risk is very highTHEN ‘project funding’ is very low

Page 20: Artificial Intelligence CIS 342

A fuzzy expert system is an expert system thatuses fuzzy rules, fuzzy logic, and fuzzy sets

Many rules in a fuzzy logic systemwill fire to some extent– If the antecedent is true to some degree of

membership, then the consequent is true to the same degree

Fuzzy Expert Systems

Page 21: Artificial Intelligence CIS 342

Two distinct fuzzy sets describing tall and heavy:

Fuzzy Expert Systems

Tall men Heavy men

180

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Height, cm

190 200 70 80 100160

Weight, kg

120

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Page 22: Artificial Intelligence CIS 342

Tall men Heavy men

180

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Height, cm

190 200 70 80 100160

Weight, kg

120

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

IF height is tallTHENweight is heavy

Fuzzy Expert Systems

Tall menHeavy men

180

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Height, cm

190 200 70 80 100160

Weight, kg

120

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Page 23: Artificial Intelligence CIS 342

Other examples (multiple antecedents):– e.g. IF ‘project duration’ is long

AND ‘project staffing’ is largeAND ‘project funding’ is

inadequateTHEN risk is high

– e.g. IF service is excellentOR food is deliciousTHEN tip is generous

Fuzzy Expert Systems

Page 24: Artificial Intelligence CIS 342

Other examples (multiple consequents):– e.g. IF temperature is hot

THEN ‘hot water’ is reduced;‘cold water’ is increased

Fuzzy Expert Systems

Page 25: Artificial Intelligence CIS 342

Named after Ebrahim Mamdani, the Mamdani method for fuzzy inference is:1. Fuzzify the input variables2. Evaluate the rules3. Aggregate the rule outputs4. Defuzzify

Fuzzy Inference

Page 26: Artificial Intelligence CIS 342

Rule 1:IF x is A3OR y is B1THEN z is C1

Rule 2:IF x is A2AND y is B2THEN z is C2

Rule 3:IF x is A1THEN z is C3

Fuzzy Inference – Example

Rule 1:IF ‘project funding’ is adequateOR ‘project staffing’ is smallTHEN risk is low

Rule 2:IF ‘project funding’ is marginalAND ‘project staffing’ is largeTHEN risk is normal

Rule 3:IF ‘project funding’ is inadequateTHEN risk is high

x, y, and z are linguistic variablesA1, A2, and A3 are linguistic values on XB1 and B2 are linguistic values on YC1, C2, and C3 are linguistic values on Z

Page 27: Artificial Intelligence CIS 342

1.Fuzzification

Fuzzy Inference – Example

CrispInput

0.1

0.71

0y1

B1 B2

Y

CrispInput

0.20.5

1

0

A1 A2 A3

x1

x1 X(x =A1) = 0.5(x =A2) = 0.2

(y =B1) = 0.1(y =B2) = 0.7

project funding project staffing

inadequate

marginal large

small

Page 28: Artificial Intelligence CIS 342

2.Rule 1 evaluation

Fuzzy Inference – Example

A31

0 X

1

y10 Y

0.0

x1 0

0.1C1

1

C2

Z

1

0 X

0.2

0

0.2 C11

C2

Z

A2

x1

Rule 3: IF x isA1 (0.5)

A11

0 X 0

1

Zx1

THEN

C1 C2

1

y1

B2

0 Y

0.7

B10.1

C3

C3

C30.5 0.5

OR(max)

AND(min)

OR THENRule 1: IF x isA3 (0.0)

AND THENRule 2: IF x isA2 (0.2)

y isB1 (0.1) z isC1 (0.1)

y isB2 (0.7) z isC2 (0.2)

z isC3 (0.5)

project fundingproject staffing

adequate small

risk

low

Page 29: Artificial Intelligence CIS 342

2.Rule 2 evaluation

Fuzzy Inference – Example

A31

0 X

1

y10 Y

0.0

x1 0

0.1C1

1

C2

Z

1

0 X

0.2

0

0.2 C11

C2

Z

A2

x1

Rule 3: IF x isA1 (0.5)

A11

0 X 0

1

Zx1

THEN

C1 C2

1

y1

B2

0 Y

0.7

B10.1

C3

C3

C30.5 0.5

OR(max)

AND(min)

OR THENRule 1: IF x isA3 (0.0)

AND THENRule 2: IF x isA2 (0.2)

y isB1 (0.1) z isC1 (0.1)

y isB2 (0.7) z isC2 (0.2)

z isC3 (0.5)

project funding project staffing

marginal large

risk

normal

Page 30: Artificial Intelligence CIS 342

2.Rule 3 evaluation

Fuzzy Inference – Example

A31

0 X

1

y10 Y

0.0

x1 0

0.1C1

1

C2

Z

1

0 X

0.2

0

0.2 C11

C2

Z

A2

x1

Rule 3: IF x isA1 (0.5)

A11

0 X 0

1

Zx1

THEN

C1 C2

1

y1

B2

0 Y

0.7

B10.1

C3

C3

C30.5 0.5

OR(max)

AND(min)

OR THENRule 1: IF x isA3 (0.0)

AND THENRule 2: IF x isA2 (0.2)

y isB1 (0.1) z isC1 (0.1)

y isB2 (0.7) z isC2 (0.2)

z isC3 (0.5)

project funding

inadequate

risk

high

Page 31: Artificial Intelligence CIS 342

00.1

1C1

z isC1 (0.1)

C2

0

0.2

1

z isC2 (0.2)

0

0.5

1

z isC3 (0.5)

ZZZ

0.2

Z0

C30.5

0.1

3.Aggregation of the rule outputs

Fuzzy Inference – Example

risk

highnormallow

Page 32: Artificial Intelligence CIS 342

00.1

1C1

z isC1 (0.1)

C2

0

0.2

1

z isC2 (0.2)

0

0.5

1

z isC3 (0.5)

ZZZ

0.2

Z0

C30.5

0.1

4.Defuzzification– e.g. use the centroid method in

which a vertical lineslices the aggregate setinto two equal halves

– How can we calculate this?

Fuzzy Inference – Example

Page 33: Artificial Intelligence CIS 342

4.Defuzzification– Calculate the centre of gravity (cog):

Fuzzy Inference – Example

b

aA

b

aA

COG

x x dx

x dx

Page 34: Artificial Intelligence CIS 342

4.Defuzzification– Use a reasonable sampling of points

Fuzzy Inference – Example

4.675.05.05.05.02.02.02.02.01.01.01.0

5.0)100908070(2.0)60504030(1.0)20100(

COG

1.0

0.0

0.2

0.4

0.6

0.8

0 20 30 40 5010 70 80 90 10060

Z

DegreeofMembership

67.4

4.675.05.05.05.02.02.02.02.01.01.01.0

5.0)100908070(2.0)60504030(1.0)20100(

COG

1.0

0.0

0.2

0.4

0.6

0.8

0 20 30 40 5010 70 80 90 10060

Z

DegreeofMembership

67.4

Page 35: Artificial Intelligence CIS 342

Why use fuzzy expert systems or fuzzy control systems?– Apply fuzziness (and therefore accuracy) to

linguistically defined terms and rules– Lack of crisp or concrete mathematical models

exist

When do you avoid fuzzy expert systems?– Traditional approaches produce acceptable results– Crisp or concrete mathematical models exist and

are easily implemented

Applications of Fuzzy Logic

Page 36: Artificial Intelligence CIS 342

Real-world applications include:– Control of robots, engines, automobiles,

elevators, etc.– Cruise-control in automobiles– Temperature control– Reduce vibrations in camcorders

http://www.esru.strath.ac.uk/Reference/concepts/fuzzy/fuzzy_appl.de20.htm

– Handwriting recognition, OCR– Predictive and diagnostic systems (e.g.

cancer)

Applications of Fuzzy Logic