6CCS3PRE & 7CCSMPNN Pattern Recognition
Coursework Assignment 1
This coursework is assessed. A type-written report needs to be submitted online through KEATS
by the deadline specified on the module's KEATS webpage. Only include in your report the
information specifically requested below: this is indicated by underlined italicised text.
Part 0: Creating Personalised Data
To answer some of the questions in this coursework you will need to create a test dataset that is
unique to you. As the answers you get will depend on the test set you use, you must ensure that
you generate the test set correctly, otherwise your answers will be wrong!
To create this test set, Xtest, use your 7-digit KCL student ID (this is the number that appears on
your College ID card, it is NOT the k-number you use to log-into College computers).
Define s1, s2, s3, s4, s5, s6, s7 to be the 1st to 7th digits of your KCL student ID number, then
define Xtest using the following MATLAB code:
Stest=[s1, s2, s3, s4, s5, s6, s7; s2, s3, s4, s5, s6, s7, s1; s3, s4, s5, s6, s7, s1, s2; s4, s5, s6, s7, s1,
s2, s3];
Stest=bsxfun(@rdivide,Stest,[2.3;4;1.5;4]);
Xtest=bsxfun(@plus,Stest,[4;2;1;0]);
Hence, if your KCL student ID was 1234567, Xtest would be:
4.4348 4.8696 5.3043 5.7391 6.1739 6.6087 7.0435
2.5000 2.7500 3.0000 3.2500 3.5000 3.7500 2.2500
3.0000 3.6667 4.3333 5.0000 5.6667 1.6667 2.3333
1.0000 1.2500 1.5000 1.7500 0.2500 0.5000 0.7500
Each column of Xtest is a sample taken from a 4-dimensional feature-space.
In your report give your 7-digit KCL student ID, and report the values in the array Xtest.
Part 1: Bayesian Decision Theory and Density Estimation
Introduction
Download file cw1_parzen_density_est.m from the module's KEATS webpage. Execute this script
in MATLAB. The output shows the parzen density estimation of a univariate dataset. The density
estimation is repeated several times using progressively more data points. You will get slightly
different results each time you run this script, due to the different random samples that are
taken each time. However, in general, as the number of samples increases, so does the accuracy
of the estimate.
To perform parzen density estimation, the cw1_parzen_density_est script calls the inbuilt
MATLAB function “mvksdensity”. For 1-d data , if each sample is an element of a row vector “d”
then the parzen density estimate of the probability, p, that a new sample would have the value
dnew, is calculated using the command: p=mvksdensity(d’,dnew’)’
Note the transpose operator in MATLAB is written using an apostrophe (e.g. x’ is the transpose
of x). It is used in the command above, as the mvksdensity expects the number of rows in the
first two input arguments to equal the number of samples, and the number of columns to equal
the number of features. Type “help mvksdensity” at the MATLAB prompt to get a full description
of this function. In general, to get a description of any function in MATLAB, you can type “help
function_name” in the MATLAB command window. Alternatively, you can use the online
documentation available here: http://uk.mathworks.com/help/