Synopsis

The objective of the milestone report is to provide assurance that I have gotten use to working with the capstone data sets and have performed exploratory analysis as part of the predictive model building process. The data sets used for this report are the English blog, twitter and news text files. I preprocess each of the data sets before performing any analysis. I produce word clouds to highlight frequently-used words in each data set and histograms to illustrate the distribution of word lengths in each set.

Data Processing

Load Data and PreProcessing

Each file is loaded through the use of the readLines command. I load a file called profane.txt to help filter out any objectionable words. File was sourced from Shutterstock’s Github page and is usable under the Creative Commons Attribution 4.0 International License described by the following link: http://creativecommons.org/licenses/by/4.0/. For the sake of completeness in analysis for this milestone report, I will not use the profanity filter but it will be used prior to model generation. Preprocessing included the removal of accents from alphabetic characters and the removal of non-alphabetic characters. The trimming of access spaces is also performed.

Basic Statistics

The blog and twitter data sets are much bigger than the news data set. Currently the data set words are “raw” in that they may contain misspellings and non word strings - prior to any prediction model creation, I will attempt to remove/correct such “words”. I used two different techniques for counting words: the Tau library function textcnt() from the large blog and twitter data sets and the tm library function termFreq() for the smaller news data set. This allowed me to show the difference removing stopwords - common words like “the” and “and” - from the news data set changes the analysis of the words.

The blog data set has 899288 entries with an average of 42 words per entry. The total number of words in the blog data set is 38199168, with a unique word count of 302833.

The twitter data set has 2360148 tweets with an average of 13 words per entry. The total number of words in the blog data set is 30686486, with a unique word count of 312834.

The news data set has 77258 entries with an average of 35 words per entry. The total number of words in the news data set is 2676940, with a unique word count of 75648.

Below you can find some basic graphs of the data sets. A word cloud is generated for each data set to show the most common words. An additional word cloud is generated for the news data set to show the difference removing stop words makes. After the word clouds, I generated histograms to show the distribution of word lengths in each data set. The wide ranges displayed further preprocessing is required to deal with unexpectedly long “words”.

News Word Cloud

News Word Cloud (Stopwords removed)

Blog Word Cloud

Blog Word Cloud

News Word Length Histogram

Twitter Word Length Histogram

Blog Word Length Histogram

Wrapup

The size of the twitter and blog data sets will require sampling techniques before training, validation and test sets can be created for predictive model building. The structure of tweets versus blog and news entries also will require special handling - in particular the disposition of hashtags will be important. I will attempt models using machines learning, support vector machines, decision trees and, if time allows, neural networks.