diff --git a/your-code/challenge-1_ines.ipynb b/your-code/challenge-1_ines.ipynb
new file mode 100644
index 0000000..3676f0a
--- /dev/null
+++ b/your-code/challenge-1_ines.ipynb
@@ -0,0 +1,354 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Challenge 1: Prepare Textual Data for Analysis\n",
+ "\n",
+ "In this challenge, we will walk you through how to prepare raw text data for NLP analysis. Due to time limitation, we will cover **text cleaning, tokenization, stemming, lemmatization, and stop words removal** but skip POS tags, named entity recognition, and trunking. The latter 3 steps are more advanced and not required for our next challenge on sentiment analysis. \n",
+ "\n",
+ "## Objectives\n",
+ "\n",
+ "* Learn how to prepare text data for NLP analysis in Python\n",
+ "* Write the functions you will use in Challenge 3 for cleaning, tokenizing, stemming, and lemmatizing data."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Text Cleaning\n",
+ "\n",
+ "Text cleaning is also called text cleansing. The goal is to clean up the messy real-world textual data in order to improve the text analysis accuracy at later steps. For generic textual data sources, we usually need to fix the following problems:\n",
+ "\n",
+ "* Missing values\n",
+ "* Special characters\n",
+ "* Numbers\n",
+ "\n",
+ "For web data, we need to additinally fix:\n",
+ "\n",
+ "* HTML tags\n",
+ "* JavaScripts\n",
+ "* CSS\n",
+ "* URLs\n",
+ "\n",
+ "Case by case, there may also be special problems we need to fix for certain types of data. For instance, for Twitter tweets data we need to fix hashtags and the Twitter handler including a *@* sign and Twitter usernames.\n",
+ "\n",
+ "In addition, we also need to convert the texts to lower cases so that when we anaylize the words later, NLTK will not think *Ironhack* and *ironhack* mean different things.\n",
+ "\n",
+ "Note that the above are the general steps to clean up data for NLP analysis. In specific cases, not all those steps apply. For example, if you are analyzing textual data on history, you probably don't want to remove numbers because numbers (such as years and dates) are important in history. Besides, if you are doing something like network analysis on web data, you may want to retain hyperlinks so that you will be able to extract the outbounding links in the next steps. Sometimes you may also need to do some cleaning first, then extract some features, then do more cleaning, then extract more features. You'll have to make these judgments by yourself case by case. \n",
+ "\n",
+ "In this challenge we are keeping things relatively simple so **you only need to clean up special characters, numbers, and URLs**. Let's say you have the following messy string to clean up:\n",
+ "\n",
+ "```\n",
+ "@Ironhack's-#Q website 776-is http://ironhack.com [(2018)]\")\n",
+ "```\n",
+ "\n",
+ "You will write a function, which will be part of you NLP analysis pipeline in the next challenge, to clean up strings like above and output:\n",
+ "\n",
+ "```\n",
+ "ironhack s q website is\n",
+ "```\n",
+ "\n",
+ "**In the cell below, write a function called `clean_up`**. Test your function with the above string and make sure you receive the expected output.\n",
+ "\n",
+ "*Notes:*\n",
+ "\n",
+ "* Use regular expressions to identify URL patterns and remove URLs.\n",
+ "\n",
+ "* You don't want to replace special characters/numbers with an empty string. Because that will join words that shouldn't be joined. For instance, if you replace the `'` in `you're`, you will get `youre` which is undesirable. So instead, replace special characters and numbers with a whitespace.\n",
+ "\n",
+ "* The order matters in terms of what to clean before others. For example, if you clean special characters before URLs, it will be difficult to identify the URLs patterns.\n",
+ "\n",
+ "* Don't worry about single letters and multiple whitespaces in your returned string. In our next steps those issues will be fixed."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import re\n",
+ "\n",
+ "\n",
+ "def clean_up(s):\n",
+ "\n",
+ " # Remove numbers\n",
+ " s = re.sub(r'\\d', '', s)\n",
+ "\n",
+ " # Remove URLs\n",
+ " s = re.sub(r'http\\S+|www\\S+', '', s)\n",
+ "\n",
+ " # Remove special characters and convert to lowercase\n",
+ " s = re.sub(r\"[@#\\-[\\](){}']\", ' ', s).lower()\n",
+ "\n",
+ " # Remove extra spaces and strip leading/trailing spaces\n",
+ " s = re.sub(r'\\s+', ' ', s).strip()\n",
+ "\n",
+ "\n",
+ " return s"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ironhack s q website is\n"
+ ]
+ }
+ ],
+ "source": [
+ "input_string = \"@Ironhack's-#Q website 776-is http://ironhack.com [(2018)]\"\n",
+ "cleaned_string = clean_up(input_string)\n",
+ "print(cleaned_string)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Tokenization\n",
+ "\n",
+ "We have actually discussed the concept of tokenization in the Bag of Words lab before. In that lab, we did both tokenization and calculated the [matrix of document-term frequency](https://en.wikipedia.org/wiki/Document-term_matrix). In this lab, we only need tokenization.\n",
+ "\n",
+ "In the cell below, write a function called **`tokenize`** to convert a string to a list of words. We'll use the string we received in the previous step *`ironhack s q website is`* to test your function. Your function shoud return:\n",
+ "\n",
+ "```python\n",
+ "['ironhack', 's', 'q', 'website', 'is']\n",
+ "```\n",
+ "\n",
+ "*Hint: use the `word_tokenize` function in NLTK.*"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package punkt to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n",
+ "[nltk_data] Unzipping tokenizers\\punkt.zip.\n"
+ ]
+ }
+ ],
+ "source": [
+ "import nltk\n",
+ "from nltk.tokenize import word_tokenize\n",
+ "\n",
+ "nltk.download('punkt')\n",
+ "\n",
+ "def tokenize(s):\n",
+ "\n",
+ " tokens = word_tokenize(s)\n",
+ " return tokens\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['ironhack', 's', 'q', 'website', 'is']\n"
+ ]
+ }
+ ],
+ "source": [
+ "input_string = \"ironhack s q website is\"\n",
+ "tokenized_words = tokenize(input_string)\n",
+ "print(tokenized_words)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Stemming and Lemmatization\n",
+ "\n",
+ "We will do stemming and lemmatization in the same step because otherwise we'll have to loop each token lists twice. You have learned in the previous challenge that stemming and lemmatization are similar but have different purposes for text normalization:\n",
+ "\n",
+ "**Stemming reduces words to their root forms (stems) even if the stem itself is not a valid word**. For instance, *token*, *tokenize*, and *tokenization* will be reduced to the same stem - *token*. And *change*, *changed*, *changing* will be reduced to *chang*.\n",
+ "\n",
+ "In NLTK, there are three stemming libraries: [*Porter*](https://www.nltk.org/_modules/nltk/stem/porter.html), [*Snowball*](https://www.nltk.org/_modules/nltk/stem/snowball.html), and [*Lancaster*](https://www.nltk.org/_modules/nltk/stem/lancaster.html). The difference among the three is the agressiveness with which they perform stemming. Porter is the most gentle stemmer that preserves the word's original form if it has doubts. In contrast, Lancaster is the most aggressive one that sometimes produces wrong outputs. And Snowball is in between. **In most cases you will use either Porter or Snowball**.\n",
+ "\n",
+ "**Lemmatization differs from stemming in that lemmatization cares about whether the reduced form belongs to the target language and it often requires the context (i.e. POS or parts-of-speech) in order to perform the correct transformation**. For example, the [*Word Net lemmatizer* in NLTK](https://www.nltk.org/_modules/nltk/stem/wordnet.html) yields different results with and without being told that *was* is a verb:\n",
+ "\n",
+ "```python\n",
+ ">>> from nltk.stem import WordNetLemmatizer\n",
+ ">>> lemmatizer = WordNetLemmatizer()\n",
+ ">>> lemmatizer.lemmatize('was')\n",
+ "'wa'\n",
+ ">>> lemmatizer.lemmatize('runs', pos='v')\n",
+ "'be'\n",
+ "```\n",
+ "\n",
+ "In the cell below, import the necessary libraries and define a function called `stem_and_lemmatize` that performs both stemming and lemmatization on a list of words. Don't worry about the POS part of lemmatization for now."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package punkt to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n",
+ "[nltk_data] Package punkt is already up-to-date!\n"
+ ]
+ }
+ ],
+ "source": [
+ "import nltk\n",
+ "from nltk.stem import SnowballStemmer\n",
+ "\n",
+ "nltk.download('punkt')\n",
+ "\n",
+ "def stem_and_lemmatize(l):\n",
+ "\n",
+ " stemmer = SnowballStemmer(\"english\")\n",
+ " stemmed_and_lemmatized = []\n",
+ "\n",
+ " for word in l:\n",
+ " stemmed_word = stemmer.stem(word)\n",
+ " stemmed_and_lemmatized.append(stemmed_word)\n",
+ "\n",
+ " return stemmed_and_lemmatized"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 46,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['cat', 'ine']\n"
+ ]
+ }
+ ],
+ "source": [
+ "word_list = ['cat','ines']\n",
+ "stemmed_and_lemmatized_words = stem_and_lemmatize(word_list)\n",
+ "print(stemmed_and_lemmatized_words)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Stop Words Removal\n",
+ "\n",
+ "Stop Words are the most commonly used words in a language that don't contribute to the main meaning of the texts. Examples of English stop words are `i`, `me`, `is`, `and`, `the`, `but`, and `here`. We want to remove stop words from analysis because otherwise stop words will take the overwhelming portion in our tokenized word list and the NLP algorithms will have problems in identifying the truely important words.\n",
+ "\n",
+ "NLTK has a `stopwords` package that allows us to import the most common stop words in over a dozen langauges including English, Spanish, French, German, Dutch, Portuguese, Italian, etc. These are the bare minimum stop words (100-150 words in each language) that can get beginners started. Some other NLP packages such as [*stop-words*](https://pypi.org/project/stop-words/) and [*wordcloud*](https://amueller.github.io/word_cloud/generated/wordcloud.WordCloud.html) provide bigger lists of stop words.\n",
+ "\n",
+ "Now in the cell below, create a function called `remove_stopwords` that loop through a list of words that have been stemmed and lemmatized to check and remove stop words. Return a new list where stop words have been removed."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package stopwords to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n",
+ "[nltk_data] Unzipping corpora\\stopwords.zip.\n"
+ ]
+ }
+ ],
+ "source": [
+ "import nltk\n",
+ "from nltk.corpus import stopwords\n",
+ "\n",
+ "nltk.download('stopwords')\n",
+ "\n",
+ "def remove_stopwords(word_list):\n",
+ "\n",
+ " stop_words = set(stopwords.words('english'))\n",
+ " filtered_words = [word for word in word_list if word not in stop_words]\n",
+ " \n",
+ " return filtered_words\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['I', 'need', 'go', 'home']\n"
+ ]
+ }
+ ],
+ "source": [
+ "# Example usage\n",
+ "word_list = ['I', 'need', 'to', 'go', 'home']\n",
+ "filtered_words = remove_stopwords(word_list)\n",
+ "print(filtered_words)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Summary\n",
+ "\n",
+ "In this challenge you have learned several text preparation techniques in more depths including text cleaning, tokenization, stemming, lemmatization, and stopwords removal. You have also written the functions you will be using in the next challenge to prepare texts for NLP analysis. Now we are ready to move on to the next challenge - Sentiment Analysis."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/your-code/challenge-2_ines.ipynb b/your-code/challenge-2_ines.ipynb
new file mode 100644
index 0000000..ef34d25
--- /dev/null
+++ b/your-code/challenge-2_ines.ipynb
@@ -0,0 +1,1857 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import pandas as pd\n",
+ "import nltk\n",
+ "from nltk.stem import WordNetLemmatizer, PorterStemmer\n",
+ "from nltk.corpus import stopwords\n",
+ "from nltk.tokenize import word_tokenize\n",
+ "from nltk import FreqDist\n",
+ "import re"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Challenge 2: Sentiment Analysis\n",
+ "\n",
+ "In this challenge we will learn sentiment analysis and practice performing sentiment analysis on Twitter tweets. \n",
+ "\n",
+ "## Introduction\n",
+ "\n",
+ "Sentiment analysis is to *systematically identify, extract, quantify, and study affective states and subjective information* based on texts ([reference](https://en.wikipedia.org/wiki/Sentiment_analysis)). In simple words, it's to understand whether a person is happy or unhappy in producing the piece of text. Why we (or rather, companies) care about sentiment in texts? It's because by understanding the sentiments in texts, we will be able to know if our customers are happy or unhappy about our products and services. If they are unhappy, the subsequent action is to figure out what have caused the unhappiness and make improvements.\n",
+ "\n",
+ "Basic sentiment analysis only understands the *positive* or *negative* (sometimes *neutral* too) polarities of the sentiment. More advanced sentiment analysis will also consider dimensions such as agreement, subjectivity, confidence, irony, and so on. In this challenge we will conduct the basic positive vs negative sentiment analysis based on real Twitter tweets.\n",
+ "\n",
+ "NLTK comes with a [sentiment analysis package](https://www.nltk.org/api/nltk.sentiment.html). This package is great for dummies to perform sentiment analysis because it requires only the textual data to make predictions. For example:\n",
+ "\n",
+ "```python\n",
+ ">>> from nltk.sentiment.vader import SentimentIntensityAnalyzer\n",
+ ">>> txt = \"Ironhack is a Global Tech School ranked num 2 worldwide.
",
+ "
",
+ "Our mission is to help people transform their careers and join a thriving community of tech professionals that love what they do.\"\n",
+ ">>> analyzer = SentimentIntensityAnalyzer()\n",
+ ">>> analyzer.polarity_scores(txt)\n",
+ "{'neg': 0.0, 'neu': 0.741, 'pos': 0.259, 'compound': 0.8442}\n",
+ "```\n",
+ "\n",
+ "In this challenge, however, you will not use NLTK's sentiment analysis package because in your Machine Learning training in the past 2 weeks you have learned how to make predictions more accurate than that. The [tweets data](https://www.kaggle.com/kazanova/sentiment140) we will be using today are already coded for the positive/negative sentiment. You will be able to use the Naïve Bayes classifier you learned in the lesson to predict the sentiment of tweets based on the labels."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Conducting Sentiment Analysis\n",
+ "\n",
+ "### Loading and Exploring Data\n",
+ "\n",
+ "The dataset we'll be using today is located on Kaggle (https://www.kaggle.com/kazanova/sentiment140). Once you have downloaded and imported the dataset, it you will need to define the columns names: df.columns = ['target','id','date','flag','user','text']\n",
+ "\n",
+ "*Notes:* \n",
+ "\n",
+ "* The dataset is huuuuge (1.6m tweets). When you develop your data analysis codes, you can sample a subset of the data (e.g. 20k records) so that you will save a lot of time when you test your codes."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package vader_lexicon to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "True"
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import nltk\n",
+ "nltk.download('vader_lexicon')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "{'neg': 0.0, 'neu': 0.741, 'pos': 0.259, 'compound': 0.8442}\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nltk.sentiment.vader import SentimentIntensityAnalyzer\n",
+ "\n",
+ "txt = \"Ironhack is a Global Tech School ranked num 2 worldwide. Our mission is to help people transform their careers and join a thriving community of tech professionals that love what they do.\"\n",
+ "analyzer = SentimentIntensityAnalyzer()\n",
+ "sentiment_scores = analyzer.polarity_scores(txt)\n",
+ "\n",
+ "print(sentiment_scores)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " target | \n",
+ " id | \n",
+ " date | \n",
+ " flag | \n",
+ " user | \n",
+ " text | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 541200 | \n",
+ " 0 | \n",
+ " 2200003196 | \n",
+ " Tue Jun 16 18:18:12 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " LaLaLindsey0609 | \n",
+ " @chrishasboobs AHHH I HOPE YOUR OK!!! | \n",
+ "
\n",
+ " \n",
+ " | 750 | \n",
+ " 0 | \n",
+ " 1467998485 | \n",
+ " Mon Apr 06 23:11:14 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sexygrneyes | \n",
+ " @misstoriblack cool , i have no tweet apps fo... | \n",
+ "
\n",
+ " \n",
+ " | 766711 | \n",
+ " 0 | \n",
+ " 2300048954 | \n",
+ " Tue Jun 23 13:40:11 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sammydearr | \n",
+ " @TiannaChaos i know just family drama. its la... | \n",
+ "
\n",
+ " \n",
+ " | 285055 | \n",
+ " 0 | \n",
+ " 1993474027 | \n",
+ " Mon Jun 01 10:26:07 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " Lamb_Leanne | \n",
+ " School email won't open and I have geography ... | \n",
+ "
\n",
+ " \n",
+ " | 705995 | \n",
+ " 0 | \n",
+ " 2256550904 | \n",
+ " Sat Jun 20 12:56:51 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " yogicerdito | \n",
+ " upper airways problem | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 1178000 | \n",
+ " 4 | \n",
+ " 1981517014 | \n",
+ " Sun May 31 09:19:12 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " gemmaridlington | \n",
+ " Loving the weather Although we're not having ... | \n",
+ "
\n",
+ " \n",
+ " | 667014 | \n",
+ " 0 | \n",
+ " 2245469775 | \n",
+ " Fri Jun 19 16:10:38 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " musicroxmysockz | \n",
+ " Me and andrea r. last day of school..... http... | \n",
+ "
\n",
+ " \n",
+ " | 1451235 | \n",
+ " 4 | \n",
+ " 2063022808 | \n",
+ " Sun Jun 07 01:05:46 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " ElaineToni | \n",
+ " Just finished watching Your Song Presents: Boy... | \n",
+ "
\n",
+ " \n",
+ " | 1181413 | \n",
+ " 4 | \n",
+ " 1982082859 | \n",
+ " Sun May 31 10:29:36 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " lindseyrd20 | \n",
+ " @janfran813 awww i can't wait to get one | \n",
+ "
\n",
+ " \n",
+ " | 517910 | \n",
+ " 0 | \n",
+ " 2191411608 | \n",
+ " Tue Jun 16 05:13:11 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " spiritkl | \n",
+ " is indeed, a rather large hoarder of paper. &a... | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
20000 rows × 6 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " target id date flag \\\n",
+ "541200 0 2200003196 Tue Jun 16 18:18:12 PDT 2009 NO_QUERY \n",
+ "750 0 1467998485 Mon Apr 06 23:11:14 PDT 2009 NO_QUERY \n",
+ "766711 0 2300048954 Tue Jun 23 13:40:11 PDT 2009 NO_QUERY \n",
+ "285055 0 1993474027 Mon Jun 01 10:26:07 PDT 2009 NO_QUERY \n",
+ "705995 0 2256550904 Sat Jun 20 12:56:51 PDT 2009 NO_QUERY \n",
+ "... ... ... ... ... \n",
+ "1178000 4 1981517014 Sun May 31 09:19:12 PDT 2009 NO_QUERY \n",
+ "667014 0 2245469775 Fri Jun 19 16:10:38 PDT 2009 NO_QUERY \n",
+ "1451235 4 2063022808 Sun Jun 07 01:05:46 PDT 2009 NO_QUERY \n",
+ "1181413 4 1982082859 Sun May 31 10:29:36 PDT 2009 NO_QUERY \n",
+ "517910 0 2191411608 Tue Jun 16 05:13:11 PDT 2009 NO_QUERY \n",
+ "\n",
+ " user text \n",
+ "541200 LaLaLindsey0609 @chrishasboobs AHHH I HOPE YOUR OK!!! \n",
+ "750 sexygrneyes @misstoriblack cool , i have no tweet apps fo... \n",
+ "766711 sammydearr @TiannaChaos i know just family drama. its la... \n",
+ "285055 Lamb_Leanne School email won't open and I have geography ... \n",
+ "705995 yogicerdito upper airways problem \n",
+ "... ... ... \n",
+ "1178000 gemmaridlington Loving the weather Although we're not having ... \n",
+ "667014 musicroxmysockz Me and andrea r. last day of school..... http... \n",
+ "1451235 ElaineToni Just finished watching Your Song Presents: Boy... \n",
+ "1181413 lindseyrd20 @janfran813 awww i can't wait to get one \n",
+ "517910 spiritkl is indeed, a rather large hoarder of paper. &a... \n",
+ "\n",
+ "[20000 rows x 6 columns]"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "import pandas as pd\n",
+ "data = pd.read_csv(\"training.1600000.processed.noemoticon.csv\", encoding='latin1', header=None)\n",
+ "data.columns = ['target', 'id', 'date', 'flag', 'user', 'text']\n",
+ "subset_data = data.sample(n=20000, random_state=42)\n",
+ "subset_data"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Prepare Textual Data for Sentiment Analysis\n",
+ "\n",
+ "Now, apply the functions you have written in Challenge 1 to your whole data set. These functions include:\n",
+ "\n",
+ "* `clean_up()`\n",
+ "\n",
+ "* `tokenize()`\n",
+ "\n",
+ "* `stem_and_lemmatize()`\n",
+ "\n",
+ "* `remove_stopwords()`\n",
+ "\n",
+ "Create a new column called `text_processed` in the dataframe to contain the processed data. At the end, your `text_processed` column should contain lists of word tokens that are cleaned up. Your data should look like below:\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import re\n",
+ "\n",
+ "def clean_up(s):\n",
+ " # Remove numbers\n",
+ " s = re.sub(r'\\d', '', s)\n",
+ "\n",
+ " # Remove URLs\n",
+ " s = re.sub(r'http\\S+|www\\S+', '', s)\n",
+ "\n",
+ " # Remove special characters and convert to lowercase\n",
+ " s = re.sub(r\"[!?,:.;&@#()\\[\\]{}'-]\", ' ', s).lower()\n",
+ "\n",
+ " # Remove extra spaces and strip leading/trailing spaces\n",
+ " s = re.sub(r'\\s+', ' ', s).strip()\n",
+ "\n",
+ " return s\n",
+ "\n",
+ "subset_data['cleaned'] = subset_data['text'].apply(clean_up)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " target | \n",
+ " id | \n",
+ " date | \n",
+ " flag | \n",
+ " user | \n",
+ " text | \n",
+ " cleaned | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 541200 | \n",
+ " 0 | \n",
+ " 2200003196 | \n",
+ " Tue Jun 16 18:18:12 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " LaLaLindsey0609 | \n",
+ " @chrishasboobs AHHH I HOPE YOUR OK!!! | \n",
+ " chrishasboobs ahhh i hope your ok | \n",
+ "
\n",
+ " \n",
+ " | 750 | \n",
+ " 0 | \n",
+ " 1467998485 | \n",
+ " Mon Apr 06 23:11:14 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sexygrneyes | \n",
+ " @misstoriblack cool , i have no tweet apps fo... | \n",
+ " misstoriblack cool i have no tweet apps for my... | \n",
+ "
\n",
+ " \n",
+ " | 766711 | \n",
+ " 0 | \n",
+ " 2300048954 | \n",
+ " Tue Jun 23 13:40:11 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sammydearr | \n",
+ " @TiannaChaos i know just family drama. its la... | \n",
+ " tiannachaos i know just family drama its lame ... | \n",
+ "
\n",
+ " \n",
+ " | 285055 | \n",
+ " 0 | \n",
+ " 1993474027 | \n",
+ " Mon Jun 01 10:26:07 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " Lamb_Leanne | \n",
+ " School email won't open and I have geography ... | \n",
+ " school email won t open and i have geography s... | \n",
+ "
\n",
+ " \n",
+ " | 705995 | \n",
+ " 0 | \n",
+ " 2256550904 | \n",
+ " Sat Jun 20 12:56:51 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " yogicerdito | \n",
+ " upper airways problem | \n",
+ " upper airways problem | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " target id date flag \\\n",
+ "541200 0 2200003196 Tue Jun 16 18:18:12 PDT 2009 NO_QUERY \n",
+ "750 0 1467998485 Mon Apr 06 23:11:14 PDT 2009 NO_QUERY \n",
+ "766711 0 2300048954 Tue Jun 23 13:40:11 PDT 2009 NO_QUERY \n",
+ "285055 0 1993474027 Mon Jun 01 10:26:07 PDT 2009 NO_QUERY \n",
+ "705995 0 2256550904 Sat Jun 20 12:56:51 PDT 2009 NO_QUERY \n",
+ "\n",
+ " user text \\\n",
+ "541200 LaLaLindsey0609 @chrishasboobs AHHH I HOPE YOUR OK!!! \n",
+ "750 sexygrneyes @misstoriblack cool , i have no tweet apps fo... \n",
+ "766711 sammydearr @TiannaChaos i know just family drama. its la... \n",
+ "285055 Lamb_Leanne School email won't open and I have geography ... \n",
+ "705995 yogicerdito upper airways problem \n",
+ "\n",
+ " cleaned \n",
+ "541200 chrishasboobs ahhh i hope your ok \n",
+ "750 misstoriblack cool i have no tweet apps for my... \n",
+ "766711 tiannachaos i know just family drama its lame ... \n",
+ "285055 school email won t open and i have geography s... \n",
+ "705995 upper airways problem "
+ ]
+ },
+ "execution_count": 33,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "subset_data.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 34,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import nltk\n",
+ "from nltk.tokenize import word_tokenize\n",
+ "\n",
+ "def tokenize(s):\n",
+ " tokens = word_tokenize(s)\n",
+ " return tokens\n",
+ "\n",
+ "subset_data['tokenized'] = subset_data['cleaned'].apply(tokenize)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " target | \n",
+ " id | \n",
+ " date | \n",
+ " flag | \n",
+ " user | \n",
+ " text | \n",
+ " cleaned | \n",
+ " tokenized | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 541200 | \n",
+ " 0 | \n",
+ " 2200003196 | \n",
+ " Tue Jun 16 18:18:12 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " LaLaLindsey0609 | \n",
+ " @chrishasboobs AHHH I HOPE YOUR OK!!! | \n",
+ " chrishasboobs ahhh i hope your ok | \n",
+ " [chrishasboobs, ahhh, i, hope, your, ok] | \n",
+ "
\n",
+ " \n",
+ " | 750 | \n",
+ " 0 | \n",
+ " 1467998485 | \n",
+ " Mon Apr 06 23:11:14 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sexygrneyes | \n",
+ " @misstoriblack cool , i have no tweet apps fo... | \n",
+ " misstoriblack cool i have no tweet apps for my... | \n",
+ " [misstoriblack, cool, i, have, no, tweet, apps... | \n",
+ "
\n",
+ " \n",
+ " | 766711 | \n",
+ " 0 | \n",
+ " 2300048954 | \n",
+ " Tue Jun 23 13:40:11 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sammydearr | \n",
+ " @TiannaChaos i know just family drama. its la... | \n",
+ " tiannachaos i know just family drama its lame ... | \n",
+ " [tiannachaos, i, know, just, family, drama, it... | \n",
+ "
\n",
+ " \n",
+ " | 285055 | \n",
+ " 0 | \n",
+ " 1993474027 | \n",
+ " Mon Jun 01 10:26:07 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " Lamb_Leanne | \n",
+ " School email won't open and I have geography ... | \n",
+ " school email won t open and i have geography s... | \n",
+ " [school, email, won, t, open, and, i, have, ge... | \n",
+ "
\n",
+ " \n",
+ " | 705995 | \n",
+ " 0 | \n",
+ " 2256550904 | \n",
+ " Sat Jun 20 12:56:51 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " yogicerdito | \n",
+ " upper airways problem | \n",
+ " upper airways problem | \n",
+ " [upper, airways, problem] | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " target id date flag \\\n",
+ "541200 0 2200003196 Tue Jun 16 18:18:12 PDT 2009 NO_QUERY \n",
+ "750 0 1467998485 Mon Apr 06 23:11:14 PDT 2009 NO_QUERY \n",
+ "766711 0 2300048954 Tue Jun 23 13:40:11 PDT 2009 NO_QUERY \n",
+ "285055 0 1993474027 Mon Jun 01 10:26:07 PDT 2009 NO_QUERY \n",
+ "705995 0 2256550904 Sat Jun 20 12:56:51 PDT 2009 NO_QUERY \n",
+ "\n",
+ " user text \\\n",
+ "541200 LaLaLindsey0609 @chrishasboobs AHHH I HOPE YOUR OK!!! \n",
+ "750 sexygrneyes @misstoriblack cool , i have no tweet apps fo... \n",
+ "766711 sammydearr @TiannaChaos i know just family drama. its la... \n",
+ "285055 Lamb_Leanne School email won't open and I have geography ... \n",
+ "705995 yogicerdito upper airways problem \n",
+ "\n",
+ " cleaned \\\n",
+ "541200 chrishasboobs ahhh i hope your ok \n",
+ "750 misstoriblack cool i have no tweet apps for my... \n",
+ "766711 tiannachaos i know just family drama its lame ... \n",
+ "285055 school email won t open and i have geography s... \n",
+ "705995 upper airways problem \n",
+ "\n",
+ " tokenized \n",
+ "541200 [chrishasboobs, ahhh, i, hope, your, ok] \n",
+ "750 [misstoriblack, cool, i, have, no, tweet, apps... \n",
+ "766711 [tiannachaos, i, know, just, family, drama, it... \n",
+ "285055 [school, email, won, t, open, and, i, have, ge... \n",
+ "705995 [upper, airways, problem] "
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "subset_data.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package punkt to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n",
+ "[nltk_data] Package punkt is already up-to-date!\n"
+ ]
+ }
+ ],
+ "source": [
+ "import nltk\n",
+ "from nltk.stem import SnowballStemmer\n",
+ "\n",
+ "nltk.download('punkt')\n",
+ "\n",
+ "def stem_and_lemmatize(word_list):\n",
+ " stemmer = SnowballStemmer(\"english\")\n",
+ " stemmed_and_lemmatized = []\n",
+ " \n",
+ " for word in word_list:\n",
+ " stemmed_word = stemmer.stem(word)\n",
+ " stemmed_and_lemmatized.append(stemmed_word)\n",
+ " \n",
+ " return stemmed_and_lemmatized\n",
+ "\n",
+ "subset_data['word_list'] = subset_data['tokenized'].apply(stem_and_lemmatize)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " target | \n",
+ " id | \n",
+ " date | \n",
+ " flag | \n",
+ " user | \n",
+ " text | \n",
+ " cleaned | \n",
+ " tokenized | \n",
+ " word_list | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 541200 | \n",
+ " 0 | \n",
+ " 2200003196 | \n",
+ " Tue Jun 16 18:18:12 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " LaLaLindsey0609 | \n",
+ " @chrishasboobs AHHH I HOPE YOUR OK!!! | \n",
+ " chrishasboobs ahhh i hope your ok | \n",
+ " [chrishasboobs, ahhh, i, hope, your, ok] | \n",
+ " [chrishasboob, ahhh, i, hope, your, ok] | \n",
+ "
\n",
+ " \n",
+ " | 750 | \n",
+ " 0 | \n",
+ " 1467998485 | \n",
+ " Mon Apr 06 23:11:14 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sexygrneyes | \n",
+ " @misstoriblack cool , i have no tweet apps fo... | \n",
+ " misstoriblack cool i have no tweet apps for my... | \n",
+ " [misstoriblack, cool, i, have, no, tweet, apps... | \n",
+ " [misstoriblack, cool, i, have, no, tweet, app,... | \n",
+ "
\n",
+ " \n",
+ " | 766711 | \n",
+ " 0 | \n",
+ " 2300048954 | \n",
+ " Tue Jun 23 13:40:11 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sammydearr | \n",
+ " @TiannaChaos i know just family drama. its la... | \n",
+ " tiannachaos i know just family drama its lame ... | \n",
+ " [tiannachaos, i, know, just, family, drama, it... | \n",
+ " [tiannachao, i, know, just, famili, drama, it,... | \n",
+ "
\n",
+ " \n",
+ " | 285055 | \n",
+ " 0 | \n",
+ " 1993474027 | \n",
+ " Mon Jun 01 10:26:07 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " Lamb_Leanne | \n",
+ " School email won't open and I have geography ... | \n",
+ " school email won t open and i have geography s... | \n",
+ " [school, email, won, t, open, and, i, have, ge... | \n",
+ " [school, email, won, t, open, and, i, have, ge... | \n",
+ "
\n",
+ " \n",
+ " | 705995 | \n",
+ " 0 | \n",
+ " 2256550904 | \n",
+ " Sat Jun 20 12:56:51 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " yogicerdito | \n",
+ " upper airways problem | \n",
+ " upper airways problem | \n",
+ " [upper, airways, problem] | \n",
+ " [upper, airway, problem] | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " target id date flag \\\n",
+ "541200 0 2200003196 Tue Jun 16 18:18:12 PDT 2009 NO_QUERY \n",
+ "750 0 1467998485 Mon Apr 06 23:11:14 PDT 2009 NO_QUERY \n",
+ "766711 0 2300048954 Tue Jun 23 13:40:11 PDT 2009 NO_QUERY \n",
+ "285055 0 1993474027 Mon Jun 01 10:26:07 PDT 2009 NO_QUERY \n",
+ "705995 0 2256550904 Sat Jun 20 12:56:51 PDT 2009 NO_QUERY \n",
+ "\n",
+ " user text \\\n",
+ "541200 LaLaLindsey0609 @chrishasboobs AHHH I HOPE YOUR OK!!! \n",
+ "750 sexygrneyes @misstoriblack cool , i have no tweet apps fo... \n",
+ "766711 sammydearr @TiannaChaos i know just family drama. its la... \n",
+ "285055 Lamb_Leanne School email won't open and I have geography ... \n",
+ "705995 yogicerdito upper airways problem \n",
+ "\n",
+ " cleaned \\\n",
+ "541200 chrishasboobs ahhh i hope your ok \n",
+ "750 misstoriblack cool i have no tweet apps for my... \n",
+ "766711 tiannachaos i know just family drama its lame ... \n",
+ "285055 school email won t open and i have geography s... \n",
+ "705995 upper airways problem \n",
+ "\n",
+ " tokenized \\\n",
+ "541200 [chrishasboobs, ahhh, i, hope, your, ok] \n",
+ "750 [misstoriblack, cool, i, have, no, tweet, apps... \n",
+ "766711 [tiannachaos, i, know, just, family, drama, it... \n",
+ "285055 [school, email, won, t, open, and, i, have, ge... \n",
+ "705995 [upper, airways, problem] \n",
+ "\n",
+ " word_list \n",
+ "541200 [chrishasboob, ahhh, i, hope, your, ok] \n",
+ "750 [misstoriblack, cool, i, have, no, tweet, app,... \n",
+ "766711 [tiannachao, i, know, just, famili, drama, it,... \n",
+ "285055 [school, email, won, t, open, and, i, have, ge... \n",
+ "705995 [upper, airway, problem] "
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "subset_data.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package stopwords to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n",
+ "[nltk_data] Package stopwords is already up-to-date!\n"
+ ]
+ }
+ ],
+ "source": [
+ "import nltk\n",
+ "from nltk.corpus import stopwords\n",
+ "\n",
+ "nltk.download('stopwords')\n",
+ "\n",
+ "def remove_stopwords(word_list):\n",
+ " stop_words = set(stopwords.words('english'))\n",
+ " filtered_words = [word for word in word_list if word not in stop_words]\n",
+ " return filtered_words\n",
+ "\n",
+ "subset_data['text_processed'] = subset_data['word_list'].apply(remove_stopwords)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "subset_data.drop(['cleaned', 'tokenized', 'word_list'], axis=1, inplace=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " target | \n",
+ " id | \n",
+ " date | \n",
+ " flag | \n",
+ " user | \n",
+ " text | \n",
+ " text_processed | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 541200 | \n",
+ " 0 | \n",
+ " 2200003196 | \n",
+ " Tue Jun 16 18:18:12 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " LaLaLindsey0609 | \n",
+ " @chrishasboobs AHHH I HOPE YOUR OK!!! | \n",
+ " [chrishasboob, ahhh, hope, ok] | \n",
+ "
\n",
+ " \n",
+ " | 750 | \n",
+ " 0 | \n",
+ " 1467998485 | \n",
+ " Mon Apr 06 23:11:14 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sexygrneyes | \n",
+ " @misstoriblack cool , i have no tweet apps fo... | \n",
+ " [misstoriblack, cool, tweet, app, razr] | \n",
+ "
\n",
+ " \n",
+ " | 766711 | \n",
+ " 0 | \n",
+ " 2300048954 | \n",
+ " Tue Jun 23 13:40:11 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " sammydearr | \n",
+ " @TiannaChaos i know just family drama. its la... | \n",
+ " [tiannachao, know, famili, drama, lame, hey, n... | \n",
+ "
\n",
+ " \n",
+ " | 285055 | \n",
+ " 0 | \n",
+ " 1993474027 | \n",
+ " Mon Jun 01 10:26:07 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " Lamb_Leanne | \n",
+ " School email won't open and I have geography ... | \n",
+ " [school, email, open, geographi, stuff, revis,... | \n",
+ "
\n",
+ " \n",
+ " | 705995 | \n",
+ " 0 | \n",
+ " 2256550904 | \n",
+ " Sat Jun 20 12:56:51 PDT 2009 | \n",
+ " NO_QUERY | \n",
+ " yogicerdito | \n",
+ " upper airways problem | \n",
+ " [upper, airway, problem] | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " target id date flag \\\n",
+ "541200 0 2200003196 Tue Jun 16 18:18:12 PDT 2009 NO_QUERY \n",
+ "750 0 1467998485 Mon Apr 06 23:11:14 PDT 2009 NO_QUERY \n",
+ "766711 0 2300048954 Tue Jun 23 13:40:11 PDT 2009 NO_QUERY \n",
+ "285055 0 1993474027 Mon Jun 01 10:26:07 PDT 2009 NO_QUERY \n",
+ "705995 0 2256550904 Sat Jun 20 12:56:51 PDT 2009 NO_QUERY \n",
+ "\n",
+ " user text \\\n",
+ "541200 LaLaLindsey0609 @chrishasboobs AHHH I HOPE YOUR OK!!! \n",
+ "750 sexygrneyes @misstoriblack cool , i have no tweet apps fo... \n",
+ "766711 sammydearr @TiannaChaos i know just family drama. its la... \n",
+ "285055 Lamb_Leanne School email won't open and I have geography ... \n",
+ "705995 yogicerdito upper airways problem \n",
+ "\n",
+ " text_processed \n",
+ "541200 [chrishasboob, ahhh, hope, ok] \n",
+ "750 [misstoriblack, cool, tweet, app, razr] \n",
+ "766711 [tiannachao, know, famili, drama, lame, hey, n... \n",
+ "285055 [school, email, open, geographi, stuff, revis,... \n",
+ "705995 [upper, airway, problem] "
+ ]
+ },
+ "execution_count": 40,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "subset_data.head()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Creating Bag of Words\n",
+ "\n",
+ "The purpose of this step is to create a [bag of words](https://en.wikipedia.org/wiki/Bag-of-words_model) from the processed data. The bag of words contains all the unique words in your whole text body (a.k.a. *corpus*) with the number of occurrence of each word. It will allow you to understand which words are the most important features across the whole corpus.\n",
+ "\n",
+ "Also, you can imagine you will have a massive set of words. The less important words (i.e. those of very low number of occurrence) do not contribute much to the sentiment. Therefore, you only need to use the most important words to build your feature set in the next step. In our case, we will use the top 5,000 words with the highest frequency to build the features.\n",
+ "\n",
+ "In the cell below, combine all the words in `text_processed` and calculate the frequency distribution of all words. A convenient library to calculate the term frequency distribution is NLTK's `FreqDist` class ([documentation](https://www.nltk.org/api/nltk.html#module-nltk.probability)). Then select the top 5,000 words from the frequency distribution."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "['go', 'get', 'day', 'good', 'work', 'like', 'love', 'quot', 'today', 'got', 'time', 'lol', 'thank', 'want', 'one', 'know', 'miss', 'back', 'feel', 'realli', 'see', 'u', 'think', 'amp', 'im', 'hope', 'well', 'watch', 'still', 'night', 'make', 'oh', 'need', 'na', 'look', 'home', 'come', '*', 'new', 'last', 'much', 'twitter', 'great', 'morn', 'wish', 'sleep', 'wait', 'follow', 'sad', 'tomorrow', 'tri', 'haha', 'bad', 'week', 'sorri', 'say', 'onli', 'happi', 'veri', 'would', 'right', 'whi', 'fun', 'friend', 'tonight', 'thing', 'nice', 'better', 'though', 'take', 'even', 'start', 'bed', 'hate', 'gon', 'peopl', 'way', 'tweet', 'school', 'yeah', 'show', 'lt', 'awesom', 'could', 'play', 'final', 'dont', 'hour', 'everyon', 'first', 'guy', 'use', 'next', 'let', 'weekend', 'year', 'soon', 'littl', 'pleas', 'long', 'yes', 'never', 'wan', 'rain', 'hey', 'girl', 'find', 'cant', 'help', 'ok', 'man', 'movi', 'done', 'best', 'sure', 'tire', 'bore', 'sick', 'x', 'ani', 'eat', 'alway', 'us', 'alreadi', 'phone', 'life', 'call', 'becaus', 'suck', 'anoth', 'head', 'keep', 'mayb', 'live', 'made', 'thought', 'leav', 'cool', 'someth', 'game', 'old', 'lot', 'read', 'amaz', 'song', 'hurt', 'bit', 'sound', 'talk', 'n', 'enjoy', 'yay', 'excit', 'went', 'yet', 'pretti', 'befor', 'away', 'listen', 'finish', 'wow', 'readi', 'earli', 'big', 'parti', 'guess', 'omg', 'ur', 'hous', 'seem', 'lost', 'birthday', 'damn', 'ever', 'mean', 'pic', 'also', 'said', 'check', 'hot', 'wonder', 'left', 'noth', 'hear', 'give', 'ugh', 'babi', 'friday', 'exam', 'world', 'mani', 'glad', 'actual', 'tell', 'stuff', 'stay', 'stop', 'end', 'aww', 'happen', 'sinc', 'ya', 'run', 'kid', 'someon', 'late', 'weather', 'might', 'put', 'beauti', 'updat', 'doe', 'summer', 'hard', 'post', 'must', 'monday', 'famili', 'hair', 'mom', 'music', 'found', 'around', 'ta', 'later', 'may', 'tho', 'god', 'sun', 'die', 'car', 'sunday', 'saw', 'meet', 'luck', 'th', 'iphon', 'fuck', 'job', 'boy', 'forward', 'yesterday', 'dinner', 'poor', 'free', 'everyth', '$', 'pictur', 'turn', 'sweet', 'food', 'least', 'place', 'move', 'cri', 'win', 'walk', 'video', 'hi', 'woke', 'b', 'cold', 'till', 'name', '/', 'shop', 'gone', 'sooo', 'month', 'chang', 'okay', 'anyth', 'cute', 'wrong', 'caus', 'believ', 'buy', 'ill', 'lunch', 'two', 'serious', 'ask', 'shit', 'onc', 'sit', 'anyon', 'fail', 'plan', 'room', 'send', 'book', 'dad', 'hahaha', 'r', 'gt', 'far', 'person', 'stupid', 'without', 'almost', 'worri', 'idea', 'headach', 'money', 'probabl', 'funni', 'hehe', 'goodnight', 'came', 'dream', 'studi', 'total', 'blog', 'class', 'saturday', 'fan', 'rock', 'repli', 'mother', 'clean', 'p', 'tv', 'whole', 'fix', 'minut', 'text', 'dog', 'train', 'anyway', 'drive', 'hit', 'busi', 'part', 'break', '=', 'cours', 'photo', 'enough', 'didnt', 'write', 'pain', 'drink', 'rememb', 'anymor', 'welcom', 'xx', 'pm', 'half', 'word', 'either', 'boo', 'ha', 'mine', 'open', 'hand', 'rest', 'true', 'hang', 'everi', 'close', 'quit', 'kinda', 'soo', 'wont', 'wake', 'real', 'email', 'coffe', 'face', 'brother', 'mileycyrus', 'els', 'eye', 'news', 'danc', 'outsid', 'care', 'site', 'full', 'vote', 'alon', 'seen', '+', 'download', 'fall', 'hello', 'heart', 'super', 'ticket', 'forgot', 'cut', 'ice', 'e', 'w/', 'concert', 'trip', 'beach', 'learn', 'heard', 'test', 'kill', 'comput', 'pay', 'bring', 'interest', 'abl', 'offic', 'wed', 'kind', 'problem', 'catch', 'link', 'add', 'internet', 'shower', 'aw', 'onlin', 'stuck', 'hug', 'star', 'bought', 'crazi', 'nite', 'la', 'park', 'june', 'btw', 'took', 'pick', 'nap', 'instead', 'mind', 'pass', 'lmao', 'ah', 'told', 'sunni', 'cuz', 'dead', 'dress', 'afternoon', 'season', 'hell', 'awak', 'togeth', 'com', 'water', 'wear', 'visit', 'laptop', 'share', 'sometim', 'ago', 'page', 'sister', 'smile', 'order', 'yea', 'side', 'offici', 'top', 'high', 'cat', 'graduat', 'mad', 'account', 'crap', 'revis', 'red', 'date', 'dude', 'congrat', 'award', 'g', 'project', 'album', 'team', 'worth', 'sign', 'laugh', 'drop', 'suppos', 'jealous', 'reason', 'breakfast', 'holiday', 'past', 'bout', 'figur', 'homework', 'favorit', 'set', 'forget', 'hungri', 'moment', 'uk', 'short', 'dear', 'english', 'tommcfli', 'ass', 'town', 'soooo', 'lose', 'upload', 'goin', 'fine', 'pack', 'air', 'st', 'youtub', 'load', 'asleep', 'definit', 'card', 'shirt', 'ate', 'cook', 'answer', 'fair', 'appar', 'second', 'broke', 'facebook', 'ladi', 'gym', 'spend', 'power', 'parent', 'sunshin', 'support', 'band', 'join', 'comment', 'store', 'bye', 'understand', 'ride', 'save', 'differ', 'sat', 'tour', 'near', 'mood', 'light', 'nd', 'agre', 'awww', 'point', 'fb', 'scare', 'church', 'ddlovato', 'appl', 'lazi', 'list', 'stori', 'bet', 'mum', 'vacat', 'coupl', 'laker', 'fast', 'flight', 'horribl', 'ipod', 'mr', 'lucki', 'annoy', 'cream', 'sing', 'due', 'min', 'ahh', 'sigh', 'slow', 'upset', 'apart', 'touch', 'line', 'sent', 'chat', 'xd', 'met', 'messag', 'perfect', 'f', 'black', 'rather', 'chocol', 'hmm', 'question', 'citi', 'usual', 'unfortun', 'relax', 'sore', 'realiz', 'ive', 'weird', 'nope', 'shame', 'em', 'chanc', 'complet', 'ppl', 'followfriday', 'fli', 'window', 'dure', 'gave', 'kick', 'blue', 'til', 'math', 'mess', 'insid', 'easi', 'hold', 'bike', 'shot', 'yummi', 'throat', 'cross', 'record', 'garden', 'colleg', 'idk', 'pool', 'manag', 'possibl', 'special', 'forev', 'depress', '»', 'c', 'film', 'road', 'chicken', 'tea', 'l', 'decid', 'piss', 'issu', 'none', 'especi', 'yep', 'type', 'hospit', 'myspac', 'block', 'sleepi', 'bbq', 'addict', 'worst', 'quick', 'earlier', 'freak', 'death', 'bitch', 'london', 'son', 'miley', 'knew', 'flu', 'roll', 'beat', 'expect', '|', 'da', 'surpris', 'goe', 'camera', 'small', 'less', 'xxx', 'spent', 'pizza', 'releas', 'exact', 'magic', 'cos', 'fell', 'storm', 'confus', '«', 'bless', 'ad', 'bus', 'invit', 'gorgeous', 'celebr', 'green', 'pray', 'via', 'sim', 'appreci', 'major', 'plz', 'slept', 'smell', 'lame', 'product', 'ear', 'case', 'bodi', 'finger', 'thursday', 'wednesday', 'bank', 'k', 'everybodi', 'stress', 'camp', 'dm', 'except', 'three', 'w', 'wors', 'lone', 'tummi', 'ahhh', 'app', 'yo', 'search', 'luv', 'fight', 'ps', 'number', 'dang', 'compani', 'teeth', 'travel', 'mtv', 'wtf', 'notic', 'hahahaha', 'chill', 'lay', 'tom', 'bday', 'interview', 'servic', 'box', 'market', 'episod', 'xoxo', 'websit', 'babe', 'low', 'cloth', 'remind', 'sold', 'breath', 'swim', 'speak', 'promis', 'hotel', 'view', 'bath', 'doctor', 'paper', 'prob', 'huge', 'crash', 'stomach', 'anim', 'v', 'airport', 'terribl', 'white', 'shoot', 'cd', 'fact', 'eh', 'woo', 'cheer', 'jona', 'mac', 'isnt', 'safe', 'current', 'inspir', 'hubbi', 'countri', 'sort', 'kate', 'bro', 'clear', 'daughter', 'shall', 'shoe', 'tuesday', 'channel', 'jonasbroth', 'sell', 'arriv', 'feet', 'absolut', 'blood', 'kiss', 'round', 'bum', 'fish', 'wash', 'voic', 'mail', 'deserv', 'disappoint', 'snow', 'broken', 'nose', 'web', 'lesson', 'cancel', 'although', 'burn', 'mobil', 'wat', 'stand', 'often', 'whatev', 'gay', '%', 'note', 'ball', 'design', 'cake', 'chillin', 'version', 'bag', 'fill', 'tast', 'meant', 'lie', 'sooooo', 'david', 'plus', 'hun', 'beer', 'chicago', 'delet', 'track', 'becom', 'cousin', 'yr', 'suggest', 'warm', 'sale', 'topic', 'boot', 'thx', 'throw', 'street', 'cover', 'random', 'longer', 'along', 'lil', 'tweep', 'behind', 'taken', 'joe', 'land', 'vip', 'hangov', 'raini', 'recommend', 'ach', 'club', 'practic', 'proud', 'review', 'offer', 'nail', 'fever', 'peac', 'experi', 'art', 'pull', 'boss', 'step', 'wife', 'tear', 'epic', 'bloodi', 'traffic', 'tweetdeck', 'id', 'certain', 'watchin', 'perform', 'huh', 'nobodi', 'puppi', 'jon', 'fat', 'leg', 'gettin', 'deal', 'boyfriend', 'ouch', 'includ', 'alright', 'cough', 'age', 'fantast', 'door', 'doesnt', 'felt', 'peep', 'futur', 'mommi', 'dark', 'choic', 'ruin', 'fam', 'wit', 'fault', 'inde', 'doubl', 'scari', 'san', 'ahead', 'batteri', 'ooh', 'plane', 'present', 'excel', 'darn', 'havent', 'moon', 'count', 'glass', 'afraid', 'msn', 'hrs', 'troubl', 'extrem', 'million', 'mouth', 'hmmm', 'aint', 'mmm', 'tonit', 'profil', 'king', 'googl', 'bill', 'bug', 'articl', 'knee', 'front', 'pc', 'father', 'wast', 'ring', 'begin', 'couldnt', 'feelin', 'hes', 'gut', '`', 'shift', 'starbuck', 'race', 'milk', 'alot', 'pink', 'radio', 'fire', 'fav', 'joke', 'teach', 'edit', 'juli', 'brain', 'arm', 'ff', 'doubt', 'social', 'return', 'thanx', 'gunna', 'prepar', 'talent', 'rip', 'congratul', 'scienc', 'build', 'hannah', 'event', 'sunburn', 'nah', 'yum', 'vega', 'loud', 'direct', 'delici', 'exhaust', 'wine', 'imagin', 'blow', 'rd', 'studio', '~', 'custom', 'aliv', 'bright', 'folk', 'schedul', 'expens', 'silli', 'itun', 'trek', 'act', 'hilari', 'taylor', 'cup', 'result', 'screw', 'mix', 'avail', 'shout', 'drag', 'posit', 'south', 'def', 'thunder', 'â\\x99', 'goodby', 'yup', 'instal', 'burnt', 'memori', 'fit', 'color', 'thru', 'franc', 'sum', 'essay', 'ohh', 'dread', 'competit', 'report', 'price', 'twilight', 'nick', 'continu', 'xo', 'smoke', 'everywher', 'sugar', 'effect', 'pop', 'mile', 'vid', 'bb', 'french', 'honest', 'buddi', 'festiv', 'state', 'extra', 'heat', 'drama', 'local', 'twit', 'area', 'entir', 'mark', 'hill', 'self', 'tree', 'taco', 'sky', 'sis', 'normal', 'slight', 'workout', 'ador', 'prom', 'fave', 'daddi', 'kitti', 'evil', 'copi', 'feed', 'surgeri', 'mo', 'bar', 'freakin', 'straight', 'blast', 'everyday', 'jus', 'screen', 'hook', 'demi', 'allergi', 'key', 'click', 'sweeti', 'success', 'dri', 'net', 'histori', 'lock', 'young', 'charact', 'charg', 'server', 'jump', 'wasnt', 'given', 'mention', 'match', 'co', 'research', 'wave', 'jam', 'pant', 'os', 'somehow', 'lack', 'hoo', 'woot', 'bunch', 'ny', 'tan', 'cooki', 'appear', 'impress', 'machin', 'kept', 'uh', 'student', 'germani', 'j', 'caught', 'dvd', 'dr', 'massiv', 'midnight', 'ship', 'ignor', 'nation', 'wing', 'brazil', 'ahaha', 'info', 'west', 'hahah', 'h', 'burger', 'control', 'dentist', 'singl', 'simpl', 'mornin', 'lake', 'drunk', 'anywher', 'toni', 'somewher', 'relat', 'brought', 'background', 'convers', 'blackberri', 'fri', 'tha', 'honey', 'joy', 'grow', 'code', 'spring', 'obvious', 'wrote', 'session', 'crave', 'war', 'origin', 'nervous', 'prayer', 'rob', 'allow', 'connect', '^^', 'teacher', 'jack', 'â\\x99¥', 'scratch', 'um', 'trend', 'board', 'cell', 'men', 'sens', 'chees', 'crappi', 'canada', 'paint', 'tip', 'matter', 'cheap', 'shaundiviney', 'suffer', 'bowl', 'dollar', 'brilliant', 'argh', 'de', 'ran', 'gosh', 'australia', 'ugli', 'afford', 'respond', 'launch', 'taylorswift', 'spin', 'pleasur', 'swear', 'pen', 'nightmar', 'prefer', 'base', 'push', 'easier', 'restaur', 'draw', 'island', 'grand', 'kno', 'theme', 'five', 'chris', 'button', 'fabul', 'guitar', 'texa', 'chick', 'mate', 'spam', 'ty', 'adam', 'august', 'latest', 'across', 'client', 'john', 'bummer', 'angel', 'bf', 'bare', 'montana', 'beta', 'sudden', 'retweet', 'jb', 'receiv', 'selenagomez', 'ridicul', 'mama', 'etc', 'tweeti', 'accept', 'complain', 'style', 'divers', 'gig', 'collect', 'plant', 'player', 'kati', 'fml', 'husband', 'pls', 'dumb', 'basic', 'request', 'paid', 'form', 'correct', 'stick', 'ohhh', 'daili', 'pari', 'yall', 'unless', 'jean', 'chip', 'refresh', 'ton', 'shut', 'hack', 'wall', 'pro', 'sir', 'east', 'consid', 'driver', 'rule', 'attempt', 'hors', 'creat', '�', 'winter', 'public', 'ima', 'sex', 'weight', 'contact', 'goood', 'neither', 'banana', 'user', 'ili', 'oooh', 'odd', 'amus', 'ep', 'egg', 'woohoo', 'featur', 'lip', 'blah', 'mall', 'trailer', 'pre', 'swine', 'skin', 'forum', 'rush', 'ughh', 'tune', 'tank', 'main', 'media', 'pour', 'parad', 'disney', 'fresh', 'recent', 'twice', 'europ', 'quiet', 'entertain', 'doin', 'child', 'cuddl', 'proper', 'floor', 'import', 'mini', 'salad', 'hide', 'nyc', 'sauc', 'option', 'foot', 'boston', 'gah', 'neck', 'heaven', 'marri', 'nooo', 'basebal', 'pet', 'infect', 'ahhhh', 'bang', 'detail', 'trust', 'india', 'bt', 'dunno', 'bear', '=d', 'susan', 'tight', 'hero', 'tough', 'laundri', 'whoop', 'univers', 'suit', 'jess', 'grandma', 'gift', 'ish', 'girlfriend', 'flat', 'carri', 'loss', 'host', 'system', 'piec', 'level', 'stage', 'group', 'assign', 'librari', 'tool', 'dougiemcfli', 'pump', 'yard', 'donniewahlberg', 'bff', 'abt', 'replac', 'heh', 'credit', 'slowli', 'california', 'attend', 'tooth', 'famous', 'soccer', 'orlando', 'stream', 'sever', 'uncl', 'challeng', 'tattoo', 'outta', 'toe', 'mm', 'soup', 'spot', 'grab', 'ash', 'bird', 'anytim', 'dick', 'healthi', 'american', 'conan', 'butt', 'talkin', 'switch', 'reach', 'hung', 'fed', 'bake', 'alex', 'shake', 'danni', 'error', 'respons', 'hav', 'spell', 'accid', 'term', 'er', 'lookin', 'action', 'howev', 'bunni', 'cancer', '//', 'jay', 'holi', 'recov', 'four', 'macbook', 'biolog', 'fashion', 'creativ', 'bottl', 'miser', 'couch', 'awsom', 'tryin', 'ten', 'wet', 'rent', 'seri', 'member', 'meal', 'wouldnt', 'jonathanrknight', 'law', 'degre', 'knock', 'mmmm', 'bite', 'non', 'mah', 'aha', 'dirti', 'pot', 'contest', 'ms', 'surviv', 'mainten', 'missin', 'umm', 'mountain', 'ing', 'energi', 'wii', 'woman', 'sushi', 'rough', 'admit', 'obsess', 'idiot', 'stole', 'blame', 'station', 'niec', 'twitt', 'besti', 'strong', 'cast', 'davidarchi', 'jason', 'palm', 'speed', 'bother', 'pasta', 'uni', 'smart', 'children', 'letter', 'shes', 'ef', 'coast', 'nothin', 'grey', 'photoshop', 'vet', 'noodl', 'truli', 'dat', 'ryan', 'typic', 'insan', 'mitchelmusso', 'period', 'boooo', 'model', 'shine', 'recip', 'depend', 'april', 'earn', 'grrr', 'cafe', 'cloudi', 'physic', '_', 'fake', 'york', 'ami', 'journey', 'awkward', 'robin', 'compliment', 'grr', 'secret', 'refer', 'goodmorn', 'seat', 'jame', 'bc', 'kelli', 'fear', 'sexi', 'sux', 'rubbish', 'access', 'tweeter', 'gr', 'fab', 'asap', 'hood', 'mon', 'coz', 'gaga', 'bgt', 'ooo', 'brown', 'realis', 'explain', 'comfort', 'limit', 'fellow', 'al', 'cost', 'ex', 'thumb', 'b/c', 'exist', 'cabl', 'singapor', 'incred', 'philippin', 'empti', 'hip', 'besid', 'andi', 'awhil', 'center', 'wreck', 'skip', 'tix', 'groceri', 'situat', 'longest', 'miami', 'bread', 'crew', 'bean', 'stare', 'michael', 'hw', 'shock', 'america', 'bull', 'explor', 'effin', 'flip', 'rainbow', 'twitpic', 'genius', 'noon', 'known', 'bleed', 'guilti', 'ñ', 'firefox', 'spoil', 'soooooo', 'meh', 'squarespac', 'bah', 'workin', 'boyl', 'discov', 'forc', 'actor', 'born', 'dish', 'dammit', 'regular', 'onto', 'imma', 'desk', 'creepi', 'greet', 'emo', 'whilst', 'oop', 'heck', 'bell', 'crack', 'deliveri', 'insur', 'walmart', 'diet', 'piti', 'nurs', 'strawberri', 'contract', 'climb', 'mistak', 'wee', 'frustrat', 'vs', 'dnt', 'perhap', 'xbox', 'skype', 'lovin', 'cali', 'toast', 'alarm', 'biggest', 'advertis', 'senior', 'tube', 'hire', 'outfit', 'tenni', 'whoa', 'kitchen', 'gas', 'cash', 'gear', 'juic', 'river', 'gud', 'tech', 'announc', 'difficult', 'noo', 'perezhilton', 'calm', 'ankl', 'femal', 'spanish', 'atm', 'freez', 'yah', 'program', 'attack', 'dare', 'iranelect', 'yellow', 'wireless', 'photographi', 'penguin', 'pure', 'soul', 'confer', 'swift', 'settl', 'gross', 'ftw', 'blond', 'clue', 'respect', 'ashley', 'favourit', 'princess', 'dave', 'crowd', 'rais', 'lolz', 'clock', 'women', 'shitti', 'bottom', 'gf', 'grace', 'ca', 'makeup', 'ew', 'mission', 'edg', 'ashleytisdal', 'rid', 'pierc', 'root', 'ray', 'grade', 'particular', 'threw', 'twin', 'wick', 'languag', 'migrain', 'confirm', 'tht', 'melt', 'colour', 'theori', 'blip', 'jake', 'nut', 'mi', 'grrrr', 'awe', 'patch', 'cutest', 'golf', 'italian', 'nasti', 'nine', 'angri', 'classic', 'biz', 'giant', 'somebodi', 'sneez', 'bailey', 'cupcak', 'closer', 'ground', 'flickr', 'dannymcfli', 'vista', 'errand', 'port', 'brush', 'assum', 'within', 'chair', 'ko', 'tag', 'doll', 'nba', 'hay', 'ohhhh', 'kay', 'heyi', 'din', 'tini', 'appli', 'advic', 'fruit', 'oil', 'hayfev', 'anniversari', 'yeh', 'network', 'hah', 'rate', 'sight', 'youth', 'piano', 'snack', 'hat', 'grill', 'intern', 'lmfao', 'flash', 'bubbl', 'thnx', 'failur', 'pee', 'tongu', 'bathroom', 'tie', 'scan', 'tail', 'press', 'txt', 'xox', 'aunt', 'hooray', 'motiv', 'lord', 'rub', 'idol', 'hella', 'liter', 'downtown', 'waffl', 'improv', 'whale', 'sheet', 'un', 'surf', 'musicmonday', 'materi', 'everytim', 'rich', 'boat', 'remain', 'thankyou', 'georg', 'loser', 'brad', 'licens', 'transform', 'ars', 'youu', 'iran', 'sittin', 'rehears', 'makin', 'mike', 'hype', 'emili', 'imag', 'process', 'hike', 'emot', 'philli', 'eventu', 'polic', 'emma', 'paul', 'truth', 'steal', 'protect', 'mmmmm', 'ghost', 'japanes', 'noooo', 'grandpa', 'starv', 'china', 'qualiti', 'url', 'woken', 'con', 'fm', 'commerci', 'neighbor', 'wink', 'judg', 'harri', 'ben', 'wordpress', 'writer', 'poo', '=/', 'bigger', 'lead', 'itch', 'nat', 'babysit', 'ang', 'address', 'tidi', 'wide', 'tmrw', 'earth', 'magazin', 'sucki', 'ng', 'hr', 'lover', 'remot', 'sf', 'larg', 'hon', 'sa', 'handl', 'desper', 'older', 'cooler', 'court', 'speech', 'rose', 'rare', 'cap', 'thinkin', 'distract', 'staff', 'tay', 'joeymcintyr', 'massag', 'poop', 'deep', 'combin', 'rli', 'swollen', 'ac', 'legal', 'apolog', 'novemb', 'emerg', 'dope', 'bone', 'duck', 'human', 'heap', 'organ', 'health', 'inform', 'beg', 'stock', 'aswel', 'mous', 'tax', 'el', 'donut', 'middl', 'w/o', 'altern', 'metal', 'space', 'takin', 'matt', 'function', 'mcfli', 'pretend', 'yahoo', 'convo', 'freedom', 'eaten', 'muscl', 'yawn', 'hunt', 'candi', 'junk', 'max', 'kitten', 'england', 'choos', 'kyle', 'nc', 'technolog', 'dissapoint', 'punch', 'kobe', 'shaunjumpnow', 'dj', 'pride', 'mid', 'charger', 'ye', 'passport', 'roast', 'phew', 'soft', 'poster', 'bust', 'soak', 'lee', 'royal', 'celeb', 'eatin', 'skill', 'cop', 'sayin', 'defin', 'promot', 'chuck', 'washington', 'wifi', 'rockin', 'robert', 'darl', 'locat', 'hurri', 'amazon', 'therefor', 'sock', 'subway', 'blown', 'focus', 'gold', 'rove', 'avoid', 'status', 'corner', 'gmail', 'provid', 'decis', 'pt', 'flower', 'blind', 'wossi', 'rachel', 'hammer', 'ninja', 'corn', 'sydney', 'reckon', 'rofl', 'grad', 'repeat', 'virus', 'kris', 'convinc', 'regist', 'activ', 'file', 'approv', 'cloud', 'wimbledon', 'cheesecak', 'someday', 'resist', 'fridg', 'closet', 'brew', 'bee', 'nighti', 'leak', 'aplusk', 'exercis', 'supris', 'translat', 'anti', 'keyboard', 'sport', 'dun', 'stalk', 'data', 'script', 'jordanknight', 'scene', 'q', 'ie', 'boom', 'pub', 'snap', 'gotten', 'dan', 'row', 'se', 'lifetim', 'campaign', 'friggin', 'yu', 'fu', 'steve', 'spread', 'brand', 'crawl', 'smooth', 'ultim', 'master', 'comp', 'aussi', 'dual', 'treat', 'rescu', 'wisdom', 'butter', 'softwar', 'spider', 'bridg', 'gossip', 'adult', 'desktop', 'gee', 'knight', 'titl', 'honor', 'drank', 'septemb', 'muffin', 'zoo', 'toronto', 'raw', 'est', 'kiddo', 'sob', 'brian', 'curious', 'condit', 'yell', 'shaun', 'anybodi', 'pill', 'highlight', 'male', 'jersey', 'alcohol', 'nz', 'homemad', 'ow', 'unit', 'flick', 'hahahah', 'spammer', 'wild', 'north', 'donat', 'login', 'unabl', 'conf', 'aye', 'financ', 'atl', 'feder', 'grape', 'default', 'wise', 'phoenix', 'knw', 'develop', 'softbal', 'appoint', 'delay', 'accomplish', 'sweat', 'compar', 'nois', 'insomnia', 'damag', 'ace', 'headphon', 'lebron', 'truck', 'bedtim', 'yess', 'melbourn', 'moro', 'geographi', 'faith', 'grown', 'allerg', 'eric', 'chines', 'bein', 'en', 'target', 'havn', 'victoria', 'heel', 'doughnut', 'guest', 'entri', 'brb', 'eu', 'coverag', 'mari', 'gb', 'counti', 'dye', 'cyrus', 'titan', 'pocket', 'tweepl', 'common', 'leavin', 'regret', 'maker', 'sd', 'abov', 'lectur', 'gona', 'footbal', 'peanut', 'ahah', 'wud', 'fade', 'cam', 'yer', 'jacket', 'tragic', 'tomfelton', 'realiti', 'tap', 'mass', 'lighten', 'playin', 'snuggl', 'retard', 'specif', 'strength', 'alancarr', 'pleasant', 'pa', 'bleh', 'tat', 'relationship', 'princ', 'allen', 'etsi', 'queen', 'â£', 'preview', 'chilli', 'battl', 'weak', 'smash', 'mann', 'addit', 'opera', 'standard', 'gir', 'oliv', 'polit', 'easter', 'thai', 'mickey', 'farm', 'pig', 'i�m', 'oprah', 'lean', 'cuppa', 'tab', 'lightn', 'yike', 'brooklyn', 'mega', 'indoor', 'strang', 'shade', 'reunion', 'mrs', 'potter', 'dev', 'mask', 'general', 'frm', 'fox', 'wknd', 'toy', 'org', 'tournament', 'funer', 'easili', 'meat', 'societi', 'bacon', 'winner', 'thread', 'fool', 'lemon', 'tim', 'afterward', 'japan', 'luca', 'sake', 'border', 'laura', 'reward', 'detroit', 'print', 'stuf', 'purpl', 'josh', 'german', 'porn', 'spymast', 'coke', 'privat', 'worker', 'trash', 'jst', 'belli', 'britain', 'disgust', 'greek', 'steak', 'smiley', 'therealjordin', 'sunglass', 'apt', 'despit', 'loung', 'youngq', 'shoulda', 'coursework', 'wood', 'pancak', 'sam', 'nephew', 'spirit', 'meeee', 'cherri', 'shoulder', 'z', 'cinema', 'concern', 'size', 'decemb', 'woop', 'sniff', 'hasnt', 'picnic', 'purs', 'noch', 'goodi', 'bruis', 'smith', 'spotifi', 'escap', 'negat', 'dull', 'comin', 'singer', 'lauren', 'william', 'xp', 'rabbit', 'field', 'itchi', 'bound', 'greatest', 'twittervers', 'eve', 'fi', 'cramp', 'jim', 'pineappl', 'grumpi', 'andyhurleyday', 'garag', 'resourc', 'cruel', 'imposs', 'morrow', 'farrah', 'warn', 'hmmmm', 'pound', 'dc', 'wi', 'que', 'ikea', 'kevin', 'employ', 'fairi', 'natur', 'windi', 'damnit', 'gna', 'charli', 'content', 'trick', 'nooooo', 'abus', 'volleybal', 'promo', 'austin', 'horni', 'steph', 'oper', 'ant', 'encourag', 'splash', 'stolen', 'unpack', 'browni', 'six', 'bastard', 'omfg', 'tick', 'sunbath', 'feedback', 'career', 'lj', 'nadal', 'toilet', 'mia', 'bay', 'tempt', 'dalla', 'artist', 'simpli', 'lili', 'shini', 'section', 'itali', 'wind', 'loan', 'whaddup', 'thus', 'scar', 'notebook', 'richard', 'charlott', 'bing', 'communiti', 'marriag', 'wierd', 'esp', 'yeahh', 'hm', 'stone', 'fee', 'fanci', 'lower', 'clip', 'vine', 'geek', 'wooo', 'squar', 'dublin', 'visual', 'wore', 'wana', 'upgrad', 'gun', 'enter', 'mount', 'yuck', 'balloon', 'bk', 'andrew', 'virtual', 'antibiot', 'dam', 'hangin', 'dis', 'sink', 'selena', 'survivor', 'ocean', 'gfalcon', 'engin', 'bueno', 'ou', 'dong', 'indonesia', 'exchang', 'sandwich', 'remix', 'borrow', 'daisi', 'beleiv', 'hee', 'iv', 'dawn', 'hundr', 'grind', 'trey', 'confid', 'avatar', 'pup', 'tori', 'gs', 'fur', 'sea', 'yessss', 'ay', 'otherwis', 'accord', 'lion', 'africa', 'wal', 'mart', 'plain', 'unfollow', 'homi', 'icon', 'az', 'yucki', 'ferri', 'younger', 'sh', 'ian', 'elect', 'nowher', 'hugh', 'accident', 'pie', 'pair', 'crush', 'sara', 'stephenfri', 'manchest', 'nudg', 'spice', 'countdown', 'patient', 'blush', 'ooooh', 'brace', 'safari', 'grew', 'fred', 'nyt', 'thingi', 'woooo', 'debbi', 'hotti', 'holla', 'uniform', 'ouchi', 'influenc', 'hawaii', 'role', 'yayi', 'dayi', 'orient', 'leader', 'plenti', 'suitcas', 'whos', 'di', 'tyler', 'momma', 'destroy', 'compet', 'per', 'glee', 'nom', 'footag', 'jk', 'mel', 'favor', 'lang', 'opportun', 'audit', 'theyr', 'soooooooo', 'rn', 'footi', 'mimi', 'cnt', 'seven', 'spoke', 'cs', 'zombi', 'nicol', 'usa', 'edward', 'pacif', 'tee', 'stoke', 'comfi', 'shuffl', 'rang', 'certifi', 'bak', 'berlin', 'termin', 'ranger', 'luckili', 'hater', 'bow', 'demo', 'chop', 'tomorow', 'mag', 'jog', 'somethin', 'lvatt', 'smh', 'phil', 'snore', 'serv', 'denver', 'asian', 'shape', 'deni', 'liverpool', 'cereal', 'cuti', 'blink', 'shane', 'twist', 'chelsea', 'mcflyharri', 'disappear', 'tortur', 'rice', 'blanket', 'vampir', 'soda', 'iamjonathancook', 'haircut', 'banner', 'overal', 'jen', 'charm', 'frog', 'gahhh', 'museum', 'interfac', 'technic', 'taxi', 'ck', 'shud', 'medic', 'jordan', 'britney', 'slower', 'propos', 'passion', 'podcast', 'reserv', 'interact', 'eff', 'campus', 'prevent', 'secur', 'guid', 'applic', 'rout', 'britneyspear', 'eww', 'gum', 'becam', 'whose', 'hii', 'jenni', 'nj', 'heavi', 'domin', 'microsoft', 'tx', 'brighton', 'lawn', 'marilyn', 'coach', 'trade', 'tracecyrus', 'mario', 'flew', 'byee', 'pete', 'stink', 'stun', 'suppli', 'comic', 'irrit', 'lo', 'pine', 'item', 'donni', 'tuck', 'dig', 'veggi', 'bio', 'electr', 'unexpect', 'dvds', 'grass', 'fantasi', 'spoiler', 'whoever', 'claim', 'unemploy', 'anatomi', 'havin', 'harder', 'diego', 'jeez', 'anticip', 'sarah', 'procrastin', '^', 'cure', 'msg', 'ughhh', 'whether', 'thang', 'florida', 'nacho', 'vodka', 'rise', 'sausag', 'alexalltimelow', 'doc', 'agent', 'santa', 'puke', 'requir', 'formula', 'yaaay', 'basketbal', 'devil', 'discuss', 'tad', 'pix', 'grrrrr', 'rude', 'luke', 'nt', 'pressur', 'joint', 'tyreser', 'beyond', 'amanda', 'stephani', 'disabl', 'lisa', 'subject', 'joelmadden', 'ventur', 'lem', 'pleasee', 'ws', 'wen', 'fawcett', 'iron', 'glasgow', 'tmr', 'kim', 'sleepov', 'alik', 'choke', 'counter', 'march', 'equal', 'spain', 'basement', 'zack', 'similar', 'prove', 'discoveri', 'mandyyjirouxx', 'pimpl', 'staci', 'ann', 'scott', 'oven', 'damnn', 'bros', 'thousand', 'author', 'kreme', 'speaker', 'visa', 'tryna', 'lens', 'kirstiealley', 'icecream', 'sonic', 'platform', 'hint', 'terrifi', 'gather', 'pitch', 'vancouv', 'punk', 'andyclemmensen', 'officialnjona', 'tall', 'sticki', 'sean', 'monkey', 'third', 'motorcycl', 'plate', 'cow', 'peterfacinelli', 'deadlin', 'stack', 'surround', 'nerd', 'chrome', 'tradit', 'prize', 'demand', 'detox', 'jesus', 'ding', 'ubuntu', 'atlanta', 'tablet', 'illeg', 'aaah', 'cinnamon', 'unfair', 'solut', 'pac', 'waitin', 'tomoz', 'guitarist', 'strike', 'brandon', 'souljaboytellem', 'turtl', 'justin', 'tend', 'forecast', 'whore', 'atleast', 'chapter', 'construct', 'fund', 'huhu', 'le', 'thr', 'map', 'minus', 'bobbi', 'stalker', 'mourn', 'sweden', 'statement', 'rode', 'onion', 'plug', 'shave', 'packag', 'leno', 'sheesh', 'acct', 'poppin', 'potato', 'earring', 'scream', 'retail', 'score', 'divorc', 'megan', 'theellenshow', 'messi', 'beth', 'canon', 'latter', 'display', 'attract', 'pal', 'semest', 'urgh', 'ed', 'succeed', 'purchas', 'sorta', 'rap', 'stabl', 'yrs', 'remov', 'plastic', 'eva', 'iamdiddi', 'tub', 'abandon', 'bud', 'planet', 'oi', 'xxxx', 'wrench', 'ip', 'pirat', 'duti', 'brunch', 'wnt', 'hardcor', 'cyber', 'wt', 'keith', 'por', 'todd', 'split', 'dy', 'corrupt', 'contempl', 'filipino', 'jacki', 'ho', 'drove', 'assist', 'breaker', 'db', 'separ', 'sue', 'pin', 'wipe', 'nevermind', 'mode', 'lan', 'awh', 'jacob', 'aus', 'flake', 'oreo', 'threaten', 'increas', 'iz', 'juss', 'twitterfox', 'assembl', 'shi', 'spare', 'lag', 'roller', 'and/or', 'multipl', 'lyric', 'cav', 'gd', 'reallli', 'scrub', 'whenev', 'lappi', 'schofe', 'whisper', 'bliss', 'fulli', 'kudo', 'heey', 'katyperri', 'ijustin', 'sensit', 'auto', 'ministri', 'advert', 'prison', 'fone', 'disneyland', 'dwight', 'audio', 'twister', 'gray', 'pan', 'scrap', 'appt', 'dawnrichard', 'castl', 'british', 'thee', 'chin', 'mucho', 'myrtl', 'disturb', 'wth', 'tabl', 'select', 'pea', 'layout', 'leagu', 'chile', 'poetri', 'motion', 'brave', 'jerri', 'kung', 'fuckin', 'cheesi', 'belong', 'viva', 'blister', 'med', 'earthquak', 'vitamin', 'string', 'bibl', 'zone', 'deliv', 'nu', 'tmw', 'jewel', 'paramor', 'rocki', 'yasmina', 'alan', 'proof', 'chose', 'photoshoot', 'silenc', 'cheek', 'silent', 'heheh', 'mc', 'jerk', 'teh', 'fa', 'circus', 'dia', 'mar', 'frank', 'anna', 'devic', 'urgent', 'wale', 'garlic', 'draft', 'gurl', 'munch', 'sticker', 'orang', 'aim', 'opinion', 'lemonad', 'metro', 'layin', 'irvin', 'sweetheart', 'weed', 'rotten', 'zealand', 'rant', 'progress', 'buck', 'ii', 'swap', 'convert', 'bradiewebbstack', 'woah', 'unlik', 'labor', 'depart', 'yanke', 'bot', 'sampl', 'potenti', 'bestfriend', 'tetri', 'log', 'janet', 'xoxoxo', 'mexico', 'outdoor', 'primari', 'diari', 'canadian', 'theater', 'romant', 'envi', 'tgif', 'injuri', 'aa', 'lovee', 'sunset', 'tshirt', 'curs', 'nerv', 'ni', 'opposit', 'dragon', 'bush', 'neeed', 'ga', 'hd', 'mental', 'secondstomar', 'panda', 'nowaday', 'tape', 'thunderstorm', 'awar', 'advantag', 'thesi', 'dairi', 'doug', 'bomb', 'lotion', 'fest', 'brandi', 'balanc', 'poke', 'poker', 'postpon', 'kidnap', 'protest', 'norway', 'billyraycyrus', 'wrap', 'wolverin', 'andrea', 'rumor', 'heheheh', 'fudg', 'cape', 'wiv', 'shanedawson', 'resum', 'hub', 'kimkardashian', 'paranoid', 'drew', 'miracl', 'consum', 'backup', 'european', 'sophi', 'restor', 'purpos', 'b_club', 'steel', 'peel', 'elder', 'hockey', 'sleeep', 'edinburgh', 'toooo', 'reader', 'effort', 'tue', 'hurrican', 'loui', 'crystal', 'experienc', 'oo', 'manual', 'invest', 'hole', 'routin', 'err', 'meee', 'legit', 'frankiethesat', 'sheep', 'puppet', 'wkend', 'ka', 'kristin', 'expir', 'occas', 'looov', 'guna', 'teas', 'musician', 'asot', 'toss', 'frame', 'monster', 'altho', 'deck', 'russian', 'sr', 'upper', 'pastor', 'piginthepok', 'knit', 'rawr', 'reaction', 'silver', 'cider', 'morro', 'commentari', 'christma', 'poni', 'sp', 'patrol', 'humid', 'shark', 'cg', 'unlimit', 'fl', 'particip', 'lou', 'timezon', 'margarita', 'denise_richard', 'fallen', 'twitterland', 'tampa', 'naw', 'wrk', 'digit', 'li', 'chase', 'mitch', 'rick', 'dd', 'unhappi', 'gomez', 'vocal', 'pe', 'fortun', 'profit', 'bob', 'shoutout', 'renew', 'ceo', 'sup', 'argentina', 'glow', 'core', 'wassup', 'feast', 'kristen', 'sri', 'netbook', 'employe', 'hs', 'wot', 'michell', 'calcul', 'dannygokey', 'bitter', 'notif', 'leo', 'autograph', 'songzyuuup', 'va', 'uber', 'persist', 'wayyy', 'eddi', 'adopt', 'balconi', 'bucket', 'wolf', 'infam', 'lab', 'flow', 'python', 'skate', 'dylan', 'liar', 'ego', 'babygirlpari', 'trail', 'cab', 'freaki', 'flop', 'antonio', 'sooner', 'twhirl', 'fwd', 'skinni', 'solv', 'val', 'youll', 'aid', 'tomorro', 'chillax', 'estat', 'broadcast', 'sequel', 'dessert', 'lastnight', 'bewar', 'alexi', 'manga', 'mandi', 'icki', 'haveyouev', 'innoc', 'bagel', 'intens', 'twitterif', 'solo', 'recess', 'galleri', 'roni', 'junior', 'wil', 'nbc', 'fame', 'religi', 'loll', 'spec', 'leas', 'arghhh', 'partner', 'document', 'uninstal', 'acid', 'ab', 'nativ', 'curtain', '=p', 'necessari', 'wooooo', 'jennettemccurdi', 'dislik', 'task', 'mai', 'den', 'virginia', 'abbi', 'justic', 'smaller', 'sack', 'exampl', 'dannywood', 'happier', 'aka', 'adob', 'giveaway', 'hound', 'hoodi', 'upstair', 'funnier', 'ai', 'impati', 'resort', 'slip', 'rt', 'bump', 'op', 'tore', 'angl', 'kl', 'former', 'prolli', 'carrot', 'offlin', 'ahhhhh', 'stil', 'torn', 'mango', 'tutori', 'dwighthoward', 'snl', 'cleveland', 'alexa', 'gloomi', 'stiff', 'belgium', 'beast', 'tbh', 'certif', 'christina', 'textur', 'papa', 'economi', 'alien', 'advanc', 'ummmm', 'codi', 'firmwar', 'reli', 'amen', 'homesick', 'headin', 'jet', 'karen', 'televis', 'geez', 'behalf', 'wwdc', 'rene', 'housew', 'hol', 'trainer', 'twitterberri', 'numb', 'hunger', 'petit', 'faster', 'wk', 'fo', 'lung', 'dmv', 'amsterdam', 'roger', 'popular', 'weigh', 'bugger', 'novel', 'chloe', 'biggi', 'horror', 'comedi', 'scroll', 'shorten', 'golden', 'myweak', 'hatton', 'howard', 'mint', 'doggi', 'vertic', 'pit', 'australian', 'ne', 'costum', 'bass', 'presum', 'treadmil', 'haaa', 'offens', 'fiesta', 'mba', 'gadget', 'mp', 'fyi', 'disc', 'bella', 'ohio', 'dedic', 'wrestl', 'rss', 'thts', 'float', 'eight', 'fr', 'wif', 'elmo', 'amount', 'derbi', 'recept', 'jeff', 'hiccup', 'lmaoo', 'anxious', 'milan', 'contain', 'erika', 'imac', 'peter', 'sour', 'skittl', 'flame', 'cellphon', 'troll', 'mow', 'knowledg', 'dissapear', 'msgs', 'perri', 'listenin', 'fran', 'jimmi', 'chubbi', 'salon', 'rustyrocket', 'lexi', 'dramat', 'becuas', 'heyyy', 'psp', 'jeremi', 'photograph', 'concentr', 'har', 'davejmatthew', 'sangria', 'slumber', 'debat', 'und', 'extens', 'yahh', 'spectacular', 'brit', 'traci', 'expert', 'kaya', 'pero', 'temp', 'sting', 'aj', 'downsid', 'blossom', 'toll', 'breast', 'determin', 'predict', 'zero', 'ashton', 'chi', 'associ', 'condo', 'belov', 'xxxxx', 'wuz', 'bun', 'sj', 'ink', 'scale', 'wire', 'cycl', 'es', 'dougi', 'classmat', 'lime', 'shrimp', 'blahh', 'hotter', 'legend', 'murder', 'geo', 'boob', 'territori', 'password', 'valu', 'kiwi', 'candlelight', 'snake', 'lool', 'itouch', 'patti', 'recycl', 'ik', 'manson', 'faint', 'birmingham', 'vanilla', 'somewhat', 'ako', 'repres', 'pathet', 'bi', 'defens', 'pcd', 'hatch', 'attent', 'hahahahahaha', 'aloud', 'jessi', 'juici', 'brook', 'nova', 'buffalo', 'feblub', 'cod', 'grumbl', 'tooo', 'diabet', 'soundtrack', 'blogger', 'cruis', 'werent', 'pillow', 'ward', 'woe', 'warp', 'mexican', 'funn', 'fart', 'tis', 'benefit', 'sc', 'goofi', 'unlock', 'tina', 'manila', 'berri', 'therapi', 'talaga', 'bsb', 'yey', 'properti', 'pattinson', 'wes', 'mcdonald', 'recoveri', 'shouldnt', 'twilightfairi', 'hahha', 'bail', 'spore', 'panic', 'brake', 'owner', 'bbi', 'isplay', 'marathon', 'mas', 'gooood', 'jasmin', 'fluffi', 'lancearmstrong', 'killer', 'duh', 'chef', 'constant', 'wouldv', 'sentenc', 'lonesom', 'dine', 'bcuz', 'struggl', 'squirrel', 'upsid', 'storag', 'overcast', 'diamond', 'sandal', 'loos', 'usernam', 'nkangel', 'bachelorett', 'danger', 'thrill', 'jane', 'immedi', 'lap', 'compat', 'markhoppus', 'cera', 'paparazzi', 'paperwork', 'pile', 'slurpe', 'hottest', 'ala', 'kk', 'disast', 'playlist', 'slice', 'rafa', 'habit', 'pork', 'poem', 'booo', 'nkotb', 'poss', 'perez', 'pond', 'wherev', 'hooker', 'cal', 'attach', 'stair', 'jason_manford', 'beef', 'choc', 'aahh', 'butterfli', 'drizzl', 'reinstal', 'coldplay', 'eastern', 'octob', 'stood', 'gm', 'portion', 'sori', 'sway', 'clarkson', 'jojo', 'seo', 'peed', 'mrskutcher', 'evan', 'grin', 'ginger', 'district', 'appeal', 'day/night', 'tsk', 'usb', 'stewart', 'inning', 'factori', 'toddler', 'coin', 'asid', 'plurk', 'steam', 'gin', 'tent', 'victori', 'perspect', 'rhyme', 'leon', 'erm', 'mamma', 'havnt', 'nighter', 'dive', 'chew', 'halfway', 'rape', 'mirror', 'becca', '\\\\', 'ahahaha', 'glove', 'tooooo', 'apprentic', 'firework', 'wishin', 'ds', 'redicul', 'dip', 'grrrrrr', 'rio', 'automat', 'mmitchelldaviss', 'engag', 'fucker', 'amber', 'korean', 'kit', 'neighbour', 'teenag', 'prop', 'mam', 'ol', 'ahem', 'hotmail', 'intuit', 'psych', 'mcr', 'halo', 'transport', 'subscrib', 'earl', 'shabbi', 'oasi', 'dfizzi', 'kentucki', 'captain', 'grant', 'sip', 'nkairplay', 'cracker', 'hunni', 'supernatur', 'guilt', 'pow', 'nooooooo', 'gal', 'await', 'sunlight', 'liz', 'director', 'bedroom', 'eachoth', 'useless', 'kenni', 'aaron', 'oversea', 'vibe', 'cowboy', 'cds', 'doh', 'stamp', 'curri', 'bat', 'chemistri', 'signal', 'cher', 'kg', 'flag', 'pepsi', 'simon', 'aja', 'delish', 'chore', 'bri', 'clair', 'cobra', 'nake', 'sofa', 'sober', 'armi', 'swell', 'manni', 'abil', 'stickam', 'goodnit', 'sermon', 'cub', 'cha', 'marti', 'bbc', 'fck', 'au', 'w/out', 'paulaabdul', 'seattl', 'polish', 'slot', 'factor', 'wayn', 'excus', 'centuri', 'waz', 'ditto', 'critic', 'poll', 'il', 'bikini', 'colin', 'cabin', 'krisallenmus', 'neighborhood', 'krispi', 'replay', 'lax', 'grandpar', 'willig', 'debut', 'cole', 'candl', 'om', 'jew', 'naman', 'hurley', 'humour', 'blew', 'ming', 'shelbi', 'bryant', 'cupboard', 'cuban', 'judez_xo', 'miseri', 'mute', 'km', 'whack', 'sooooooooo', 'wendi', 'cdc', 'vaccin', 'jone', 'rewrit', 'sunscreen', 'pleeeeeas', 'crib', 'thedebbyryan', 'strait', 'hai', 'bid', 'mikeg', 'wound', 'ryanstar', 'coma', 'coolest', 'instrument', 'cleaner', 'dpak', 'victim', 'casa', 'batch', 'backstreetboy', 'genuin', 'drinkin', 'dozen', 'heyyyi', 'bran', 'celtic', 'christ', 'outcom', 'incom', 'youuuu', 'insert', 'sarcasm', 'herb', 'scotland', 'netherland', 'bond', 'cheaper', 'patrick', 'bawl', 'inner', 'eli', 'ovr', 'jackson', 'crumb', 'fragil', 'scoop', 'forest', 'wimp', 'houston', 'buka', 'anyhow', 'chrispirillo', 'insect', 'tropic', 'blogspot', 'wiff', 'straighten', 'egypt', 'hahahahahahahaha', 'kansa', 'missi', 'oooo', 'lololol', 'vampirefreak', 'crop', 'batman', 'mikey', 'worm', 'nathanfillion', 'harsh', 'preorder', 'velcrosho', 'ultra', 'kardashian', 'atlant', 'introduc', 'dodlebugdebz', 'yous', 'jumper', 'keza', 'ðºð°ðº', 'ð½ð°', 'ð¸', 'barney', 'pod', 'damm', 'tequila', 'sassi', 'browser', 'scrabbl', 'rollercoast', 'printer', 'fourth', 'carradin', 'vers', 'php', 'ambit', 'discount', 'ethic', 'belt', 'shelter', 'mrtweet', 'weirdest', 'tornado', 'bride', 'warranti', 'skirt', 'flaw', 'impuls', 'affect', 'ooohh', 'rec', 'conquer', 'budget', 'chain', 'ram', 'recal', 'indiana', 'brrr', 'swamp', 'loooong', 'exempt', 'backward', 'memo', 'yest', 'nina', 'curl', 'bcoz', 'gps', 'bulli', 'clash', 'tile', 'howdi', 'ralli', 'bench', 'owen', 'wilson', 'northern', 'ireland', 'lor', 'reboot', 'tele', 'pilot', 'chart', 'whoo', 'tj', 'maxx', 'transfer', 'sou', 'nokia', 'disco', 'conflict', 'heal', 'bold', '_anne', 'champion', 'surfer', 'individu', 'whataburg', 'industri', 'advil', 'toward', 'tara', 'warrior', 'chariti', 'linux', 'spear', 'font', 'od', 'goldfish', 'tommorow', 'haunt', 'tripl', 'minc', 'mushroom', 'pepper', 'seed', 'nauseous', 'las', 'onm', 'thou', 'descript', 'complex', 'enorm', 'dunt', 'tower', 'brill', 'jobro', 'lynn', 'region', 'brekki', 'condol', 'hsm', 'maui', 'seek', 'hv', 'kylepetti', 'freeway', 'involv', 'sytycd', 'idc', 'educ', 'privaci', 'joey', 'happenin', 'violin', 'flood', 'lg', 'looooov', 'thirti', 'hp', 'restart', 'wut', 'cya', 'timmi', 'wa', 'augh', 'sinus', 'sandi', 'plymouth', 'embed', 'leed', 'berni', 'jami', 'tote', 'deff', 'rat', 'mutual', 'bald', 'statist', 'cardiff', 'glorious', 'tmi', 'spaghetti', 'kfc', 'ambul', 'ddub', 'robot', 'strand', 'badg', 'shefali', 'cord', 'thomasfiss', 'puzzl', 'blake', 'donâ´t', 'financi', 'crisi', 'overnight', 'turkey', 'notorioustori', 'oki', 'dooo', 'ud', 'lollll', 'pj', 'barbi', 'lyk', 'archuleta', 'ot', 'chuf', 'slide', 'leah', 'rank', 'allison', 'rs', 'prioriti', 'mich', 'overtim', 'captur', 'christian', 'spotlight', 'lolol', 'booooo', 'crane', 'gelato', 'worn', 'bra', 'classi', 'exit', 'char', 'shamim', 'championship', 'alaska', 'linkin', 'preach', 'scorpio', 'generat', 'caitlin', 'dictionari', 'flatter', 'navig', 'drift', 'dollhous', 'govt', 'nes', 'dunkin', 'emailunlimit', 'gail', 'wah', 'ping', 'ross', 'arsenal', 'molli', 'java', 'treasur', 'ftl', 'precious', 'robkardashian', 'sarcast', 'abc', 'gag', 'dreamt', 'medicin', 'column', 'moonfry', 'ciara', 'greg', 'fiction', 'reali', 'nigga', 'empir', 'melissa', 'silverston', 'libbi', 'inn', 'bj', 'temperatur', 'pose', 'jonathan', 'giraff', 'celli', 'alli', 'songz', 'format', 'citizenship', 'buri', 'tomato', 'stab', 'sensor', 'bookmark', 'centr', 'bnp', 'skool', 'recharg', 'qualifi', 'earphon', 'doze', 'barrel', 'laid', 'wallpap', 'perman', 'css', 'lbs', 'valid', 'mitchel', 'carb', 'shallow', 'doo', 'junki', 'oth', 'ver', 'omgg', 'yã¤i', 'meetup', 'charl', 'lewi', 'initi', 'danecook', 'heya', 'sod', 'xxxxxxx', 'sheer', 'path', 'carl', 'bree', 'natali', 'chap', 'learnt', 'int', 'pffft', 'booti', 'sooooooo', 'israel', 'beggin', 'quicker', 'newcastl', 'duno', 'lamb', 'comm', 'sew', 'ð½ðµ', 'olymp', 'emoisforluv', 'calf', 'kimmi', 'amazingg', 'payday', 'srsli', 'ham', 'penni', 'whistl', 'volum', 'milo', 'diagnos', 'suncream', 'cricket', 'luggag', 'lolli', 'sang', 'loyal', 'ladygaga', 'kenny_wallac', 'peach', 'roomi', 'cox', 'rash', 'tumblr', 'roach', 'thnks', 'ey', 'westendactress', 'raffl', 'soni', 'devin', 'brum', 'auburn', 'drum', 'rai', 'bleach', 'rachmurrayx', 'desert', 'pitt', 'leather', 'darker', 'barn', 'rev', 'cram', 'kirk', 'spock', 'profession', 'kewl', 'sci', 'sprint', 'diss', 'tot', 'twitterfon', 'mona', 'overus', 'rico', 'chad', 'mkay', 'multi', 'newli', 'dh', 'raspberri', 'bigdaw', 'ph', 'kristenstewart', 'awaltzforanight', 'mcdo', 'sniffl', 'haz', 'huggl', 'funnn', 'blokeslib', 'hog', 'hahahahah', 'cp', 'sharon', 'asshol', 'foul', 'pike', 'sidekick', 'frend', 'dito', 'abba', 'recogn', 'dancer', 'lalala', 'apa', 'dishwash', 'decent', 'bali', 'hyper', 'coool', 'ordinari', 'captiv', 'creek', 'regard', 'premier', 'blogher', 'freebi', 'submit', 'plaster', 'folder', 'vanessa', 'debit', 'cba', 'michigan', 'dust', 'funniest', 'prescript', 'occupi', 'yayyy', 'magnific', 'presid', 'telli', 'velvet', 'twelv', 'wookie', 'ebay', 'okayyy', 'outt', 'asham', 'pad', 'toenail', 'sg', 'stake', 'navi', 'gooo', 'bruna', 'beetlejuic', 'gute', 'dorm', 'jaw', 'ewan', 'sweati', 'sagada', 'adventur', 'trap', 'editor', 'mlexiehayden', 'denis', 'linda', 'niley', 'par', 'salli', 'hungov', 'afterparti', 'gawd', 'stat', 'acknowledg', 'wax', 'pong', 'cassi', 'pretzel', 'pandora', 'motor', 'shed', 'soderl', 'ughhhh', 'frozen', 'yogurt', 'wasp', 'xbllygbsn', 'essenti', 'relev', 'stranger', 'upp', 'xxxxxx', 'tasha', 'twittervill', 'udah', 'loop', 'officialtila', 'sunris', 'flavour', 'methink', 'chippi', 'jail', 'unlov', 'averag', 'medium', 'tighter', 'neat', 'mighti', 'express', 'omgosh', 'arent', 'crunchyk', 'asia', 'sistah', 'witch', 'hola', 'meeeee', 'mee', 'alyssa', 'rib', 'recruit', 'humm', 'blogtv', 'method', 'crunch', 'larri', 'evryon', 'si', 'ramp', 'offset', 'electron', 'jamba', 'nonsens', 'handsom', 'dock', 'neva', 'sonni', 'ofcours', 'marvel', 'revolut', 'plugin', 'hardest', 'shutey', 'unbear', 'multitask', 'asda', 'sleepless', 'anywho', 'slp', 'semi', 'maplestori', 'scotti', 'barf', 'kaput', 'central', 'utter', 'brillianc', 'xdd', 'cheeseburg', 'prime', 'teen', 'blockhead', 'christin', 'sacr', 'multipli', 'bristol', 'shamara', 'aiden', 'convent', 'moral', 'vice', 'petewentz', 'gang', 'blackout', 'prep', 'shoppin', 'newslett', 'cultur', 'np', 'ict', 'sharp', 'et', 'ticklemejoey', 'bracelet', 'threat', 'visitor', 'unwind', 'ap', 'tt', 'concur', 'outer', 'beyonc', 'marley', 'mock', 'champagn', 'loneli', 'fiona', 'behav', 'anxieti', 'calend', 'kaotic', 'sprinkl', 'freshman', 'symbol', 'een', 'extend', 'collar', 'chica', 'yeap', 'rerun', 'canal', 'blade', 'â\\x80\\x93', 'demon', 'abi', 'juga', 'arrest', 'bin', 'achi', 'please', 'macca', 'folow', 'raisin', 'sail', 'concept', 'mma', 'fare', 'barcelona', 'yesh', 'lit', 'thur', 'mermaid', 'elliott', 'nintendo', 'soar', 'produc', 'freezer', 'familiar', 'slack', 'keen', 'creep', 'vision', 'wander', 'pud', 'brazilian', 'coincid', 'casino', 'claudia', 'recit', 'accent', 'seafood', 'offend', 'leftov', 'rockband', 'nicki', 'ranch', 'dice', 'khloekardashian', 'diddi', 'endless', 'frnds', 'whyy', 'hut', 'yearbook', 'litter', 'amazinggg', 'southern', 'repair', 'filter', 'volunt', 'spongebob', 'absenc', 'yoga', 'sensat', 'militari', 'welll', 'gilmor', 'grate', 'hamlet', 'lettuc', 'relli', 'dnb', 'preston', 'ly', 'mbp', 'tweetin', 'booth', 'banksyart', 'neil', 'sk', 'upcom', 'gain', 'jennif', 'refus', 'genet', 'deari', 'carpet', 'samuel', 'kidney', 'wheel', 'sneak', 'blunt', 'riskybusinessmb', 'illustr', 'shayna', 'derek', 'simpson', 'denmark', 'handi', 'dank', 'poopi', 'arghh', 'fresno', 'salsa', 'tame', 'cb', 'logo', 'jr', 'injur', 'juz', 'lc', 'unreal', 'stroll', '__', 'digg', 'hulu', 'karaok', 'farewel', 'pleaseee', 'sharehold', 'dividend', 'bs', 'owl', 'cheerio', 'heartmileycyrus', 'rey', 'ave', 'brutal', 'horrid', 'cur', 'slap', 'iâ´m', 'decor', 'clever', 'chronicl', 'linnetwood', 'themselv', 'cus', 'nw', 'mixtap', 'ooc', 'whew', 'written', 'kraseybeauti', 'sub', 'pilat', 'driveway', 'copper', 'peak', 'venu', 'accompani', 'dump', 'mandarin', 'grrrrrrrr', 'sarap', 'deed', 'depot', 'boredd', 'noooooooo', 'ryanseacrest', 'overslept', 'meyer', 'threadless', 'lilyroseallen', 'maria', 'summit', 'strategi', 'ttyl', 'roof', 'textil', 'percent', 'dayyy', 'beatwittyparti', 'spark', 'drill', 'loveyou', 'environ', 'commit', 'spiffi', 'pk', 'ss', 'zac', 'youuu', 'diggin', 'flirt', 'cope', 'yn', 'terror', 'mite', 'stephen', 'blurri', 'shell', 'tc', 'stretch', 'urban', 'dose', 'goal', 'hall', 'explan', 'ribbon', 'pr', 'immens', 'snitch', 'firewal', 'noooooo', 'hamster', 'stilll', 'headlin', 'korea', 'ceremoni', 'suspend', 'remedi', 'nk', 'vou', 'unev', 'gim', 'amd', 'suzeormanshow', 'baar', 'caffein', 'palac', 'civic', 'effici', 'donâ\\x80\\x99t', 'drowsi', 'intrigu', 'necklac', 'jun', 'aah', 'mannn', 'sync', 'qot', 'setup', 'groov', 'anaheim', 'reminisc', 'bol', 'conspiraci', 'wel', 'wallet', 'trio', 'carolina', 'looong', 'maddi', 'regent', 'tin', 'alic', 'reschedul', 'stuffi', 'conserv', 'abroad', 'lei', 'bei', 'nin', 'mash', 'dim', 'ducati', 'dot', 'sroxi', 'torrent', 'ancient', 'powerbook', 'unsubscrib', 'parrot', 'soap', 'matur', 'grandmoth', 'peek', 'penang', 'popstar', 'nag', 'explod', 'combo', 'hashtag', 'umbrella', 'lacross', 'poison', 'virgin', 'whatcha', 'exclus', 'built', 'denni', 'jelous', 'filthi', 'beliv', 'the_real_shaq', 'madisonmitchel', 'fearnecotton', 'hectic', 'whiten', 'hotdog', 'sponsor', 'gether', 'februari', 'oedipus', 'reall', 'w/you', 'strip', '=s', 'newspap', 'crab', 'courtney', 'unlucki', 'rum', 'grandfath', 'popcorn', 'organis', 'sec', 'poland', 'shatter', 'mx', 'askin', 'mein', 'johnson', 'jasonbradburi', 'sloppi', 'ft', 'votemileycyrus', 'forgotten', 'omgsh', 'treatment', 'dodgi', 'àª\\x82', 'smother', 'penalti', 'bonus', 'veg', 'thrown', 'russia', 'nomad', 'arsebiscuit', 'chrishasboob', 'gahh', 'zach', 'lilpecan', 'blizzard', 'nadalnew', 'rog', 'swag', 'hillsong', 'pox', 'minist', 'boobi', 'tomorrrow', 'flatmat', 'arggh', 'fizz', 'thro', 'happili', 'crank', 'myer', 'lydia', 'heartburn', 'paula', 'ewww', 'ginorm', 'nightt', 'complaint', 'platinum', 'ldn', 'begon', 'ch', 'shaw', 'lotteri', 'richardwiseman', 'teemonst', 'habbit', 'pageant', 'global', 'dinn', 'cooker', 'byeee', 'alexandramus', 'flawless', 'pleeas', 'tantrum', 'trophi', 'donkey', 'chamber', 'thailand', 'numpti', '~~', 'thewildjok', 'spitphyr', 'bebe', 'olympus', 'len', 'acj', 'sheffield', 'shadez', 'kandychaz', 'flask', 'mew', 'shelli', 'frankenstein', 'mandy_emmerson', 'mick', 'cougar', 'roar', 'melodi', 'highland', 'woahh', 'timer', 'kyli', 'prejudic', 'pale', 'meganbul', 'brighter', 'stanley', 'wolfi', 'boy_kill_boy', 'reread', 'ensur', 'ahahaa', 'billy_burk', 'dizzi', 'vomit', 'boopti', 'throttl', 'marshmallow', 'tra', 'minivan', 'sti', 'samantha', 'ditch', 'destini', 'crystalchappel', 'vienna', 'leila', 'nausea', 'shook', 'goodsex', 'wifey', 'tow', 'kellyolexa', 'sashakan', 'sadden', 'rumour', 'fraud', 'dontforgetchao', 'scone', 'foh', 'loner', 'orkut', 'paulpuddifoot', 'pissin', 'popculturezoo', 'nicer', 'spontan', 'guin', 'bowwow', 'spade', 'wade', 'orchestra', 'coconut', 'daze', 'yelyahwilliam', 'cryin', 'coy', 'jodabon', 'settler', 'splendid', 'foil', 'luvv', 'twiter', 'pout', 'embarrass', 'logi', 'nest', 'lodg', 'racist', 'devill', 'jungl', 'greekpeac', 'bks', 'aidan', 'photogen', 'municip']\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nltk import FreqDist\n",
+ "\n",
+ "all_words = [word for word_list in subset_data['text_processed'] for word in word_list]\n",
+ "\n",
+ "freq_dist = FreqDist(all_words)\n",
+ "\n",
+ "top_words = freq_dist.most_common(5000)\n",
+ "\n",
+ "top_words = [word[0] for word in top_words]\n",
+ "\n",
+ "print(top_words)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Building Features\n",
+ "\n",
+ "Now let's build the features. Using the top 5,000 words, create a 2-dimensional matrix to record whether each of those words is contained in each document (tweet). Then you also have an output column to indicate whether the sentiment in each tweet is positive. For example, assuming your bag of words has 5 items (`['one', 'two', 'three', 'four', 'five']`) out of 4 documents (`['A', 'B', 'C', 'D']`), your feature set is essentially:\n",
+ "\n",
+ "| Doc | one | two | three | four | five | is_positive |\n",
+ "|---|---|---|---|---|---|---|\n",
+ "| A | True | False | False | True | False | True |\n",
+ "| B | False | False | False | True | True | False |\n",
+ "| C | False | True | False | False | False | True |\n",
+ "| D | True | False | False | False | True | False|\n",
+ "\n",
+ "However, because the `nltk.NaiveBayesClassifier.train` class we will use in the next step does not work with Pandas dataframe, the structure of your feature set should be converted to the Python list looking like below:\n",
+ "\n",
+ "```python\n",
+ "[\n",
+ "\t({\n",
+ "\t\t'one': True,\n",
+ "\t\t'two': False,\n",
+ "\t\t'three': False,\n",
+ "\t\t'four': True,\n",
+ "\t\t'five': False\n",
+ "\t}, True),\n",
+ "\t({\n",
+ "\t\t'one': False,\n",
+ "\t\t'two': False,\n",
+ "\t\t'three': False,\n",
+ "\t\t'four': True,\n",
+ "\t\t'five': True\n",
+ "\t}, False),\n",
+ "\t({\n",
+ "\t\t'one': False,\n",
+ "\t\t'two': True,\n",
+ "\t\t'three': False,\n",
+ "\t\t'four': False,\n",
+ "\t\t'five': False\n",
+ "\t}, True),\n",
+ "\t({\n",
+ "\t\t'one': True,\n",
+ "\t\t'two': False,\n",
+ "\t\t'three': False,\n",
+ "\t\t'four': False,\n",
+ "\t\t'five': True\n",
+ "\t}, False)\n",
+ "]\n",
+ "```\n",
+ "\n",
+ "To help you in this step, watch the [following video](https://www.youtube.com/watch?v=-vVskDsHcVc) to learn how to build the feature set with Python and NLTK. The source code in this video can be found [here](https://pythonprogramming.net/words-as-features-nltk-tutorial/)."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "[](https://www.youtube.com/watch?v=-vVskDsHcVc)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np\n",
+ "import pandas as pd\n",
+ "\n",
+ "features = np.zeros((len(top_words), len(subset_data)), dtype=bool)\n",
+ "\n",
+ "for i, words_list in enumerate(top_words):\n",
+ " for j, word in enumerate(top_words):\n",
+ " if word in words_list:\n",
+ " features[j, i] = True\n",
+ "\n",
+ "feature_data = {word: features[i, :] for i, word in enumerate(top_words)}\n",
+ "features = pd.DataFrame(feature_data)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " go | \n",
+ " get | \n",
+ " day | \n",
+ " good | \n",
+ " work | \n",
+ " like | \n",
+ " love | \n",
+ " quot | \n",
+ " today | \n",
+ " got | \n",
+ " ... | \n",
+ " nest | \n",
+ " lodg | \n",
+ " racist | \n",
+ " devill | \n",
+ " jungl | \n",
+ " greekpeac | \n",
+ " bks | \n",
+ " aidan | \n",
+ " photogen | \n",
+ " municip | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
5 rows × 5000 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " go get day good work like love quot today got ... \\\n",
+ "0 True False False False False False False False False False ... \n",
+ "1 False True False False False False False False False False ... \n",
+ "2 False False True False False False False False False False ... \n",
+ "3 True False False True False False False False False False ... \n",
+ "4 False False False False True False False False False False ... \n",
+ "\n",
+ " nest lodg racist devill jungl greekpeac bks aidan photogen \\\n",
+ "0 False False False False False False False False False \n",
+ "1 False False False False False False False False False \n",
+ "2 False False False False False False False False False \n",
+ "3 False False False False False False False False False \n",
+ "4 False False False False False False False False False \n",
+ "\n",
+ " municip \n",
+ "0 False \n",
+ "1 False \n",
+ "2 False \n",
+ "3 False \n",
+ "4 False \n",
+ "\n",
+ "[5 rows x 5000 columns]"
+ ]
+ },
+ "execution_count": 43,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "features.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "[nltk_data] Downloading package vader_lexicon to\n",
+ "[nltk_data] C:\\Users\\ines_\\AppData\\Roaming\\nltk_data...\n",
+ "[nltk_data] Package vader_lexicon is already up-to-date!\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " go | \n",
+ " get | \n",
+ " day | \n",
+ " good | \n",
+ " work | \n",
+ " like | \n",
+ " love | \n",
+ " quot | \n",
+ " today | \n",
+ " got | \n",
+ " ... | \n",
+ " lodg | \n",
+ " racist | \n",
+ " devill | \n",
+ " jungl | \n",
+ " greekpeac | \n",
+ " bks | \n",
+ " aidan | \n",
+ " photogen | \n",
+ " municip | \n",
+ " is_positive | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " True | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " | 19995 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 19996 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 19997 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 19998 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 19999 | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " ... | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
20000 rows × 5001 columns
\n",
+ "
"
+ ],
+ "text/plain": [
+ " go get day good work like love quot today got \\\n",
+ "0 True False False False False False False False False False \n",
+ "1 False True False False False False False False False False \n",
+ "2 False False True False False False False False False False \n",
+ "3 True False False True False False False False False False \n",
+ "4 False False False False True False False False False False \n",
+ "... ... ... ... ... ... ... ... ... ... ... \n",
+ "19995 False False False False False False False False False False \n",
+ "19996 False False False False False False False False False False \n",
+ "19997 False False False False False False False False False False \n",
+ "19998 False False False False False False False False False False \n",
+ "19999 False False False False False False False False False False \n",
+ "\n",
+ " ... lodg racist devill jungl greekpeac bks aidan photogen \\\n",
+ "0 ... False False False False False False False False \n",
+ "1 ... False False False False False False False False \n",
+ "2 ... False False False False False False False False \n",
+ "3 ... False False False False False False False False \n",
+ "4 ... False False False False False False False False \n",
+ "... ... ... ... ... ... ... ... ... ... \n",
+ "19995 ... False False False False False False False False \n",
+ "19996 ... False False False False False False False False \n",
+ "19997 ... False False False False False False False False \n",
+ "19998 ... False False False False False False False False \n",
+ "19999 ... False False False False False False False False \n",
+ "\n",
+ " municip is_positive \n",
+ "0 False False \n",
+ "1 False False \n",
+ "2 False False \n",
+ "3 False True \n",
+ "4 False False \n",
+ "... ... ... \n",
+ "19995 False False \n",
+ "19996 False False \n",
+ "19997 False False \n",
+ "19998 False False \n",
+ "19999 False False \n",
+ "\n",
+ "[20000 rows x 5001 columns]"
+ ]
+ },
+ "execution_count": 44,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "from nltk.sentiment import SentimentIntensityAnalyzer\n",
+ "nltk.download('vader_lexicon')\n",
+ "\n",
+ "sia = SentimentIntensityAnalyzer()\n",
+ "\n",
+ "def get_sentiment(text):\n",
+ " scores = sia.polarity_scores(text)\n",
+ " compound_score = scores['compound']\n",
+ " return compound_score > 0\n",
+ "\n",
+ "features['is_positive'] = features.apply(lambda row: get_sentiment(' '.join(row.index[row])), axis=1)\n",
+ "features"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Building and Traininng Naive Bayes Model\n",
+ "\n",
+ "In this step you will split your feature set into a training and a test set. Then you will create a Bayes classifier instance using `nltk.NaiveBayesClassifier.train` ([example](https://www.nltk.org/book/ch06.html)) to train with the training dataset.\n",
+ "\n",
+ "After training the model, call `classifier.show_most_informative_features()` to inspect the most important features. The output will look like:\n",
+ "\n",
+ "```\n",
+ "Most Informative Features\n",
+ "\t snow = True False : True = 34.3 : 1.0\n",
+ "\t easter = True False : True = 26.2 : 1.0\n",
+ "\t headach = True False : True = 20.9 : 1.0\n",
+ "\t argh = True False : True = 17.6 : 1.0\n",
+ "\tunfortun = True False : True = 16.9 : 1.0\n",
+ "\t jona = True True : False = 16.2 : 1.0\n",
+ "\t ach = True False : True = 14.9 : 1.0\n",
+ "\t sad = True False : True = 13.0 : 1.0\n",
+ "\t parent = True False : True = 12.9 : 1.0\n",
+ "\t spring = True False : True = 12.7 : 1.0\n",
+ "```\n",
+ "\n",
+ "The [following video](https://www.youtube.com/watch?v=rISOsUaTrO4) will help you complete this step. The source code in this video can be found [here](https://pythonprogramming.net/naive-bayes-classifier-nltk-tutorial/)."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "[](https://www.youtube.com/watch?v=rISOsUaTrO4)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 45,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Most Informative Features\n",
+ " cha = True True : False = 739.7 : 1.0\n",
+ " ha = True True : False = 614.0 : 1.0\n",
+ " ff = True True : False = 443.8 : 1.0\n",
+ " ok = True True : False = 288.6 : 1.0\n",
+ " tha = True True : False = 187.7 : 1.0\n",
+ " eff = True True : False = 143.5 : 1.0\n",
+ " right = True True : False = 99.4 : 1.0\n",
+ " lay = True True : False = 99.4 : 1.0\n",
+ " nj = True True : False = 77.3 : 1.0\n",
+ " hat = True True : False = 61.5 : 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "from sklearn.model_selection import train_test_split\n",
+ "from nltk.classify import NaiveBayesClassifier\n",
+ "\n",
+ "train_set, test_set = train_test_split(features, test_size=0.2, random_state=42)\n",
+ "train_data = [(row.to_dict(), row['is_positive']) for _, row in train_set.iterrows()]\n",
+ "\n",
+ "classifier = NaiveBayesClassifier.train(train_data)\n",
+ "classifier.show_most_informative_features()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Testing Naive Bayes Model\n",
+ "\n",
+ "Now we'll test our classifier with the test dataset. This is done by calling `nltk.classify.accuracy(classifier, test)`.\n",
+ "\n",
+ "As mentioned in one of the tutorial videos, a Naive Bayes model is considered OK if your accuracy score is over 0.6. If your accuracy score is over 0.7, you've done a great job!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 46,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Accuracy: 0.98775\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nltk.classify import accuracy\n",
+ "test_data = [(row.to_dict(), row['is_positive']) for _, row in test_set.iterrows()]\n",
+ "accuracy_score = accuracy(classifier, test_data)\n",
+ "print(\"Accuracy:\", accuracy_score)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Bonus Question 1: Improve Model Performance\n",
+ "\n",
+ "If you are still not exhausted so far and want to dig deeper, try to improve your classifier performance. There are many aspects you can dig into, for example:\n",
+ "\n",
+ "* Improve stemming and lemmatization. Inspect your bag of words and the most important features. Are there any words you should furuther remove from analysis? You can append these words to further remove to the stop words list.\n",
+ "\n",
+ "* Remember we only used the top 5,000 features to build model? Try using different numbers of top features. The bottom line is to use as few features as you can without compromising your model performance. The fewer features you select into your model, the faster your model is trained. Then you can use a larger sample size to improve your model accuracy score."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# your code here"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Bonus Question 2: Machine Learning Pipeline\n",
+ "\n",
+ "In a new Jupyter Notebook, combine all your codes into a function (or a class). Your new function will execute the complete machine learning pipeline job by receiving the dataset location and output the classifier. This will allow you to use your function to predict the sentiment of any tweet in real time. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# your code here"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Bonus Question 3: Apache Spark\n",
+ "\n",
+ "If you have completed the Apache Spark advanced topic lab, what you can do is to migrate your pipeline from local to a Databricks Notebook. Share your notebook with your instructor and classmates to show off your achievements!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# your code here"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}