Getting scores in Naive Bayes and Support Vector Machine
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Elizabeth Vieira
el 12 de En. de 2016
Comentada: Elizabeth Vieira
el 14 de En. de 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 comentarios
Respuesta aceptada
Brendan Hamm
el 12 de En. de 2016
Editada: Brendan Hamm
el 12 de En. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Naive Bayes en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!