fuzzy logic cpsc 386 artificial intelligence ellen walker hiram college
TRANSCRIPT
![Page 1: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/1.jpg)
Fuzzy Logic
CPSC 386 Artificial Intelligence
Ellen Walker
Hiram College
![Page 2: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/2.jpg)
Why fuzzy?
• Imprecision better approximates human reasoning– It is warm today.
• 65 degrees F in April is warm• 65 degrees F in August is cool
• Imprecise calculation can be much faster (and “good enough”)– This is the idea behind heuristics
• TSP (0.75%) 1,000,000 cities, 7 months• TSP (3.5%) 1,000,000 cities, 3.5 hours
![Page 3: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/3.jpg)
Fuzzy vs. Crisp Sets
• Crisp set A– Each item x is an element of A (100%) or is not
(0%)
• Fuzzy set A– Each item x has degree of membership in the set
A– An item can have non-zero membership in both A
and ~A
![Page 4: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/4.jpg)
Membership function
• Horizontal axis: all potential members of the set (sorted, if possible)
• Vertical axis: membership value from 0 (not at all) to 1 (totally)
Temperature
cold warm hot
65F
0.8
0.2
![Page 5: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/5.jpg)
Linguistic Values
• Cold, Warm and Hot are linguistic values, represented by overlapping membership functions
• We can also define linguistic modifiers– Very A = membership in A squared– Somewhat hot = sqrt (membership in A)– Not A = 1-A– So, “not very A” = 1-A2
![Page 6: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/6.jpg)
Fuzzy Logic Operations
• AND– X cannot have more membership in the set (A and
B) than it does in A– Therefore, membership in (A and B) = min
(membership in A, membership in B)
• OR– X must have at least as much membership in (A or
B) as in A– Therefore, membership in (A or B) = max
(membership in A, membership in B)
![Page 7: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/7.jpg)
Fuzzy Rules
• The basic fuzzy rule form– If x is A then y is B
• First, determine membership of x in A• Then use that value to limit the degree to
which y is B
![Page 8: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/8.jpg)
Example: Adjusting a Bath/Shower
• Rules– If temperature is cold, then add-hot-water = high– If temperature is warm, then add-hot-water = med
– If temperature is cold, then add-cold-water = low– If temperature is warm, then add-cold-water = low
![Page 9: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/9.jpg)
Example: Membership functions
Temperature
cold warm
65F
0.8
0.2
Water flow
low high
hot
med
![Page 10: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/10.jpg)
Resulting Membership Functions
Cold water flow (.8 low, .2 low)
low highmed
Hot water flow (.8 med, .2 high)
low highmed
Center of mass
Center of mass
![Page 11: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/11.jpg)
More complex left sides
• If X is A and Y is B, then Z is C– Take AND (min) of A and B membership values to
limit C
• If X is A and Y is not B …– Take min (A, 1-B) membership values to limit C
![Page 12: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/12.jpg)
Designing a Fuzzy Rule-based System
• Develop linguistic variables for each input and output variable
• Express a set of rules in terms of variables– One rule for each input,output combination
• Test and adjust– Change rules– Change linguistic variables
• Often done using neural net, genetic algorithm, etc.
![Page 13: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/13.jpg)
Operating a Fuzzy Rule Based System
• Fuzzify inputs– Numerical input -> set of linguistic memberships
• Apply rules– Find the degree to which the left side applies– Limit the m.f. of the right side at that value– OR (union) m.f.s of all applicable rules
• Defuzzify output– Find the center of mass of the resulting fuzzy set,
translate that to a numerical output (if needed)
![Page 14: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/14.jpg)
Rules as Fuzzy Graphs
– If temperature is cold, then add-hot-water = high– If temperature is warm, then add-hot-water = med– If temperature is hot, then add-hot-water = low
cold
warm
hot
low med high
![Page 15: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/15.jpg)
Advantages of Fuzzy Rules
• Rules are expressed in (close to) natural language
• Fewer rules are needed because of interpolation
• No precise thresholds– Precise thresholds tend to make systems brittle
![Page 16: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/16.jpg)
Fuzzy Clustering
• If you have data that you want to classify, you are essentially specifying subsets of your data.
• Crisp clustering = crisp sets. Each item in (at most) one cluster.
• Fuzzy clustering = fuzzy sets. Items can belong to multiple clusters (with membership values between 0 and 1)– Typically, membership values add up to 1
![Page 17: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/17.jpg)
K Means Clustering (Crisp)
Choose K random cluster centers
Repeat
For each data point (feature vector)
Find the closest cluster
Assign point to cluster
For each cluster
Recompute the center (avg. data pt)
Until clusters don’t change
![Page 18: Fuzzy Logic CPSC 386 Artificial Intelligence Ellen Walker Hiram College](https://reader030.vdocuments.us/reader030/viewer/2022032802/56649dff5503460f94ae75be/html5/thumbnails/18.jpg)
Fuzzy C-Means Clustering
• Same as fuzzy K-means except:– Point has (0-1) membership in cluster– Membership computed based on distance from
center– Center computed based on weighted average of
cluster members (weight by membership)
• “Borderline points” belong to multiple clusters, but don’t pull the centers much
• Overlapping clusters make sense