Naive Bayes
2 次查看(过去 30 天)
显示 更早的评论
Hi all,
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.
Am I missing something basic?
Please Help.
Avishek
0 个评论
采纳的回答
Ilya
2012-6-7
"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".
更多回答(1 个)
Ilya
2012-6-7
If you use ClassificationTree introduced in 2011a, you can use the same syntax with FIT and PREDICT. If you use classregtree, use EVAL method to predict.
You can run methods(obj) and properties(obj) on any object such as classregtree or NaiveBayes to see a list of all its methods and properties.For instance,
methods(t)
would give you a long list with EVAL on it.
7 个评论
Ilya
2012-6-7
If you care only about the classification accuracy, use any classifier you like and measure its accuracy by cross-validation or using an independent set. Ensemble techniques such as TreeBagger introduced in 2009a or fitensemble introduced in 2011a tend to be very powerful and versatile (work on data of many kinds); all in Statistics Toolbox. You can try k-NN classification in Stats. There are neural nets in Neural Net Tlbx and SVM in Bioinformatics Tlbx.
If you need a classifier with an interpretable structure, go with something simple such as LDA, NaiveBayes or decision tree.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Naive Bayes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!