%Image Features Classification addpath(genpath('/Users/manalhelal/Dropbox/AAST/undergrad/F2014/CC716')); clear all; load images_2; imagesMat = images_2; %file containing rows of 52 images, and columns of 57 features %create the Euclidian distance matrix D = pdist(imagesMat); %create the Agglomerative hierarchical cluster tree Z = linkage(D); %cluster the images into 6 classes C = cluster(Z,'maxclust',6); %create the NB Classifier model using only the first 8 features, because the within-class variance of features 9, 21, 24, 50 in class 1 are not positive, and it should be positive for Naive Bayes classifier to work NBModel = fitNaiveBayes(imagesMat(:, 1:8),C); %using the generated model, predict the class of image 50, using the same %features pre = predict(NBModel,imagesMat(50, 1:8)); %return the posterioir probability of the same image to all classes, and %the log of the [post,cpre,logp] = posterior(NBModel,imagesMat(50, 1:8)); %draw the 3d scatter plot of the first three features of the images using %circle size 10, and colouring based on the assigned classes to visualise %the distribution. scatter3(imagesMat(:, 1), imagesMat(:, 2), imagesMat(:, 3), 10, C); % read the estimates of the class, the mean and the standard deviation of % the predicted class estimates = NBModel.Params{pre,1};