GithubHelp home page GithubHelp logo

mateoias / trump_tweet_analysis Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 20.39 MB

An analysis and exploration of 4 years of Trump's tweets, including data cleaning, sentiment analysis and topic categorization with LDA and NMF.

License: MIT License

Jupyter Notebook 90.30% Python 9.70%
sentiment-analysis cleaning-data machine-learning trump-tweets topic-extraction

trump_tweet_analysis's Introduction

Trump Tweet Analysis

This project is an analysis of Donald Trump's tweets. I have parsed and organized the tweets to make them accessible and searchable for the user and done sentiment analysis and topic categorization to help look for trends in the tweets.

Tools/Packages Used:

  • sklearn.decomposition, sklearn.feature_extraction, sklearn.cluster
  • nltk.stem, nltk.corpus, nltk.tokenize
  • vaderSentiment
  • LatentDirichletAllocation
  • NMF
  • KMeans
  • wordcloud
  • textblob
  • pandas
  • time
  • matplotlib
  • scipy.stats
  • plotly

Datasets

This project is based on the complete set of Trump's tweets taken from the trump twitter archive (http://www.trumptwitterarchive.com/archive) and extending to the point at which he was banned by twitter.

Sentiment analysis

I ran a variety of sentiment analysis algorithms, including textblob, Naive Bayes and Vader. Vader was the most effective so I created a new dataset including Vader sentiment scores. Then I built an exploratory interface where a user can graph different aspects of the data and look for patterns. For example, plotting the tweet sentiment for some set of search terms over time (see user_searchable_tweet_dataframe.py).

Topic categorization

Finally, I did topic categorization of the tweets, looking to find a connection between the words Trump used that would help in understanding the data. The topic categorization required much more data cleaning (see build_clean_tweet_dataframe.py). In this step I also calculated term frequency and created a dictionary of vocabulary used (tweet_dictionary_maker.py). For the topic categorization I used LDA and NMF to create clusters of words looking for underlying patterns of terms that would help in analyzing the texts. See NMF_topic_categorizer.py for results. I finally wrote a word cloud creating function that allows the user to see what words are most strongly assosciated with each topic (create_word_cloud_by_topic.py).

trump_tweet_analysis's People

Contributors

mateoias avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ajjumaxy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.