I'd like to perform sentiment analysis on stock comment using scikit and nltk. I already have about 100 comments on different stocks like "this stock will rock" which I marked as positive (1) or "this is doomed stock" which I marked as negative(0). So I'd like to train classifier which can tell whether new comments I add are negative or positive. So my question is how to perform it. I've already searched the Net but all I found was movie review sentiment analysis which is quite remote from the topic.


1 Answer 1


What you're doing right now is a traditional classification using supervised learning. This is a great method for predicting outcomes, but I suspect there are much better ways to complete this sentiment analysis project you're working on.

Without knowing what the goal of your analysis is, I would suggest you look at the NLTK package. A lot of work has been done to idenify how positive or negative a collection of words is, and you could piggyback on the work of some really smart people.

If you're having trouble starting, you can look at NLTK's how-to tutorial, some Kaggle kernels, or find some articles online.

Good luck!

  • $\begingroup$ I'have already took some NLTK courses, and someone suggested trying VADER. As fro NLTK, I tried to do something similar to movie review like finding out how each sentiment is negative/positive, but then I got stuck in this project. Also, it seems to me that ML approach is more perspective and beneficial. $\endgroup$
    – nikitok56
    Oct 15, 2018 at 17:24
  • $\begingroup$ What might be more what you're looking to do is predict a score based on the sentiment of a review. Maybe you can look at the sentiment of the movie review and try to predict the score given by that user (if that data is available). It seems like you're trying to predict sentiment, when it's something you can easily discern from the information available. Now, if you want to create a custom sentiment score (using slang for example), then that's another task. You'd need to build a dictionary of words and associate a score with each word. $\endgroup$ Oct 16, 2018 at 13:19
  • $\begingroup$ Thanks a lot! Yeah, I used easy sentiments such as "good/bad" but I'd like to use these training set applied to a massive of sophisticated sentiments. So you suggesting me collecting words and make score as a value? I understand that it can be done this way but I thought there can be another solution without giving each word a score? $\endgroup$
    – nikitok56
    Oct 21, 2018 at 7:45
  • $\begingroup$ I'd recommend you do a little more research on what's already out there. From what I can tell, you're trying to reinvent the wheel. Read up on lexicons. These are 'word score' score databases. There are some that look at unigrams (single words), others look at bigrams, or trigrams. If you really need to, you can add onto these lexicons with your own words, but I expect this will suffice. $\endgroup$ Oct 22, 2018 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.