You are on page 1of 1

Assignment 2

Generate a data set X1 with 400 vectors that stem from two classes. The classes are modeled
with m1=[-8 8]T and m2=[8 8]T and the covariance matrix is S=[0.3 1.5; 1.5 9.0];
1. Use the following lines of code to generate data. Use MATLAB function mean,
scatter_mat to develop a Fisher LDA classifier for the above data set.
randn(seed, 0);
S=[.3 1.5; 1.5 9];
mv=[-8 8; 8 8];
N=200;
x1=[mvnrnd(mv(:,1), S, N); mvnrnd(mv(:,2), S, N)];
y1=[ones(1, N), 2*ones(1, N)

2. Use the following lines of code to generate data. Use MATLAB function perce to
evaluate perceptron classifier for the data. Repeat the training 10 times and save the
models. Test the models and compare the classification performance
randn(seed, 0);
N=[100 100];
l=2;
x=[3 3];
X1=[2*rand(l, N(1)) 2*rand(l, N(2))+x*ones(1, N(2))];
X1=[X1; ones(1, sum(N))];

Repeat the line of code in red, bold font face to generate the remaining date set:
x=[2 2]; % for X2
x=[0 2]; % for X3
x=[1 1]; % for X4

3. Use the following lines of code to generate data. Use MATLAB function fitctree to
develop a decision tree classifier for the data set. Use view to display the tree and
prune the prune the tree, and predict to evaluate an example. Try a real data set
with load fisheriris;
rng(0,'twister') % for reproducibility
X = rand(100,1);
Y = (abs(X - .55) > .4);

You might also like