Chris Cox
Goal is to create a predictive model that will take in user text and predict the next word with an aim to improve the efficiency of the users typing.
This app was build to allow the user to explore the predictive model and consider ways to improve its accuracy. The App:
Following steps were taken to build the prediction model using Stupid Back-Off method
### train using the sbo::kgrams_freqs_fast function.
small_train_freq <- kgram_freqs_fast(train, N=4, dict = max_size ~ 708, EOS = ".?!:;")
Phrase sentiment is used to try to improve accuracy. Sentiment is used to order words with equal probabilities
s <- sentiment(phrase)
pt <- predict(small_train_freq, phrase)
colnames(pt) <- c("word", "probability")
pt <- anti_join(pt, badwords, by = "word") %>%
left_join(sentim, by = "word") %>%
filter(word != "<EOS>")
if(s$sentiment > -0.25 & s$sentiment < 0.25) { pt[is.na(pt)] <- 1
pt <- arrange(pt, desc(probability), desc(value))
} else { pt[is.na(p)] <- 0
if(s$sentiment > 0.25){ pt <- arrange(pt, desc(probability), desc(value))
} else { pt <- arrange(pt, desc(probability), value)} }
Type a phrase and press Enter to see the top 3 suggested words. For example, enter the phrase “i've had the best” gives the suggested words “time, day, dream”.
The app also shows 3 plots: phrase sentiment, circular barplot with top 20 words, and a word cloud with 100 words max.