Liwen Duan's Logo
Article

Twitter Analysis Program

This is the final project for my IST 256, Applied Programing for Information Systems course. The intention of this program is to help you understand the current Twitter trend. The program was built using Python/ Jupyter Notebook.

You can view code and project documents on GitHub

This project is a group project, collaborating with my friend Chen Chaofan .

This project was built using Jupyter notebook, a python based ’notebook’ that are really good for data analytic, visualization, and research purpose. Basically what this program does is to help users to know the latest Twitter trends, and we will bring users to view those tweets.

There are two things we have tried on this program that is a little bit more than what we learned during the course. One is to modulize each function so it makes the final document look clean, and the code can be reused. The other is to utilize a library called ‘webbrowser’ to create some level of interaction for our users.

The flow behind the hood

  1. We get the trend of a location that Twitter provides, sorted by tweet volume
  2. Users can choose a topic they are interested in
  3. Then we will get tweets from Twitter, do some sentiment analysis
  4. We will provide an opportunity to let users view the tweet on Twitter.com

What python library, API, and environment we used

We build the program on Jupyter Notebook, the environment we used during the course.

API and Python Library List:

  • import_ipynb

    This library help me to separate all functions we used from the main program, make the code look clean.

  • tweepy

    Tweepy is a great third-party Twitter API library used on python.

  • pandas

    Pandas is a great data analysis tool, the DataFrame of pandas is easy to use and good for our purposes

  • ipywidgets

    This library helps us to have user interaction within the Jupiter notebook environment, create buttons, and dropdown lists.

  • IPython

    This library helps us to present multiple contents in the same output at once.

  • webbrowser

    This API helps us to get you from the program to a webpage. It is Work on Windows computers, but not on macOS for some reason...

  • matplotlib

    This is how we generate sentiment analysis on a pie chart

  • Sentiment Analysis API from http://text-processing.com

    This is the Sentiment analysis API we used

How to use it (If you really want)

Before you start, there are a few things you need to have. Jupyter Notebook environment, which you can find it via Anaconda. You also want to get a Twitter API Token.

We want to make the process straight forward as possible. First, download or clone the repository.

Go into the ’Program’ folder.

To ensure everything will work flawlessly, we have created a Jupyter Notebook document called 'Environment installation’. You can open it and run all the code blocks.

If everything checks out, you can move on to ’The Program’, and run all the code blocks. You now will follow the instruction as prompted.