ARTIFICIAL INTELLIGENCE Uncertainty: fuzzy systems Lecturer: Silja - - PowerPoint PPT Presentation

artificial intelligence uncertainty fuzzy systems
SMART_READER_LITE
LIVE PREVIEW

ARTIFICIAL INTELLIGENCE Uncertainty: fuzzy systems Lecturer: Silja - - PowerPoint PPT Presentation

Utrecht University INFOB2KI 2019-2020 The Netherlands ARTIFICIAL INTELLIGENCE Uncertainty: fuzzy systems Lecturer: Silja Renooij These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html


slide-1
SLIDE 1

ARTIFICIAL INTELLIGENCE

Lecturer: Silja Renooij

Uncertainty: fuzzy systems

Utrecht University The Netherlands

These slides are part of the INFOB2KI Course Notes available from www.cs.uu.nl/docs/vakken/b2ki/schema.html

INFOB2KI 2019-2020

slide-2
SLIDE 2

Outline

  • Boolean logic and crisp sets
  • Fuzzy logic & sets
  • Inferences with fuzzy rules
slide-3
SLIDE 3

Reasoning models

  • Classical models (logic, exact)

– If Pressure = 10 atm then Volume = 2.5 cc

  • Imprecise models

– If Pressure ≥ 5 atm then Volume ≤ 6 cc

  • Probabilistic models

– If Pressure ≥ 5 atm then P(Volume = 6 cc) = 0.9

  • Vague models

– If Pressure = HIGH then Volume = LOW

slide-4
SLIDE 4

Boolean logic & Crisp sets I

  • Boolean logic uses sharp distinctions.
  • It forces us to draw lines between

members of a class and non‐members.

  • For instance, we may say, Tom is tall because his height is

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

tall men

slide-5
SLIDE 5

Boolean Logic & Crisp sets II

Consider a universe of discourse (interest) X and its elements x. In classical set theory, a crisp subset A of X is defined by the characteristic function fA(x) of A: fA(x) : X  {0, 1}, where

      A x A x x f A if 0, if 1, ) (

slide-6
SLIDE 6

The trouble with crisp sets

Sorites Paradox: the paradox of the heap

Consider a heap of sand from which grains are individually

  • removed. One might construct the following argument:
  • 1,000,000 grains of sand is a heap of sand (Premise 1)
  • A heap of sand minus one grain is still a heap. (Premise 2)

Repeated application of Premise 2 eventually forces one to accept the conclusion that a heap may be composed of just

  • ne grain of sand …

…at some point it must stop being a heap!

slide-7
SLIDE 7

Fuzzy reasoning

  • Experts rely on common sense when they solve problems.
  • How can we represent expert knowledge that uses vague

and ambiguous terms in a computer?

  • Fuzzy logic is based on the idea that all things admit of

degrees. Temperature, height, speed, distance, beauty – all come

  • n a sliding scale.

– The motor is running really hot. – Tom is a very tall guy.

slide-8
SLIDE 8

A bit of History

Multi‐valued logic:

  • First introduced in the 1930s by Jan Lukasiewicz

(Polish philosopher)

  • work led to an inexact reasoning technique often called

possibility theory.

  • extended into a formal system of mathematical logic by

Lofti Zadeh in 1965  new multi‐valued logic for representing and manipulating fuzzy terms was called fuzzy logic.  Unlike other logical systems, it deals with imprecise or uncertain knowledge.

slide-9
SLIDE 9

Fuzzy logic and Fuzzy sets

Fuzzy logic

  • is multi‐valued, unlike Boolean logic; it deals with

degrees of membership and degrees of truth.

  • uses the continuum between 0 (completely false)

and 1 (completely true), accepting that things can be partly true and partly false at the same time.

tall men, to a certain degree

slide-10
SLIDE 10

Fuzzy Sets vs Crisp sets

Degree of Membership Fuzzy Frank John Tom Bob Bill 1 1 1 1.00 1.00 0.98 0.82 0.78 Peter Steven Mike David Chris Crisp 1 0.24 0.15 0.06 0.01 0.00 Name Height, cm 205 198 181 167 155 152 158 172 179 208

The set of Tall people

slide-11
SLIDE 11

Fuzzy sets vs Crisp sets

150 210 170 180 190 200 160 Height, cm Degree of Membership Tall Men 150 210 180 190 200 1.0 0.0 0.2 0.4 0.6 0.8 160 Degree of Membership Short Average Short Tall 170 1.0 0.0 0.2 0.4 0.6 0.8 Fuzzy Sets Crisp Sets Short Average Tall Tall

slide-12
SLIDE 12

Fuzzy sets

Consider a universe of discourse (interest) X and its elements x. In fuzzy set theory, a fuzzy subset A of X is defined by the membership function µA(x) of A:

µA(x) : X  [0,1], where µA(x) = 1 if x is totally in A; µA(x) = 0 if x is not in A; 0 < µA(x) < 1 if x is partly in A.

slide-13
SLIDE 13

Fuzzy set representation

  • Typical functions that can be used to represent a fuzzy set

are sigmoid, Gaussian and Pi.

  • However, these functions increase the time of
  • computation.  in practice, most applications use

– linear fit functions, or – just a number of ordered pairs mapping x to µ (discrete)

Fuzzy Subset A Fuzziness 1 Crisp Subset A Fuzziness x X  (x)

slide-14
SLIDE 14

Fuzzy set notations

Consider a discrete universe of discourse (interest) X and its elements x. Different notations are used to describe fuzzy (sub)set A of X : A = {(x1, 0.4), (x2, 0.3), (x3, 1), (x4, 0.6)} i.e. A = {(x, µA(x)) | x in X} Or, using Zadeh’s notation: A = 0.4/x1 + 0.3/x2 + 1/x3 + 0.6/x4 i.e. A = ∑x µA(x)/x (not fractions!)

slide-15
SLIDE 15

Fuzzy sets and probability

Take care!

  • Fuzzy membership values may look like

probabilities, but have a totally different meaning!

slide-16
SLIDE 16

Operators

  • Complement /negation
  • Intersection / AND
  • Union / OR
  • containment / implication
  • Equality
  • Cardinality
  • Empty set
slide-17
SLIDE 17

Boolean Logic/Crisp Sets: ops

Intersection Union Complement Not A A Containment A A B B A B A A B

) ( A x

  • B

x A x    B x A x    B x A x   

slide-18
SLIDE 18

Fuzzy ops: complement/negation

  • Boolean/Crisp: Who does not belong to the set?
  • Fuzzy: How much do elements not belong to the set?
  • Standard negation:

Complement ¬A of fuzzy set A can be found as follows: ¬A (x) = 1  A(x) Example: consider set X and fuzzy subset A X = {a, b, c, d, e} A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e  A = 0/a + 0.7/b + 0.8/c + 0.2/d + 1/e

slide-19
SLIDE 19

Negation: alternatives

Minimum negation ¬A (x) = 1 if A(x)=0 = 0 otherwise Maximum negation ¬A (x) = 0 if A(x)=1 = 1 otherwise

slide-20
SLIDE 20

Fuzzy ops: Intersection/AND

  • Boolean/Crisp: Which element belongs to both sets?
  • Fuzzy: How much of the element is in both sets?
  • Standard intersection: (minimum)

Intersection of two fuzzy subsets A and B of X is the lower membership in both sets of each element: AB(x) = min [A(x), B(x)] = A(x)  B(x) Example: consider set X and two fuzzy subsets A,B X = {a, b, c, d, e} A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e B = 0.6/a + 0.9/b + 0.1/c + 0.3/d + 0.2/e  A  B = 0.6/a + 0.3/b + 0.1/c + 0.3/d + 0/e

slide-21
SLIDE 21

Intersection: alternatives

Product

AB(x) = A(x) ∙B(x)

Lukasiewicz

AB(x) = max[ A(x)+B(x)‐1, 0 ]

Drastic

AB(x) = min[ A(x), B(x) ], if A(x)=1 or B(x)=1 = 0, otherwise

slide-22
SLIDE 22

Fuzzy operations: Union/OR

  • Boolean/Crisp: Which element belongs to either set?
  • Fuzzy: How much of the element is in either set?
  • Standard union: (maximum)

‐ reverse of intersection ‐ union of two fuzzy subsets A and B of X is the largest membership value of each element in either set: AB(x) = max [A(x), B(x)] = A(x)  B(x) Example: consider set X and two fuzzy subsets A,B X = {a, b, c, d, e} A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e B = 0.6/a + 0.9/b + 0.1/c + 0.3/d + 0.2/e  A  B = 1/a + 0.9/b + 0.2/c + 0.8/d + 0.2/e

slide-23
SLIDE 23

Union: alternatives

Probabilistic sum

AB(x) = A(x) + B(x) ‐ A(x)∙B(x)

Lukasiewicz

AB (x) = min[ A(x)+B(x), 1 ]

Drastic

AB(x) = max[ A(x), B(x) ], if A(x)=0 or B(x)=0 = 1, otherwise

slide-24
SLIDE 24

Fuzzy ops: containment(inclusion)/implication

  • Boolean/Crisp: Which sets belong to which other sets?
  • Fuzzy: Which sets belong to other sets?
  • Inclusion:

– each element can belong less to the subset than to the larger set. – Fuzzy set A  X is included in (is a subset of) another fuzzy set, B  X: A(x)  B(x), xX Example: Consider X = {1, 2, 3} and fuzzy subsets A,B A = 0.3/1 + 0.5/2 + 1.0/3 B = 0.5/1 + 0.55/2 + 1.0/3 then A is a subset of B, or A  B

slide-25
SLIDE 25

Fuzzy Equality

  • Fuzzy set A is considered equal to a fuzzy

set B, IF AND ONLY IF (iff): A(x) = B(x), xX Example: A = 0.3/1 + 0.5/2 + 1.0/3 B = 0.3/1 + 0.5/2 + 1.0/3 therefore A = B

slide-26
SLIDE 26

Fuzzy cardinality

  • Crisp Sets: How many elements belong to the set?
  • Fuzzy Sets: What is the total membership value of the set?
  • Cardinality (aka sigma count) for finite sets:

cardA = A(x1) + A(x2) + … A(xn) = ΣA(xi) for i=1..n Example: Consider X = {1, 2, 3} and fuzzy subsets A and B A = 0.3/1 + 0.5/2 + 1.0/3 cardA = 1.8 B = 0.5/1 + 0.55/2 + 1.0/3 cardB = 2.05

slide-27
SLIDE 27

Empty Fuzzy Set

  • A fuzzy set A is empty IF AND ONLY IF:

A(x) = 0, xX Example: Consider X = {1, 2, 3} and fuzzy set A A = 0/1 + 0/2 + 0/3 then A is empty

slide-28
SLIDE 28

Fuzzy to Crisp operations

  • ‐cuts (alpha‐cuts)
  • Support
  • core
slide-29
SLIDE 29

Fuzzy to crisp: alpha cut

  • An ‐cut or ‐level set of a fuzzy set A  X is

– a crisp set A X, such that:

A={xX |A(x)} Example: Consider X = {1, 2, 3} and A = 0.3/1 + 0.5/2 + 1.0/3 then A0.5 = {2, 3}, A0.1 = {1, 2, 3}, A1 = {3}

  • For continuous X and A, A will be a subinterval of

X (see previous slide)

slide-30
SLIDE 30

Fuzzy to Crisp: Core and Support

Consider a fuzzy subset A of X

  • the support of A is the crisp subset of X consisting of all

elements with positive membership grade: supp(A) = {x X  A(x)  0}

  • the core of A is the crisp subset of X consisting of all elements

with membership grade 1: core(A) = {x X  A(x) = 1}

  • For continuous X, A, supp and core again are subintervals of X

Example: Consider two fuzzy subsets of the set X = {a, b, c, d, e} A = 1/a + 0.3/b + 0.2/c + 0.8/d + 0/e and B = 0.6/a + 0.9/b + 0.1/c + 0.3/d + 0.2/e  Support: supp(A) = {a, b, c, d} and supp(B) = {a, b, c, d, e}  Core: core(A) = {a} and core(B) = {}

slide-31
SLIDE 31

Fuzzy Reasoning

Requires:

  • 1. Knowledge base with rules and membership functions
  • 2. Fuzzy inference process
slide-32
SLIDE 32

Knowledge base: fuzzy rules

  • A fuzzy rule can be defined as a conditional

statement in the form: IF x is A THEN y is B where

– x and y are linguistic variables (e.g. length, weight); – A and B are linguistic values determined by fuzzy sets

  • n the universe of discourses X and Y, respectively

(e.g. short, heavy)

slide-33
SLIDE 33

Classical vs Fuzzy Rules

A classical IF‐THEN rule uses binary logic

Rule: 1 Rule: 2 IF speed > 100 IF speed < 40 THEN stopping_distance = 300 THEN stopping_distance = 40

  • variable speed: any numerical value between 0 and 220 km/h
  • variable stopping_distance: numbers 40, …, 300

Stopping distance rules in a fuzzy form:

Rule: 1 Rule: 2 IF speed = fast IF speed = slow THEN stopping_distance = long THEN stopping_distance = short

  • Linguistic variable speed: range (universe of discourse) still between 0

and 220 km/h, but includes fuzzy sets, such as slow, medium and fast.

  • variable stopping_distance: between 0 and 300m and may include such

fuzzy sets as short, medium and long.

slide-34
SLIDE 34

Fuzzy Inference

All fuzzy inference processes basically consist of 4 steps:

  • 1. Fuzzification of the input variables
  • 2. Rule evaluation
  • 3. Aggregation of the rule outputs (if necessary)
  • 4. Defuzzification.

Step 1 Step 4 Step 2&3

slide-35
SLIDE 35

Boiling fuzzy eggs

http://www.youtube.com/watch?v=J_Q5X0nTmrA

slide-36
SLIDE 36

Step 1: Fuzzification

  • Take the crisp inputs
  • Determine the degree  to which these inputs

belong to each of the appropriate1 fuzzy sets

1 as used in the fuzzy rules

(e.g. if height is tall or height is average then…)

Degree of Membership 150 210 180 190 200 1.0 0.0 0.2 0.4 0.6 0.8 160 170 Short Average Tall Tall

slide-37
SLIDE 37

Step 2: Rule Evaluation (I)

‘Classical’ if‐then rules are triggered if the antecedent can be matched (=true); firing (applying) the rule then allows for inferring the consequent. Fuzzy if‐then rules:

  • are triggered only partially: antecedent is matched

with fuzzified input  holds only to a certain degree

(if rule has multiple antecedents, apply given fuzzy

  • perator to obtain a single number)
  • relate fuzzy sets to each other
  • fire only partially: consequent only holds to a certain

degree

slide-38
SLIDE 38

Rule evaluation: monotonic selection

Consider the following fuzzy rule: IF height is tall THEN weight is heavy The truth membership grade of the rule consequent can be estimated directly from a corresponding truth membership grade in the antecedent, using monotonic selection:

Tall men Heavy men 180 Degree of Membership 1.0 0.0 0.2 0.4 0.6 0.8 Height, cm 190 200 70 80 100 160 Weight, kg 120 Degree of Membership 1.0 0.0 0.2 0.4 0.6 0.8

slide-39
SLIDE 39

Step 2: Rule Evaluation (II)

The type of result of fuzzy rule evaluation depends on choice of inference engine.

  • textbook: returns membership value in fuzzy set of

rule consequent

  • Mamdani inference returns a fuzzy set for each rule

consequent  using clipping or scaling  allows for elegant rule aggregation (step 3)

slide-40
SLIDE 40

Rule Evaluation: scaling

Adjust original membership function of the rule consequent by multiplying all its membership degrees by the truth value

  • f the rule antecedent.

Preserves the original shape of the fuzzy set (better than clipping).

Degree of Membership Z 1.0 0.0 0.2 C2

slide-41
SLIDE 41

Rule Evaluation: clipping

  • the most common method
  • cut the consequent membership function at the level of the

antecedent truth (related to alpha‐cut)

  • Less complex and faster mathematics; generates an

aggregated output surface that is easier to defuzzify.  Since the top of the membership function is sliced, the clipped fuzzy set loses some information.

Degree of Membership 1.0 0.0 0.2 Z C2

slide-42
SLIDE 42

Step 3: Aggregating rule outputs

Consider: if X=A then Z=C, and if Y=B then Z=D Aggregation: combine rule evaluation results for fuzzy sets C and D to obtain a single result per output variable Z. Since different inference engines give different types of output for rules, aggregation is also different.

  • textbook: return single membership value

(e.g max of membership values in fuzzy sets; or blended (combines aggregation with defuzzification))

  • Mamdani inference: return a single fuzzy set (constructed

from the previously clipped or scaled sets)

slide-43
SLIDE 43

Step 4: Defuzzification

Fuzziness helps us to evaluate the rules, but the final output of a fuzzy system has to be a crisp number. Again various defuzzification methods exist.

  • textbook: e.g. project membership value back on output variable
  • Mamdani inference: most popular: centroid technique

 find center of gravity (COG) of a (aggregated) fuzzy set.

Tall men Heavy men 180 Degree of Membership 1.0 0.0 0.2 0.4 0.6 0.8 Height, cm 190 200 70 80 100 160 Weight, kg 120 Degree of Membership 1.0 0.0 0.2 0.4 0.6 0.8

slide-44
SLIDE 44

Center of Gravity

The center of gravity is the point where a vertical line would slice the set into two equal masses

   

 

   

b a A b a A

dx x dx x x COG

 ( x ) 1.0 0.0 0.2 0.4 0.6 0.8 160 170 180 190 200 a b 210 A 150 X

In practice COG is typically approximated with summations.

slide-45
SLIDE 45

Mamdani Fuzzy Inference

The Mamdani‐style fuzzy inference is used most often. In summary, it does the following:

  • 1. Fuzzification of the input variables: standard
  • 2. Rule evaluation: results in fuzzy sets
  • 3. Aggregation of the rule outputs: into a single fuzzy set
  • 4. Defuzzification: e.g. with centroid technique

We will now illustrate all steps with an example…

slide-46
SLIDE 46

Example rule base

We examine a simple two‐input ‐‐ one‐output problem that includes 3 rules, 3 variables and 8 fuzzy sets.

Rule: 1 Rule: 1 IF x is A3 IF project_funding is adequate OR y is B1 OR project_staffing is small THEN z is C1 THEN risk is low Rule: 2 Rule: 2 IF x is A2 IF project_funding is marginal AND y is B2 AND project_staffing is large THEN z is C2 THEN risk is normal Rule: 3 Rule: 3 IF x is A1 IF project_funding is inadequate THEN z is C3 THEN risk is high

slide-47
SLIDE 47
  • Our crisp inputs for project funding (x1) and project

staffing (y1) are: x1 = 35% and y1 = 60%

Crisp Input y1

0.1 0.7 1 y1

B1 B2

Y

Crisp Input

0.2 0.5 1

A1 A2 A3

x1

x1 X

(x1) = 0.5

Step 1: Fuzzification

(x1) = 0.2 (x1) = 0.0 (y1) = 0.1 (y1) = 0.7

slide-48
SLIDE 48

Step 2: Rule Evaluation

A3

1 X 1 y1 Y 0.0 x1 0.1

C1

1

C2

Z 1 X 0.2 0.2

C1

1

C2

Z

A2

x1

Rule 3: A1

1 X 1 Z x1

THEN

C1 C2

1 y1

B2

Y 0.7

B1

0.1

C3 C3 C3

0.5 0.5 OR (max) AND (min)

OR THEN

Rule 1:

AND THEN

Rule 2:

IF x is A3 (0.0) y is B1 (0.1) z is C1 (0.1) IF x is A2 (0.2) y is B2 (0.7) z is C2 (0.2) IF x is A1 (0.5) z is C3 (0.5)

Note: application of fuzzy operators in antecedent + clipping in consequent; fuzzy membership values are given in brackets

slide-49
SLIDE 49

Step 3: Aggregating rule outputs

All three rules have a consequent concerning the

  • utcome variable risk (Z)

We combine the three relevant clipped fuzzy sets into a single one  for each value z: (z)= max(C1(z), C2(z), C3(z))  output is one fuzzy set (z) for risk

0.1 1

C1

C z is 1 (0.1)

C2

0.2 1

C z is 2 (0.2)

0.5 1

C z is 3 (0.5)

Z Z Z 0.2 Z

C3

0.5 0.1

slide-50
SLIDE 50

Step 4: Defuzzification

We approximate COG with sums and find: the project’s risk is 67.4%

4 . 67 5 . 5 . 5 . 5 . 2 . 2 . 2 . 2 . 1 . 1 . 1 . 5 . ) 100 90 80 70 ( 2 . ) 60 50 40 30 ( 1 . ) 20 10 (                          COG

1.0 0.0 0.2 0.4 0.6 0.8 20 30 40 50 10 70 80 90 100 60 Z Degree of Membership 67.4

slide-51
SLIDE 51

Conclusions

  • Fuzzy sets can be used to model vague terms

– Important when crisp distinctions would lead to arbitrary cut offs

  • Inference with fuzzy logic possible, but not as

“clean” as with first order logic ≈ approximate reasoning

  • Outcome of inference differs for:

– choice of implementation of operators – choice of implementation of inference steps

 what’s best?

slide-52
SLIDE 52

Applications

  • Automatically parking cars
  • Video cameras (noise reduction, steady image)
  • Image processing
  • Classifying situations in games
  • Household appliances

(see Fuzzy in Appliances: http://www.fuzzytech.com/e/e_a_esa.html)

  • Japanese subway

(Sendai Subway 1000 series)