

% IN ORDER TO RUN THIS EXAMPLE, LOAD THE DATASET FIRST USING THE COMMAND BELOW
% uiimport('diabetes_no_attribute_names.dat');
% This creates three matrices:
% data: containing the data instances
% rowheaders: containing the class labels
% textdata: containing all textdata (in this case same as class labels) as the dataset is numeric.


nb = NaiveBayes.fit(data,rowheaders);
% creates a Naive Bayes model, nb.
nb
% shows info about nb

cpre = predict(nb,data);
% makes prediction using the Naive Bayes model nb over the training data, called data.
cpre
% shows the predictions

[post,cpre1,logp] = posterior(nb,data);
% [post,cpre,logp] = posterior(nb,test) returns logp, an N-by-1 vector containing estimates of the log of the probability density function (PDF). logp(i) is the log of the PDF of point i. The PDF value of point i is the sum of Prob(point I | class J) * Pr{class J} taken over all classes. 
cpre1
% shows the predictions
logp
% shows the logp
post
% shows the posterior probabilities

