How to train a Naive Bayes classifier?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a dataset which looks like this:
I need to use a Naive Bayes classifier to classify these rows (observations) by Category- 'unvoiced' and 'voiced'. I was looking some examples on fisheriris dataset but it didn't work. I would appreciate if someone could give me some hint or with what to start. I separated dataset into dataTesting (for testing) and dataTraining (for training the classifier).
0 件のコメント
回答 (1 件)
Don Mathis
2017 年 4 月 11 日
編集済み: Don Mathis
2017 年 4 月 11 日
How about this?
% Make a synthetic dataset
STE = rand(84,1)*20;
ZCR = randi(900,84,1);
Category = [repmat({'unvoiced'},42,1); repmat({'voiced'},42,1)];
STE(1:42) = 15 + STE(1:42); % Make class 1 different so there's something to learn.
D = dataset(STE, ZCR, Category);
% Note: You should convert your dataset to 'Table' because dataset is deprecated:
T = dataset2table(D);
% You could have created a table directly like this: T = table(STE, ZCR, Category);
% Fit naive bayes model
model = fitcnb(T, 'Category')
% Compute cross-validated error. Chance misclassification rate would be 0.5
MisclassificationRate = kfoldLoss(crossval(model, 'KFold', 10))
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Classification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!