32
Fuzzy Expert Systems Fuzzy Expert Systems

Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Embed Size (px)

Citation preview

Page 1: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy Expert SystemsFuzzy Expert Systems

Page 2: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Lecture OutlineLecture Outline

What is fuzzy thinking?What is fuzzy thinking? Fuzzy setsFuzzy sets Linguistic variables and hedgesLinguistic variables and hedges Operations of fuzzy setsOperations of fuzzy sets Fuzzy rulesFuzzy rules SummarySummary

Page 3: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy LogicFuzzy Logic How can we represent expert knowledge How can we represent expert knowledge

that uses vague and ambiguous terms in that uses vague and ambiguous terms in a computer?a computer?

Fuzzy logic is not logic that is fuzzy, but logic Fuzzy logic is not logic that is fuzzy, but logic that is used to describe fuzziness. that is used to describe fuzziness.

Fuzzy logic is the theory of fuzzy sets.Fuzzy logic is the theory of fuzzy sets. Fuzzy logic is based on the idea that things Fuzzy logic is based on the idea that things

can be described by a range of linguistic can be described by a range of linguistic variation.variation.

Temperature, height, speed, distance, beauty Temperature, height, speed, distance, beauty all come on a sliding scale. all come on a sliding scale. The motor is running The motor is running really hotreally hot. . Tom is a Tom is a very tallvery tall guy. guy.

Page 4: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Crisp SetsCrisp Sets

Boolean logic forces us to draw lines Boolean logic forces us to draw lines between members of a class and non-between members of a class and non-members. members.

e.g we may say, Tom is tall because his e.g we may say, Tom is tall because his height is 181 cm. height is 181 cm.

If we drew a line at 180 cm, we would If we drew a line at 180 cm, we would find that David, who is 179 cm, is small. find that David, who is 179 cm, is small.

Is David really a small man or we have Is David really a small man or we have just drawn an arbitrary distinction?just drawn an arbitrary distinction?

Page 5: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Crisp SetsCrisp Sets A subset U of a set S can be defined as a set of A subset U of a set S can be defined as a set of

ordered pairs with a first element from the set ordered pairs with a first element from the set S, and a second element from the set { 0, 1} S, and a second element from the set { 0, 1}

This defines a mapping between elements of S This defines a mapping between elements of S and elements of the set { 0, l }. and elements of the set { 0, l }.

zero is non-membership, one represents zero is non-membership, one represents membership. membership.

The truth or falsity of the statement : x is in U The truth or falsity of the statement : x is in U is determined by finding the ordered pair is determined by finding the ordered pair whose first element is x. The statement is true whose first element is x. The statement is true if the second element of the ordered pair is l, if the second element of the ordered pair is l, and false if it is 0.and false if it is 0.

Page 6: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy conceptsFuzzy concepts Truth values (in fuzzy logic) or membership values (in Truth values (in fuzzy logic) or membership values (in

fuzzy sets) are indicated by a value on the range fuzzy sets) are indicated by a value on the range [0.0,1.0], (0.0 = absolute Falseness ,1.0 = absolute [0.0,1.0], (0.0 = absolute Falseness ,1.0 = absolute Truth.) Truth.) eg “Jane is old.”eg “Jane is old.” If Jane's age was 75, we might assign the statement If Jane's age was 75, we might assign the statement

the truth value of 0.80.the truth value of 0.80. The statement could be translated into set terminology:The statement could be translated into set terminology:

““Jane is a member of the set of old people.”Jane is a member of the set of old people.” This statement would be rendered symbolically with This statement would be rendered symbolically with

fuzzy sets as: mOLD(Jane) = 0.80fuzzy sets as: mOLD(Jane) = 0.80 where m is the membership function, operating on where m is the membership function, operating on

the fuzzy set of old people, which returns a value the fuzzy set of old people, which returns a value between 0.0 and 1.0.between 0.0 and 1.0.

Page 7: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy conceptsFuzzy concepts

The probabilistic approach yields the The probabilistic approach yields the natural-language statement, “There natural-language statement, “There is a 80% chance that Jane is old,”is a 80% chance that Jane is old,”

The fuzzy terminology corresponds The fuzzy terminology corresponds to “Jane's degree of membership to “Jane's degree of membership within the set of old people is 0.80.” within the set of old people is 0.80.”

Page 8: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy LogicFuzzy Logic Fuzzy logic is a set of mathematical Fuzzy logic is a set of mathematical

principles for knowledge principles for knowledge representation based on degrees of representation based on degrees of membership.membership.

fuzzy logic is fuzzy logic is multi-valuedmulti-valued. . It deals with It deals with degrees of degrees of

membershipmembership and and degrees of truthdegrees of truth. . Fuzzy logic uses the continuum of Fuzzy logic uses the continuum of

logical values between 0 (completely logical values between 0 (completely false) and 1 (completely true). false) and 1 (completely true).

Page 9: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Range of logical values in Boolean and fuzzy logicRange of logical values in Boolean and fuzzy logic

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

Page 10: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy SetsFuzzy Sets

The basic idea of the fuzzy set The basic idea of the fuzzy set theory is that an element belongs to theory is that an element belongs to a fuzzy set with a certain degree of a fuzzy set with a certain degree of membership. membership.

Thus, a proposition is not either true Thus, a proposition is not either true or false, but may be partly true (or or false, but may be partly true (or partly false) to any degree. partly false) to any degree.

This degree is usually taken as a real This degree is usually taken as a real number in the interval [0,1].number in the interval [0,1].

Page 11: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

The classical example in fuzzy sets is The classical example in fuzzy sets is tall mentall men. The . The elements of the fuzzy set “tall men” are all men, but elements of the fuzzy set “tall men” are all men, but their degrees of membership depend on their their degrees of membership depend on their height. height.

Degree of Membership

Fuzzy

Mark

John

Tom

Bob

Bill

1

1

1

0

0

1.00

1.00

0.98

0.82

0.78

Peter

Steven

Mike

David

Chris

Crisp

1

0

0

0

0

0.24

0.15

0.06

0.01

0.00

Name Height, cm

205

198

181

167

155

152

158

172

179

208

Page 12: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

150 210170 180 190 200160

Height, cmDegree ofMembership

Tall Men

150 210180 190 200

1.0

0.0

0.2

0.4

0.6

0.8

160

Degree ofMembership

170

1.0

0.0

0.2

0.4

0.6

0.8

Height, cm

Fuzzy Sets

Crisp Sets

Crisp and fuzzy sets of “Crisp and fuzzy sets of “tall mentall men””

Page 13: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

The The xx-axis represents the -axis represents the universe of universe of discoursediscourse the range of all possible the range of all possible values applicable to a chosen variable. values applicable to a chosen variable. In our case, the variable is the man height. In our case, the variable is the man height.

The The yy-axis represents the -axis represents the membership membership value of the fuzzy setvalue of the fuzzy set. . In our case, the fuzzy set of “In our case, the fuzzy set of “tall mentall men” ”

maps height values into corresponding maps height values into corresponding membership values.membership values.

Page 14: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

A fuzzy set is a set with fuzzy boundaries.A fuzzy set is a set with fuzzy boundaries. Let Let XX be the universe of discourse and its elements be the universe of discourse and its elements

be denoted as be denoted as xx. In the classical set theory, . In the classical set theory, crisp crisp set set AA of of XX is defined as function is defined as function ffAA((xx)) called the called the

characteristic function of characteristic function of AA

ffAA((xx): ): XX {0, 1}, where {0, 1}, where

Ax

Axxf A if0,

if 1,)(

This set maps universe This set maps universe XX to a set of two to a set of two elements. For any element elements. For any element xx of universe of universe XX, , characteristic function characteristic function ffAA((xx) is equal to 1 if ) is equal to 1 if xx is an is an

element of set element of set AA, and is equal to 0 if , and is equal to 0 if xx is not an is not an element of element of AA..

Page 15: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy set Fuzzy set AA of universe of universe XX is defined by function is defined by function AA((xx) called the ) called the membership functionmembership function of set of set AAAA((xx): ): XX [0, 1], where [0, 1], where AA((xx) = 1 if ) = 1 if xx is totally in is totally in AA;;

AA((xx) = 0 if ) = 0 if xx is not in is not in AA;;

0 < 0 < AA((xx) < 1 if ) < 1 if xx is partly in is partly in AA..

For any element For any element xx of universe of universe XX, membership , membership function function AA((xx) equals the degree to which ) equals the degree to which xx is an is an

element of set element of set AA. . This degree, a value between 0 and 1, represents the This degree, a value between 0 and 1, represents the

degree of membershipdegree of membership, also called , also called membership membership valuevalue, of element , of element xx in set in set AA..

Page 16: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

How to represent a fuzzy set in a How to represent a fuzzy set in a computer?computer?

Determine the membership functions.Determine the membership functions. In the “In the “tall mentall men” example, we can obtain ” example, we can obtain

fuzzy sets of fuzzy sets of talltall, , shortshort and and averageaverage men. men. The universe of discourse consists of three sets: The universe of discourse consists of three sets:

shortshort, , averageaverage and and tall mentall men. . a man who is 184 cm tall is a member of the a man who is 184 cm tall is a member of the

average menaverage men set with degree of membership set with degree of membership of 0.1, and he is also a member of the of 0.1, and he is also a member of the tall mentall men set with a degree of 0.4.set with a degree of 0.4.

Page 17: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Crisp and fuzzy sets of short, average and tall menCrisp and fuzzy sets of short, average and tall men

150 210170 180 190 200160

Height, cmDegree ofMembership

Tall Men

150 210180 190 200

1.0

0.0

0.2

0.4

0.6

0.8

160

Degree ofMembership

Short Average ShortTall

170

1.0

0.0

0.2

0.4

0.6

0.8

Fuzzy Sets

Crisp Sets

Short Average

Tall

Tall

Page 18: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Representation of crisp and fuzzy subsetsRepresentation of crisp and fuzzy subsets

Fuzzy Subset A

Fuzziness

1

0Crisp Subset A Fuzziness x

X

(x)

Typical functions that can be used to represent a fuzzy Typical functions that can be used to represent a fuzzy set are sigmoid, gaussian and pi. However, these set are sigmoid, gaussian and pi. However, these functions increase the time of computation. Therefore, functions increase the time of computation. Therefore, in practice, most applications use in practice, most applications use linear fit functionslinear fit functions..

Page 19: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

In fuzzy expert systems, linguistic variables are used In fuzzy expert systems, linguistic variables are used in fuzzy rules. in fuzzy rules. A linguistic variable is a A linguistic variable is a fuzzy variablefuzzy variable For example:For example:

IFIF wind is strongwind is strongTHEN sailing is goodTHEN sailing is good

IFIF project_duration is longproject_duration is longTHEN completion_risk is highTHEN completion_risk is high

IF IF speed is slowspeed is slowTHEN stopping_distance is shortTHEN stopping_distance is short

Page 20: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

The range of possible values of a linguistic variable The range of possible values of a linguistic variable represents the universe of discourse of that variable. represents the universe of discourse of that variable.

For example, the universe of discourse of the For example, the universe of discourse of the linguistic variable linguistic variable speedspeed might have the range might have the range between 0 and 220 km/h and may include such between 0 and 220 km/h and may include such fuzzy subsets as fuzzy subsets as very slowvery slow, , slowslow, , mediummedium, , fastfast, , and and very fastvery fast..

A linguistic variable includes the concept of fuzzy A linguistic variable includes the concept of fuzzy set qualifiers, called set qualifiers, called hedgeshedges. .

Hedges are terms that modify the shape of fuzzy Hedges are terms that modify the shape of fuzzy sets. They include adverbs such as sets. They include adverbs such as veryvery, , somewhatsomewhat, , quitequite, , more or lessmore or less and and slightlyslightly..

Page 21: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

HedgesHedges These operations are provided in an effort to These operations are provided in an effort to

maintain close ties to natural language, and to maintain close ties to natural language, and to allow for the generation of fuzzy statements allow for the generation of fuzzy statements through mathematical calculations. through mathematical calculations.

. The simplest example is in which one . The simplest example is in which one transforms the statement “Jane is old” to transforms the statement “Jane is old” to “Jane is very old.” The hedge `Very” is usually “Jane is very old.” The hedge `Very” is usually defined as follows:defined as follows:

m”Very”A(x) = mA(x)^2m”Very”A(x) = mA(x)^2 Thus, if mOLD(Jane) = 0.8, then Thus, if mOLD(Jane) = 0.8, then

mVERYOLD(Jane) = 0.64.mVERYOLD(Jane) = 0.64.

Page 22: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy sets with the hedge Fuzzy sets with the hedge veryvery

Short

Very Tall

Short Tall

Degree ofMembership

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

Page 23: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Representation of hedges in fuzzy logicRepresentation of hedges in fuzzy logic

Hedge MathematicalExpression

A little

Slightly

Very

Extremely

Hedge MathematicalExpression Graphical Representation

[A ( x )]1.3

[A ( x )]1.7

[A ( x )]2

[A ( x )]3

Page 24: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Representation of hedges in fuzzy logic (continued)Representation of hedges in fuzzy logic (continued)

Hedge MathematicalExpressionHedge 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 25: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

What is a fuzzy rule?What is a fuzzy rule?

A fuzzy rule can be defined as a conditional A fuzzy rule can be defined as a conditional statement in the form:statement in the form:

IFIF xx is is AATHEN THEN yy is is BB

where where xx and and yy are linguistic variables; and are linguistic variables; and AA and and BB are linguistic values determined by fuzzy sets on the are linguistic values determined by fuzzy sets on the universe of discourses universe of discourses XX and and YY, respectively., respectively.

Page 26: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

What is the difference between classical and What is the difference between classical and fuzzy rules?fuzzy rules?

A classical IF-THEN rule uses binary logic, for A classical IF-THEN rule uses binary logic, for example,example,

Rule: 1Rule: 1IFIF speed is > 100 speed is > 100THEN stopping_distance is longTHEN stopping_distance is long

Rule: 2Rule: 2IFIF speed is < 40 speed is < 40THEN stopping_distance is shortTHEN stopping_distance is short

Page 27: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

We can also represent the stopping distance rules in a We can also represent the stopping distance rules in a fuzzy form:fuzzy form:

Rule: 1Rule: 1IFIF speed is fast speed is fastTHEN stopping_distance is longTHEN stopping_distance is long

Rule: 2Rule: 2IFIF speed is slow speed is slowTHEN stopping_distance is shortTHEN stopping_distance is short

What is the difference What is the difference between classical and fuzzy between classical and fuzzy

rules?rules?

In a fuzzy system, all rules fire to some In a fuzzy system, all rules fire to some extent, or in other words they fire partially. If extent, or in other words they fire partially. If the antecedent is true to some degree of the antecedent is true to some degree of membership, then the consequent is also true membership, then the consequent is also true to that same degreeto that same degree.

Page 28: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

Fuzzy RulesFuzzy Rules

• In fuzzy rules, the linguistic variable In fuzzy rules, the linguistic variable speedspeed also has the range (the universe also has the range (the universe of discourse) between 0 and 220 km/h, of discourse) between 0 and 220 km/h, but this range includes fuzzy sets, such but this range includes fuzzy sets, such as as slowslow, , mediummedium and and fastfast. .

• The universe of discourse of the The universe of discourse of the linguistic variable linguistic variable stopping_distancestopping_distance can can be between 0 and 300 m and may be between 0 and 300 m and may include such fuzzy sets as include such fuzzy sets as shortshort, , mediummedium and and longlong..

Page 29: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

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

Fuzzy sets of Fuzzy sets of talltall and and heavyheavy men men

These fuzzy sets provide the basis for a weight estimation These fuzzy sets provide the basis for a weight estimation model. The model is based on a relationship between a model. The model is based on a relationship between a man’s height and his weight:man’s height and his weight:

IF height is IF height is talltallTHEN weight is THEN weight is heavyheavy

Page 30: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

The value of the output or a truth membership grade of The value of the output or a truth membership grade of the rule consequent can be estimated directly from a the rule consequent can be estimated directly from a corresponding truth membership grade in the corresponding truth membership grade in the antecedent. This form of fuzzy inference uses a antecedent. This form of fuzzy inference uses a method called method called monotonic selectionmonotonic selection..

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 31: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

A fuzzy rule can have multiple antecedents, for A fuzzy rule can have multiple antecedents, for example:example:

IFIF project_duration is long project_duration is longANDAND project_staffing is large project_staffing is largeANDAND project_funding is inadequate project_funding is inadequateTHEN risk is highTHEN risk is high

IFIF service is excellent service is excellentOROR food is delicious food is deliciousTHEN tip is generousTHEN tip is generous

Page 32: Fuzzy Expert Systems. Lecture Outline What is fuzzy thinking? What is fuzzy thinking? Fuzzy sets Fuzzy sets Linguistic variables and hedges Linguistic

The consequent of a fuzzy rule can also include The consequent of a fuzzy rule can also include multiple parts, for instance:multiple parts, for instance:

IFIF temperature is hot temperature is hotTHEN hot_water is reduced;THEN hot_water is reduced;

cold_water is increasedcold_water is increased