Question
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
John Williams
PhD Expert
Answered Sep 12, 2026
"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".
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related AI Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →