Premium Project

Who's Tweeting? Trump or Trudeau?

Build a machine learning classifier that knows whether President Trump or Prime Minister Trudeau is tweeting!

Start Project
  • 8 tasks
  • 1,590 participants
  • 1,500 XP

Project Description

Now that you've completed Natural Language Processing Fundamentals in Python, let's get started with applying our knowledge of text to a new domain: Twitter. Tweets are notoriously difficult, as they are shorter than most texts and usually have hard-to-parse content like hashtags, mentions, links and emoji.

Despite the difficulties, tweets are fun content, so in this notebook we'll take a look at classifying two prominent North American politicians. Can we determine if it is Donald Trump or Justin Trudeau based on just a tweet? Let's see!

Project Tasks

  • 1Tweet classification: Trump vs. Trudeau
  • 2Transforming our collected data
  • 3Vectorize the tweets
  • 4Training a multinomial naive Bayes model
  • 5Evaluating our model using a confusion matrix
  • 6Trying out another classifier: Linear SVC
  • 7Introspecting our top model
  • 8Bonus: can you write a Trump or Trudeau tweet?
Katharine Jarmul

Founder, kjamistan

Katharine Jarmul runs a data analysis company called kjamistan that specializes in helping companies analyze data and training others on data analysis best practices, particularly with Python. She has been using Python for 8 years for a variety of data work -- including telling stories at major national newspapers, building large scale aggregation software, making decisions based on customer analytics, and marketing spend and advising new ventures on the competitive landscape.

See More


  • Python LogoPython
  • Topics

    Data ManipulationData VisualizationProbability & StatisticsImporting & Cleaning Data