Detection and Pattern Recognition: Matlab: 1 Supervised Classification
Detection and Pattern Recognition: Matlab: 1 Supervised Classification
Contents
1 Supervised Classification
1.1 Mean Classifier . . . . .
1.2 Mahalanobis distance . .
1.3 XOR Feature Transform
1.4 Feature Normalization .
1.5 Hard Margin SVM . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
1
2
2
3
1 Supervised Classification
1.1 Mean Classifier
Use the protoype provided to implement a mean classifier using the euqlidian distance.
(a) Compute the mean i for every class i , i = 1, . . . , C by using the training examples.
(b) Compute the distance from each sample to each class mean.
(c) Asign the class label with the nearest mean as the prediction for every sample.
Apply the created mean classifer to the first Set of the lecture which uses two different gaussians
for the classes.
(d) Create a dataset of type 1 by the call DATA = Set1_data(N) with N = 1e3.
(e) Compute the error rate of the mean classifier for different training set sizes, i.e N =
10, 20, 30, . . . , 200, by using the extract_subset and generate_error_rate functions.
(f) Repeat the provious task 100 times to compute the mean and standart deviation of the error
rate for every training set size.
(g) Plot the mean and standart deviation of the training set size using the errorbar function and
discuss the results.
rs
sr rs
rs
rs
rs
rs rs
rs sr
rs
bc
bc
rs
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc
rs
rs
bc
bc
bc
rs
bc
bc
bc
bc
bc
bc
bc
rs
bc
rs
rs
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc
bc bc
bc
bc
rs
rs
rs
rs
rs
rs
rs
rs
rs
rs
rs sr
rs rs
rs
rs
bc
rs
(g) Compute the normal w and offset b by using the realationship f = Xw + 1w0 .
(h) Compute the margin using the support vectors.
(i) Draw the hyperplanes wT x + w0 = 0, wT x + w0 = 1 and wt x + w0 = 1 into the previously
created figure using the hold on; option.