MATLAB Answers

Want to confirm that how to mainly train and predict class from new testing features

1 view (last 30 days)
SUNNY NEGI on 10 Nov 2019
Hi, I am working on supervised training and testing. There are few changes in previous commands. I want to be assured that is it ok to use following pair of commands to train and predict the model for different classifier?
For Naive Bayes:
Mdl = fitcnb(Training,Group)
Class = predict(Mdl,Sample);
For kNN:
Mdl = fitcknn(Training,Group,'NumNeighbors',k);
Class = predict(Mdl,Sample);
For LDA:
Mdl = fitcdiscr(Training,Group);
Class = predict(Mdl,Sample);
For SVM:
Mdl = fitcecoc(Training,Group)
Class = predict(Mdl,Sample);
and so on...
Is it OK to use these syntax for training a model and then predict class for unknown Sample? And then comapre Class with trueclass for calculating classification accuracy?
Kindly provide me easiest way to train and test a model..

Answers (0)

Community Treasure Hunt

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

Start Hunting!