Getting scores in Naive Bayes and Support Vector Machine
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Elizabeth Vieira
il 12 Gen 2016
Commentato: Elizabeth Vieira
il 14 Gen 2016
I am using Naive Bayes and Support Vector Machine in a dataset with a binary dependent variable. I am using MatlabR2015a. I would like to get the scores when I use ScoreTransform equal to none and ScoreTransform with logit. I did some research on the subject, but I did not get results. How can I access to the scores?
Thanks in advance!
Elizabeth Vieira
0 Commenti
Risposta accettata
Brendan Hamm
il 12 Gen 2016
Modificato: Brendan Hamm
il 12 Gen 2016
The scores are only the result from using the predict method of the aforementioned classes. They are the second output referred to as posterior.
% Load data
load fisheriris
X = meas(:,3:4);
Y = categorical(species); % 3 classes
% Remove versicolor so we have binary decision
idx = Y == 'versicolor';
X = X(~idx,:);
Y = Y(~idx,:);
Y = removecats(Y,'versicolor');
% Create a Binary Naive Bayes model w/ and w/out the score transform:
Mdl1 = fitcnb(X,Y);
Mdl2 = fitcnb(X,Y,'ScoreTransform','logit');
[grp1,score1,cost1] = predict(Mdl1,X);
[grp2,score2,cost2] = predict(Mdl2,X);
% Notice score1 has probabilities, score2 has been transformed using the logit function:
% logit(x) = 1/(1+exp(-x))
% The inverse logit is:
% ilogit(x) = -log(1/x-1);
score2Trans = -log(1./score2-1);
% Are these the same?
any(abs(score1 - score2Trans) > eps)
% voila score2Trans is within machine precision of score1.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Naive Bayes in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!