Matthew Gray

MAS.622 Problem Set 5 April 22, 1998

Problem 1

Using Parzen Windows, an evidence curve for a range of values of h was found using the following Matlab code. The evidence curve for class 1 appears in Figure 1 and for class 2 in Figure 2.

train = train1;
gn = 1./(sqrt(2*pi));
for hct = 1:100
h = hct/50;
lpsum = 0;
for lo = 1:20
x = train(lo);
density = 0;
for s = 1:20
if(s ~= lo)
density = density + (gn./h)*exp(((-1/2).*(train(s)-x).^2)./(h*h));
end
end
lpsum = lpsum + log(density);
end
v(hct) = lpsum/20;
hv(hct) = h;
end

Picking 3 values of h from different parts of the curve, we’ll use .03 .48 and 2.0 for class 1, and .03, .8 and 2.5 for class 2. These density estimates appear in Figures 3, 4, 5, 6, 7, and 8 respectively and were determined using the following Matlab code.

gn = 1./(sqrt(2*pi));
train = train1;
h = .48;
density = zeros(100,1);
for xct = 1:100
x = xct/10;
for s = 1:20
density(xct) = density(xct) + (gn./h)*exp(((-1/2).*(train(s)-x).^2)./(h*h));
xv(xct) = x;
end
end

Figure 1: Evidence curve for class 1 for varying values of h Figure 2: Evidence curve for class 2 for varying values of h Figure 3: Class 1 Density estimate, h = .03 Figure 4: Class 1 Density estimate, h = .48 Figure 5: Class 1 Density estimate, h = 2.0 Figure 6: Class 2 Density estimate, h = .03 Figure 7: Class 2 Density estimate, h = .8 Figure 8: Class 2 Density estimate, h = 2.5 Using these densities to obtain a minimum error rate classifier yields a classifier that misclassifies test samples 22.5% of the time for samples actually in class 2 and 21% of the time for samples actually in class 1.