Naive Bayes

Illustration
Avishek Dutta - 2022-06-13T15:53:41+00:00
Question: Naive Bayes

Being a beginner I am facing great confusion regarding the NaiveBayes classifier.   The examples I see are like this   O1 = NaiveBayes.fit(meas,species); C1 = O1.predict(meas); cMat1 = confusionmat(species,C1) Or nbGau= NaiveBayes.fit(meas(:,1:2), species); nbGauClass= nbGau.predict(meas(:,1:2)); Always the function is taking two inputs. My task is to compare different classification methods on IMU data. I have seven scenarios like walk, run, stairup etc. I have a sample data which is an extract of my full training data (extracted randomly from the plot by selecting 2 points) i.e. data of all 7 scenarios combined together.   Using classify(sample,training,group) I am getting good results. But for NaiveBayes I have no option to include this sample data as input.  

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

"training" is used to train a classifier (pass it to FIT method), and "sample" is used to test the classifier performance on data not used for training (pass it to PREDICT method). for example:

 

O1 = NaiveBayes.fit(training,group);
C1 = O1.predict(sample);
cMat1 = confusionmat(sampleGroup,C1);

where sampleGroup is an array of true class labels for the predictor matrix in "sample".


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!