Graphing Live Twitter Sentiment – Language Processing With Python and NLTK p.21


Video is ready, Click Here to View ×

For a current conclusion to this series, we go ahead and graph our basic sentiment analysis results to a live Matplotlib graph.

Playlist link:

sample code:

43 thoughts on “Graphing Live Twitter Sentiment – Language Processing With Python and NLTK p.21

  1. An advice here: when you wrote the "" program you choose to select only adjectives. I tried to check in every tweet if there is at least one adjective in it, then I just let the program to do its job. This way I got bigger accuracy with example "obama", so wasn't almost everything negative. Anyways, thank you for teaching us all this, amazing series!

  2. Really great content, been watching your NLTK series – just great to follow along!

    I ran into a problem with live graphing though, somehow I keep getting an error:
    ModuleNotFoundError: No module named 'matplotlib' or ModuleNotFoundError: No module named 'style'

    Has anyone else run into the same or similar problem?
    all google searches so far couldnt really help.
    any help much appreciated!

  3. Hats off man !!!!!!!! That was simply amazing. I enjoyed your tutorials a lot. I am working on sentiment analysis …..can you please help me in getting the api's of amazon / flipkart and use them for sentiment analysis.

  4. Love your tutorial so much!! I have finished this tutorial and for the last part twitter sentiment analysis, can I do that for a specific period of time? for instance, I want to know what do people think of Obama only in June, 2017? Can this task be accomplished by the tweepy module? Thanks!

  5. +Sentdex I love this series. I kind of cannot fine this in any of the files featuresets.pickle. Could you point me to the file that created "pickled_algos/featuresets.pickle", "wb". Thanks for the works.

  6. Hello, i liked all the tutorials but when i stream live twitter i got this error

    raise ProtocolError('Connection broken: %r' % e, e)

    ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

    Has any one got this ?

    Thank you

  7. I seem to only be able to run one program at once – when I try to run the twitter stream my graphing program closes and vice versa and so my graph is not live. Any ideas on how to fix this?

  8. My favorite series so far! I'm using OS X/Terminal. What's the best way to disconnect from the Twitter feed? I've been using Control-C. Also gets a bit glitchy trying to exit the graph. I have to use Control-Z and then Control-C. Are there better ways?

  9. I didn't use pickle. My code runs fine. But it gets stuck after streaming just one tweet and gives the following error. Please help. And thanks a ton for these videos !!

    NuSVC_classifier accuracy percent: 59.78915662650602
    RT @MarkMahon: Weekend Actuals: #BooAMadeaHalloween – $17.2M, #Inferno – $14.8M, #JackReacher2 – $9.6M, #TheAccountant – $8.4M & #TheGirlOn… neg 0.8

    Traceback (most recent call last):
    File "/Users/shivaligoel/Documents/", line 43, in <module>
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tweepy/", line 445, in filter
    File "/Users/shivaligoel/Documents/", line 25, in on_data
    output = open(twitter-out.txt,"a")
    NameError: name 'twitter' is not defined

  10. Seriously you rock buddy loved your tutorials
    I started watching NLTK tutorials because I want to build a chat bot for starter and a really good thing later on.
    Can you suggest anything related to chat bot where to start and how to improvise. It would be really helpful thank you for making this series. Please keep posting

  11. Great Tutorial. I'm new on this stuff with python and nltk. now I am working on a project that the main purpose is to try to predicte a best user to assign a ticket based on the descriptions of ticket historical data, and also implement a machine learning app to feed the model every time a ticket is closed (it's suppose closed for the best user to resolve it) . at the beginning I tried to do it with SQL creating a dictionary with the split by noun phrases but with machine learning the idea is to pass a vector space. I would like you to guide me what it would be the stpes that I have to follow to do this project. Initiatlly, I think that I have to tokenize the descriptions of each ticket with the user who closed it and then train and test the data, but to implementing with a machine learning, I don't know how to do it. Maybe I am not on the right direction. I hope you can help me on that. thanks in advance

  12. A great series on NLTK. Loved it!

    Quick Question:
    Can you suggest some ways to make the system adaptive? There might be a possibility when we are required to analyze a tweet that contains word(s) which are not included in our training set? Is there any way to make system find the probability of the new word(s) that are not included in our corpus.

  13. I did the try and except thing.
    (just like in the vid)
    except Except as e:
    return True

    and when I run it, it gives me an error:  " 'UCS-2' codec can't encode characters in position 80-80: Non-BMP character not supported in Tk."
    Not sure what error it is, but after I google it. It is something about the encoding in twitter api. (refer to this linK:
    Not sure whether it helps or not.

Leave a Reply

Your email address will not be published. Required fields are marked *