Homework 3
Homework 3
1. You have been approached by a botanist to help out in the classification of 3 different species of the
flower iris based on measurements of their petal length (x 1) and petal width (x2). The botanist has provided
you with the knowledge about the type of flower (i.e, the class) for each data sample. You are asked to
provide an automated inference tool which assigns a class (e.g., iris class 1, iris class 2, iris class 3) based
on the measurements of petal length and petal width. The task is complicated by an overlapping region in
which the classification is not unique. Misclassifications are unavoidable but it is the goal to hold them to a
minimum. Specifically,
a) Design a fuzzy inference tool with 3 rules of the following type: IF petal length small AND petal width
small, THEN iris belongs to class 1,
b) Use 3 membership functions for petal length (small, medium, large) and petal width (small, medium,
large). Use triangular-shaped functions. Use the max operator for defuzzification of the singleton
output; Hint: the compressed mf notation as shown in equation 2.19 in the text book may be useful.
c) Display the iris data displaying feature x1 vs. x2 using different markers for each class (blue, black, and
red stars for classes 1, 2, and 3, respectively) (2 points)
d) Display the result of the classification on the same plot using blue, black, and red circles, for found
classes 1, 2, and 3, respectively (4 points)
e) Display the membership functions on the same plot on the x-axis and y-axis; in particular, plot the
membership functions for the petal length on the x-axis, the membership functions for the petal width
on the y-axis; add a legend (4 points)
f) Count the total misclassifications and itemize as in the following example (note that the rows need to
add up to the number of samples for that particular class, i.e., 50)- (2 points):
Total misclassifications: 7
Class 1 found Class 2 found Class 3 found
Actual Class 1 50 0 0
Actual Class 2 0 47 3
Actual Class 3 0 4 46
g) Reason about the results; what could improve the results? (2 points)
h) For bonus points: implement suggested improvement and compare results (4 points)
Iris data can be downloaded from the class web site at:
http://www.cs.rpi.edu/courses/fall01/soft-computing/hw/iris2D.dat
An example graph is shown here
(minus the tick marks and mfs(x2)
labels): membership
x2 functions length small
length medium
length large
width small
width medium
width large
mfs(x1)
x1
2.) Use the linear regression algorithm described in class and chapter 5 of Jang to find a line, in the form y
= ax + b, that fits the data below. Hand in the formula for the line and the value of the line for x = 7. (1
point)
X Y
1 2
2 4
3 5
4 5
5 7
6 8
Predict the value of x = 7 for the above data using the smoothing algorithm f(x + 1) = a f(x) + (1 - a) y(x),
where a = .5. Assume f(1) = y(1) = 2. Hand in the value at x=7. (1 point)