# How to make use of POS tags as useful features for a NaiveBayesClassifier for sentiment analysis?

I'm doing sentiment analysis on a twitter dataset (problem link). I have extracted the POS tags from the tweets and created tfidf vectors from the POS tags and used them as a feature (got accuracy of 65%). But I think, we can achieve a lot more with POS tags since they help to distinguish how a word is being used within the scope of a phrase. The model I'm training is MultnomialNB().

The problem I'm trying to solve is to find the sentiments of tweets like positive, negative or neutral.

### Created pos tags:

I created tfidf vectors from the tweet and gave the inputs to my model:

tfidf_vectorizer1 = TfidfVectorizer(
max_features=5000, min_df=2, max_df=0.9, ngram_range=(1,2))
train_pos = tfidf_vectorizer1.fit_transform(train_data['pos'])
test_pos = tfidf_vectorizer1.transform(test_data['pos'])

clf = MultinomialNB(alpha=0.1).fit(train_pos, train_labels)
predicted = clf.predict(test_pos)


With the above code I got 65% accuracy. Rather than creating TF-IDF vectors of POS and using them as modal inputs. I'm wondering is there any other way that we can use POS tags to increase the accuracy of the model?

• Hi @emily, thank you for your question. Can you provide how exactly you are implementing this model and can your edit your post to make more explicit what problem you are trying to solve? – shepan6 Jul 24 '20 at 9:09
• How about concatenating the word with the tag? It might be meaningful to distinguish whether the same word is being used as a noun or as a verb for example. Then you can use the same Bag of Words approach. Additionally, I would mention that if you want to use POS TAG separately and then using BoW you should use CountVectorizer instead of TfidfVectorizer; remember that the idea behind the later is to weight the most frequent words as less relevant across the documents but this is not the case in POS Tag since the fact that there are lots of verbs does not mean those are lees important. – Julio Jesus Aug 25 '20 at 20:02