Chunlu (Lyn) Yang
Coursera Data Science Capstone
A lightweight Shiny app that predicts the next word from an English phrase.
Try the app: https://lyannn.shinyapps.io/next_word_predictor/
The app uses a reliability-aware n-gram language model.
Key idea: Rare trigrams should not automatically override stronger lower-order evidence.
I compared three prediction strategies on the same 10-item benchmark.
| Model | Description | Multiple-choice accuracy |
|---|---|---|
| V1 | Hard backoff: trigram → bigram → unigram | 30% |
| V2 | Reliability-aware trigram/bigram/unigram interpolation | 40% |
| V3 | V2 + pruned 4-gram evidence | 40% |
V2 improved accuracy without adding extra model storage.
| Model | Avg. runtime per prediction | Accuracy |
|---|---|---|
| V1 | 0.24023 sec | 30% |
| V2 | 0.24045 sec | 40% |
| V3 | 0.25329 sec | 40% |
4-gram exploration showed strong sparsity:
The app is designed for quick, interactive next-word prediction.
How to use it:
Thank you so much for yourThe final model uses V2 because it provides the best balance of accuracy, speed, and simplicity.