Getting scores in Naive Bayes and Support Vector Machine

7 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Brendan Hamm
Brendan Hamm am 12 Jan. 2016
Bearbeitet: Brendan Hamm am 12 Jan. 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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by