CS代考 1. Introduction and JUnit – cscodehelp代写

1. Introduction and JUnit

Fuzzy Logic

1

1

Fuzzy Expert Systems: Learning Objectives
Exploit fuzziness in data
Create fuzzy rules
Apply fuzzy rules
Adapted from Savich
2

What Can We Expect Machines to Learn?
3
Much of what needs to be learned carries uncertainty.

(e.g., X is a dining room because it contains a table and several chairs)

Fuzzy is a useful approach to uncertainty.

Key motivation for fuzzy: humans’ use of language.

Fuzzy Logic

4
Introduction; Fuzzy Linguistic Variables
Fuzzy Rules
Applying fuzzy rules to crisp input
Demonstration
Applications
Tools
Conclusion

Advantages over Conventional E.S.
Fewer rules
Easier to express
Amenable to parallelism
More robust

As we will see, fuzzy expert systems (“ES”) tend to need fewer rules than conventional ES’s. Fuzzy rules can operate in parallel, and their “fuzziness” can make them less brittle than conventional rules.

Fuzzy Disadvantages
No chaining
No guarantee of stability
Few theoretical results
Verification requires extensive testing
Adapted from Munakata & Jani CACM March 1995

The main disadvantage of fuzzy rules is that they do not facilitate chains of reasoning. The other listed disadvantages concern the fact that they are empirical. However, this is true for almost all machine learning techniques—with the possible exception on Bayesian reasoning. Also, automated chain reasoning from data seems to be a long way off in any case.
6

When to Apply Conventional/Fuzzy
Logically deep: Conventional
e.g. radar repair
e.g. business prognosis with multiple branching
Small number of rules: Fuzzy
e. g., semi-trailer backup
e.g. rough business prognosis

The bullet points contrast examples of conventional vs. fuzzy expert systems. The operator of a semitrailer uses a relatively small set of rules (“If I am in … position and … then I take … action”) rather than a rule that concludes an intermediate statement, and thus facilitates chains of reasoning in which one application of a rule produces results that are then used in another rule application.

Common Visualization of Fuzzy Set S

0
1

Universal set represented here
x
degree to which
x belongs to F

On a History of Fuzzy Sets and Systems


and students

A set in mathematics is something for which it is possible to state, for anything, whether that thing belongs or not. An example is the set of chairs in Manhattan on January 1, 2017 at 3 pm. The universal set is the set consisting of everything.

, a prominent electrical engineer, speculated in the 1950’s about the mismatch between the concreteness of sets and how this mismatched the real world. He invented the idea of a fuzzy set (let’s call an example F) for which one can state, for anything, the degree to which that thing belongs to F.

The figure shows a way to visualize a fuzzy set in two dimensions. It imagines the universal set as spread out on the x axis, and a typical element x. The degree to which x belongs to F is represented by a point whose y coordinate is between 0 (equivalent to not belonging at all in the conventional sense and 1 (belonging entirely). Since the sets we will be concerned with involve only numbers, this visualization proves to be adequate.
8

Example: The Fuzzy Set Young

0
1
age

25
The degree to which 25 belongs to Young is 0.7 (70%).

45
0.7

The definition of a fuzzy set depends on the context. For example, in the context of a nursery school application, a 10-year-old would belong the the fuzzy set Young to the degree 0. For an insurance application, the fuzzy set Young might be defined as in the figure. In this particular definition, the number -1 is not considered to belong to this set—more properly, we say that its degree of belonging to Young is zero.
9

Visualization of Fuzzy Sets

0
1

Universal set “spread” out on x-axis
s1 s2 s3 s4

As an exercise in reinforcing the fuzzy idea, the figure concerns a system in which the universal set consists of just four elements, labeled s1, s2, s3, and s4. We imagine them as four positive numbers.
10

Visualization of “S” & “T”

0
1

s1 s2 s3 s4

S

T

This figure shows two fuzzy sets in this space. There is an extensive theory about intersecting fuzzy sets etc. but we will not need most of it for machine learning in this course.
11

Fuzzy Linguistic Variable
A variable
whose values are fuzzy sets
over a common range of numbers.
Example: Temperature,
with values VLo, Lo, Med, Hi, VHi

In fuzzy work, we often work with variables (such as Temperature) whose values are fuzzy sets (such as VeryLow, Low, etc.). This is like a variable s in Java of type String—the values of s are strings. Variables whose values are fuzzy sets are called fuzzy linguistic variables.
12

(Fuzzy Linguistic Variable Temperature)
One of its Values: High

1

0C
50C
80C
60C

degree to which 60C is High

0
High

Here is a picture of the fuzzy set High, a value of the fuzzy linguistic variable Temperature.
13

v hi
v lo
med
low
hi
Common Fuzzy Values

1

The figure shows the general shape of commonly used fuzzy values.
14

Common Place for Fuzzy Use
Output

pendulum position / velocity
Decision mechanism
Which way to move
e. g.
Model
Input

The layman often imagines that fuzzy expert systems are used when the input or output is fuzzy but this is not generally true: it is the model that expresses fuzziness. Inputs and outputs are more often crisp.
15

Fuzzy Logic

16
Introduction; Fuzzy Linguistic Variables
Fuzzy Rules
Applying fuzzy rules to crisp input
Demonstration
Applications
Tools
Conclusion

Now that we have defined fuzzy linguistic variables, we can define rules with them in the same way that we defined expert system rules. Recall that the latter are like

IF strength is >80 units and speed is >70 units THEN recruit is promising.

For classical expert systems, this refers to values of strength and speed—ordinary, (“crisp”) variables. This example carries over easily to fuzzy variables Strength and Speed whose values are fuzzy sets like Fast, Slow, High Low, etc., as explained in this section.

Fuzzy Control Model
Made up of controller rules (model)
IF IS
AND IS

THEN IS

The figure shows the form of a fuzzy rule. Notice that we are not allowing for an OR conclusion.
17

Fuzzy Control Model

t
t’
v

t +
+

t’ +
Sign convention
Angle
Rotation speed

The classical example of a fuzzy rules set is one that balances a stick (formally referred to as an “inverted pendulum”). Three fuzzy variables are involved:
Angle (i.e., with the vertical), shortened to t,
Angular Velocity (e.g., measured in degrees per second), shortened to t’, and
Velocity (e.g., measured in degrees per second), shortened to t’.

. The figure shows the directions that are taken as positive and negative.

18

Fuzzy Control Model

t
t’
Example:
IF t is Positive Large AND t’ is Negative Large
THEN v Positive Large
v

t +
+

t’ +

The figure shows an example of a fuzzy rule. You can check for yourself that if the pendulum (stick) were leaning to the right and rotating clockwise fast, you would need to move the bottom of the stick to the right at high speed in order to keep it balanced.
19

Truck Backing Example

t = truck angle
w = wheel angle
IF
location left quadrant
& t negative large
& w left medium
THEN
turn wheel clock large
+

left quadrant
left
back
front

right

The idea of fuzzy linguistic rules codifies useful rules-of-thumb such as those used when backing up a truck to a loading bay—or even more complex ones such as backing up a semi-trailer.
20

Pendulum Values for t and t’
NL Negative Large
NM Negative Medium
NS Negative Small
ZE Zero
PS Positive Small
PM Positive Medium
PL Positive Large

The fuzzy values of one fuzzy linguistic variable are not necessarily the same as those of another; however, they often have names such as “Large.” The “Large” fuzzy value for one variable is unlikely to be the same as for another, though.

In the inverted pendulum example, t and t’ share values with the same names, as in the figure. Positive Small, for example, has different for t as for t’, however.
21

Fuzzy Value Example: Zero (ZE)

-20o
20o
1

Consider the (fuzzy set) value Zero of a Temperature variable. Certainly, 0o qualifies fully as belonging to Zero. On the other hand, 50o almost certainly does not. One version of Zero is shown in the figure.
22

Pendulum Fuzzy Associative Memory (FAM)
for Velocity (of base)
ZE
NS
PS
NM
NL
PM
PL
NM
PM
NS
NM
NL
PS
PM
PL
t
t’
NL
NM
NS
ZE
PS
PM
PL
NL
NM
NS
ZE
PS
PM
PL

t
t’
v

+
+
+
Example shown

The rules of a fuzzy expert system with two variables can be conveniently expressed by a matrix, as in the figure. For example, the rule PM is “if t is Positive Small and t’ is Negative Small (i.e., counter-clockwise), then velocity is Positive Medium.” This particular rule is illustrated in the figure.
23

Uncertainty and Fuzzy Logic

24
Introduction; Fuzzy Linguistic Variables
Fuzzy Rules
Applying fuzzy rules to crisp input
Demonstration
Applications
Tools
Conclusion

We can express fuzzy rules. In this section, we will describe what a fuzzy expert system does with an input. The inputs will be assumed to be an ordinary numbers. The term crisp is used to emphasize this.

Applying “A => B” to Input: Example

A: Temp == Medium
B: Alert level == Normal

0

0

Medium
Normal

100

Imagine a rule for which the input (the IF part) is Temperature and the output (THEN part) is Alert Level on a scale from 0 to 100.
25

Implementing “A => B”: Example

Given: furnace temp 90o …..
90o

Consequent value via rule?
Temp

Alert level

0

Medium
Normal
0o

100

Suppose that we have the rule “IF Temp == Medium THEN Alert Level == Normal.” (We are using ‘==‘ to emphasize that the variable has the value, although we usually use just “=“.)

Suppose that, in addition to this rule, we also know that the temperature is measured at 90o. The question is what does the fuzzy system do with crisp input?
26

Implementing “A => B”

Given: a crisp value in range of A
a

A
B
Fuzzy consequence of a

degree of A

degree of B

When a crisp value a is observed, it conditions the premise A (IF part); in other words a and A determine the extent to which the premise is true. We are asking to what extent is B true? It is natural to say that if A implies B and A is true some particular extent then B is true to the same extent. That is what the diagram shows in red—the extent to which the fuzzy set B is true.
27

Implementing “A => B”

Rule’s consequence of 90o

alert level

90o
Temp
Alert level
Medium
Normal
100

The consequence of the input 90o is thus the fuzzy value shown in red. It is probably not equivalent to any single name like “large,” “somewhat large” etc. but it is nevertheless well-defined.
28

Implementing A&B => C

IF t = PS AND t’ = ZE THEN v = NS

t = 15
t’ = -10

The figure shows the consequence (in red) of
The rule IF t = PS AND t’ = ZE THEN v = NS
The input t = 15, and
The input t’ = -10

The lower of the two horizontal lines isusually chosen.

29

Summing Consequents

Applying rules to input thus produces a set of fuzzy (set) values—often trapezoidal in shape. What we actually want is a concrete (“crisp”) result. This is usually done by treating the fuzzy sets as, in effect, metal plates* and selecting as the crisp value, the center of gravity (“centroid”) of the result.

* Plates with uniform mass, in fact
30

Summing Consequents

Center of gravity of combination

To find the center of gravity of a set of shapes, you can replace each with a weighted point at its own center of gravity. Then you find the weighted average of the point weights. This is demonstrated in the figure.
31

Fuzzy Logic

32
Introduction; Fuzzy Linguistic Variables
Fuzzy Rules
Applying fuzzy rules to crisp input
Demonstration
Applications
Tools
Conclusion

http://www.cs.dartmouth.edu/~spl/publications/fuzzy%20talk/FuzzyPendulum.html

The figure shows the rules (in green) that provide nonzero contribution to the velocity of the base (actually, the torque, which is equivalent here). You can select a single rule—Zero and Zero implies Zero in the figure—that shows the way that rule contributes.

The pendulum is “knocked” now and then to get it going.
33

Inverted Pendulum
34

Leave a Reply

Your email address will not be published. Required fields are marked *