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 日

1 投票

"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 日

0 投票

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 日
Thanks again. Also I would like to know your opinion about the following matter.
As I said I have IMU data, simply put a file with acceleration, gyrometer readings, velocity, magentometer readings etc.
I plot my training data of 7 scenarios together and ask the user to select random two points, which is my sample.
Comparing classification strategies {to me} (as a beginner would like to know what others feel) is to show a confusion matrix and caluclate the cross validation error.
I have chosen the classify method and its variants, NaiveBayes but do you feel a decision tree makes sense in this context? I mean what decisions am I supposed to make? and I donot have any idea what the parameter 'names' is doing and how I can control it!!!
Please help.
Avishek Dutta
Avishek Dutta 2012 年 6 月 7 日
Hi, this is what I am doing for classregtree.
o1 = classregtree(training,group,'method','classification','names',{'Acc_X','Acc_Y','Acc_Z','Gyr_X','Gyr_Y','Gyr_Z','Mag_X','Mag_Y','Mag_Z','Roll','Pitch','Yaw','Vel_X','Vel_Y','Vel_Z'});
C = eval(o1,sample);
view(o1)
CM = confusionmat(sampleGroup,C);
I get this error,
??? Error using ==> confusionmat at 52
G and GHAT need to be the same type.
WHat am I doing wrong?
Ilya
Ilya 2012 年 6 月 7 日
Well, did you compare the size of sampleGroup and C?
Avishek Dutta
Avishek Dutta 2012 年 6 月 7 日
Well, they have the same size.
Ilya
Ilya 2012 年 6 月 7 日
Sorry, I mistyped. I meant - did you compare the type of sampleGroup and C?
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.

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

質問済み:

2012 年 6 月 7 日

コメント済み:

2014 年 11 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by