This capstone project presentation covers the model behind the app, the testing and performance findings, and the shiny app itself.
As suggested, I used a basic n-gram predictive model: this is not in fact how modern predictive text input apps work, but it’s simple to train and implement. To cut down on database size and training time, I only used the news text base, which also limits the slang and curse words commonly appearing through the twitter and blog text collection. Instead of a full Markov chain model, I cut the results down to the top 3 options for each word / bigram / trigram in the database.
Using a random sample of 1% of the original news text (the prediction task is so simple that the standard 20-30% test dataset seemed excessive), I repeatedly evaluated the performance of my models. I started by dropping all n-grams that only appeared once, cutting down significantly on the saved model size. Attempting to raise the filter threshold worked reasonably well for 1-grams, only dropping by a percentage point or so from the initial 21% performance, but the dataset size savings were hardly worth it at 1.5 MB. Bigram and trigram tables were larger, at 7 and 5 MB, but similar losses of around 1 percentage point seemed far costlier given the starting points of 11% and 3%, respectively, so I left it at only filtering out single-appearance n-grams.
The shiny app should be self-explanatory: based on an inputted string of words, the app provides the top 3 suggestions for the likely next word. The only complication was figuring out the format for loading data from the attached file of word suggestion tables.
If you are reading this, you probably have just finished the capstone project and the entire data science specialization. Congrats!