Naive Bayes

1 回表示 (過去 30 日間)
Avishek Dutta
Avishek Dutta 2012 年 6 月 7 日
コメント済み: Abrham Debasu 2014 年 11 月 18 日
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

採用された回答

Ilya
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".
  2 件のコメント
Avishek Dutta
Avishek Dutta 2012 年 6 月 7 日
Thanks, it worked. Can you also guide me as to how to do the same with Decesion Tree. And how to visualise the classification?
I am a bit unclear about what is said in the help. It seems to me if I do something like
t = classregtree(training, group); % i didnot understant the 'names' parameter.
It give me a tree of the already classified data. How can I then use it to locate/predict my sample.
Abrham Debasu
Abrham Debasu 2014 年 11 月 18 日
Thanks this is very helpfull

サインインしてコメントする。

その他の回答 (1 件)

Ilya
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 件のコメント
Avishek Dutta
Avishek Dutta 2012 年 6 月 7 日
Right on, found it eval gives 'cell ' and my sampleGroup was double. Got around it.
Will still like to hear what you/people have to say about my other comment (about choice of classification schemes)..!!
Many thanks.
P.S. I need help with un-supervised classification now.
http://www.mathworks.in/matlabcentral/answers/40587-k-means-clustering
Ilya
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 ExchangeNaive Bayes についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by