\[P({\bf x}|\omega_i)=P({\bf x}|\mu_i,\sigma_i^2)\]
For example, using iris data, we first get the parameters of the setosa, versicolor and virginica class
load iris;
muset = mean(setosa);
muver=mean(versicolor);
muvir=mean(virginica);
covset=cov(setosa);
covver=cov(versicolor);
covvir=cov(virginica);
muset = mean(setosa);
muver=mean(versicolor);
muvir=mean(virginica);
covset=cov(setosa);
covver=cov(versicolor);
covvir=cov(virginica);
There are 50 samples from each class. Then, we test the iris classification into three classes.
X=[setosa;versicolor;virginica];
pset=mvnpdf(X,muset,covset);
pver=mvnpdf(X,muver,covver);
pvir=mvnpdf(X,muvir,covvir);
plot(pset,'b'), hold on;
plot(pver,'r');
plot(pvir,'g'); hold off;
The result is shown below (setosa, versicolor, virginica).
No comments:
Post a Comment