I'm writing a OOP on Matlab, a naive bayes for separating email. Like this
classdef NaiveClass
%NaiveClass what this will do is hold on his emails
% the p(message|class) compute the probability
% have the specific class info as well as who are they brothers
%
properties
name
numberOfMail
laplaceCounts
uniqueWords
totalMails
totalWords
likelihoodGivenClass
prior
end
methods
function identify(thisNaiveClass)
disp('I''m a bayes node')
end
function set = setPrior(obj)
obj.prior = (obj.numberOfMail + 1) / (obj.totalMails + obj.laplaceCounts)
end
function like = setLikelihood(this)
this.likelihoodGivenClass = (1 + 1) / (this.totalWords + 17)
end
end
end
But every time I call the function setPrior or setLikelihood the previous vaule get deleted from the other, the likelihood or the prior, like this:
>> setLikelihood(bayes)
this =
NaiveClass
Properties:
name: 'Primary'
numberOfMail: 3
laplaceCounts: 4
uniqueWords: []
totalMails: 12
totalWords: 8
likelihoodGivenClass: 2/25
prior: []
Methods
And then the other call:
setPrior(bayes)
obj =
NaiveClass
Properties:
name: 'Primary'
numberOfMail: 3
laplaceCounts: 4
uniqueWords: []
totalMails: 12
totalWords: 8
likelihoodGivenClass: []
prior: 1/4
Methods
So what is this? Thanks.