You are on page 1of 2

Naive Bayes Algorithm for Predictive

modelling

Naive Bayes algorithm works on conditional probability i.e.

Formula

Where p(Ck|x) Is the probability


whethere the tweet has positive/negative
sentiment
P(Ck) Probability of Negative/Positive
dataframe
P(x|Ck) Probability of every word in tweet
as positive or negative

Where K positive negative


P(xi|Ck) probability of bag of words
P(x1,x2,x3,x4)
Sentiment with highest probability value
will be selected

Logic behind the Model

ppose weve trained the model using a excel file containing 10 tweets which con
tive tweets and 7 negative tweets.

bility (Positive tweets) = 0.3


bility (Negative tweets) =0.7
uppose out tweet is I had an awesome experience.
uppose the strings in this particular tweet are represented by x1, x2, x3, x4, x5.

bility (Pos/strings of data(say x1 x2 x3 x4 x5)) =


*P(x1/pos)*P(x2/pos)*P(x3/pos)*P(x4/pos)*P(x5/pos) ----------------------- 1

bility (Neg/strings of data(say x1 x2 x3 x4 x5)) =


*P(x1/neg)*P(x2/neg)*P(x3/neg)*P(x4/neg)*P(x5/neg) --------------------- 2

Where Nk No of time x1 repeated in positive dataframe repos


N Total number of words in positive dataframe repository incl
D Total distinct words including positive & negative database

, the text will be classified as a positive one and if otherwise, negative tweet.

You might also like