Estimating joint density directly from the joint density table requires intensive computation, especially with large dataset.
To implement a Naive Bayes classifier in Matlab, two separate functions could be developed: nb_train and nb_test. The nb_train() function takes in training dataset x and y, with each row of x represents the feature vector of one training instance and the corresponding row in y contains the class label for that instance. The computed conditional probabilities matrices as well as class priors should be put together inside a model struct as the return value. Information retrieved from the model struct is applied on the testing data points to calculate the probability of belonging to each class. The class label is determined as the one with the highest probability. |
Monday, October 5, 2015
Implement Naive Bayes Classifier with Matlab
Labels:
Matlab,
Naive Bayes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment