This report presents an exploratory analysis of the SwiftKey text datasets used for the prediction project. The goal of this milestone is to understand the structure and characteristics of the data and identify patterns that will be useful when developing a text prediction algorithm.
The analysis focuses on three sources of English text: blogs, news articles, and Twitter messages. The datasets differ substantially in size and writing style, providing a useful foundation for developing a model that can predict the next word entered by a user.
The three datasets were successfully downloaded and loaded into R. The following table summarizes their size in terms of number of lines, words, and characters.
| Dataset | Lines | Words | Characters |
|---|---|---|---|
| Blogs | 899288 | 79780901 | 206824505 |
| News | 1010206 | 74313644 | 203214543 |
| 2360148 | 65271462 | 162096241 |
The three sources contain a substantial amount of text. Blogs contain approximately 79.8 million words, news contains approximately 74.3 million words, and Twitter contains approximately 65.3 million words.
The average number of characters per line differs considerably between the three sources. Blog entries are longest on average, followed by news articles, while Twitter messages are substantially shorter.
| Dataset | Lines | Average_Characters |
|---|---|---|
| Blogs | 899288 | 229.99 |
| News | 1010206 | 201.16 |
| 2360148 | 68.68 |
A sample of 50,000 lines from each source was combined and cleaned to examine the most common vocabulary. Common English stop words and obvious contraction fragments were removed.
| Word | Frequency |
|---|---|
| said | 14825 |
| will | 13648 |
| one | 13369 |
| can | 13119 |
| just | 11347 |
| like | 10749 |
| time | 9544 |
| get | 8561 |
| new | 8017 |
| now | 6917 |
| people | 6903 |
| year | 6680 |
| day | 6509 |
| first | 6437 |
| also | 6432 |
| good | 6355 |
| know | 6132 |
| two | 5853 |
| back | 5817 |
| love | 5364 |
The following histogram uses a sample of 10,000 lines from each source. It illustrates the differences in text length across blogs, news and Twitter.
Several useful characteristics were identified during the exploratory analysis:
The next stage of the project will focus on developing a statistical language model that predicts the next word based on words already entered by the user.
The cleaned text will be used to identify common word sequences. The model will initially consider relatively short sequences of words and estimate which words are most likely to follow a given sequence. The model will then be evaluated using held-out text to determine how accurately it predicts unseen examples.
Because the source data is large, sampling and efficient data structures will be important for keeping the model fast enough for practical use.
The final Shiny application will provide a simple interface where a user can enter a phrase and receive suggested next words.
The application will use the prediction model created from the training data and display a small number of likely suggestions. The main objective will be to provide useful predictions while keeping response time short and the interface easy to understand.
The exploratory analysis confirms that the SwiftKey datasets contain sufficient text and substantial variation in writing style to support development of a word-prediction system. The next stage will focus on building and evaluating the prediction model and integrating it into a Shiny application.