# Naive Bayes in text classification - Only classifying “0”

I have a data set of 1000 Amazon "art" category reviews. I want to classify Positive +1, Negative -1, Neutral 0 Ratings using user reviews. The final Naive Bayes classifier only predicts 0 for all training sample. I will write my process of building the classifier and want to know why it's failing to classify other classes.

1. Find all unique words in the 1000 reviews and stem the words (ex: pleased, pleasing -> please).
2. Build Feature matrix (1000 X Size of Unique words vector) where each element is # of times the unique word appears in the document
3. By-row operation multiply by idf -> A 1 X (# of Unique words vector). (# of Documents / # of documents word (i) appears)
4. Set Y as 3 factors (-1,0 or 1) 1000 X 1
5. Train and predict

Results:

                actual
predicted  -1   0   1
-1   0   0   0
0  150  92 758
1   0   0   0


Am I missing something in the mix? I will post code if requested but I believe my processes are done correctly.

• What implementation of Naive Bayes are you using? Is it built to deal with continuous data like your tf-idf matrix? – Ben Kuhn Mar 22 '15 at 6:36
• The NaiveBayes function assumes normal distribution. Since the raw frequency of each sample is multiplied by idf, it loses its discrete property and becomes continuous. – Kevin Pei Mar 22 '15 at 13:34

dtm <- DocumentTermMatrix(data, control = list(weighting = function(x) weightTfIdf(x, normalize = TRUE)))