# What is the Best and easiest way to create a Classifer for Sentiment Analysis [closed]

Sentiment analysis using Machine Learning is a hot topic. In the present situation when a person doesn't have a problem in having the training data set then which way should we create the classifier possibly the NaiveBayes classifier?

This isn't the best way but it's simple and fast:

• preprocess the input with the Porter Stemmming algorithm (it's a process for removing the commoner morphological and inflexional endings from words in English) or similar (take a look at Snowball)
• preprocess the input flagging words before and after every negation ("never", "not", "no", "n't"):

the movie was not great => the movie ¬was not ¬great

• Use Bernoulli Naïve Bayes (duplicate words are removed from the document and given a class, positive or negative, you assume that the words are conditionally independent of each other): $$P(C_j | D) = \frac{\prod_i P(x_i | C_j) P(C_j)}{P(D)}$$

$$P(x_i | C_j) = \frac{count\ of\ x_i\ in\ documents\ of\ class\ C_j}{total\ number\ of\ words\ in\ documents\ of\ class\ C_j}$$ ($x_i$ are the individual words of the document $D$)

You can also use Laplacian smoothing to avoid problems if the classifier encounters a word that hasn't been seen in the training set:

$$P(x_i | C_j) = \frac{1 + count\ of\ x_i\ in\ documents\ of\ class\ C_j}{2 (total\ number\ of\ words\ in\ documents\ of\ class\ C_j)}$$

This works quite well.

Further steps are feature selection (removing redundant features, while retaining those features that have high disambiguation capabilities) and the use of ngrams (e.g. Fast and accurate sentiment classification using an enhanced Naive Bayes model by Vivek Narayanan, Ishan Arora, Arjun Bhatia).