SwiftKey Next Word Predictor

Data Science Capstone
August 2026

Fast word prediction in a lightweight Shiny app

The product predicts the next word as a user types, using a compact language model trained on blogs, news, and Twitter text.

Built for a real data product goal: useful predictions, fast response time, and a model small enough to deploy.

How The Model Works

1. Clean text Normalize case, punctuation, URLs, and encoding issues.
2. Tokenize Split text into words and build 1-, 2-, 3-, and 4-grams.
3. Predict Use up to the previous 3 words to find likely next words.
4. Back off If a phrase is unseen, fall back to shorter contexts and common words.

The deployed model is a pruned 4-gram Markov model: it stores only useful context-to-next-word transitions.

Quantified Performance

12.24%Top-1 accuracy
22.29%Top-3 accuracy
27.40%Top-5 accuracy
2.03 msPer prediction
| Deployment metric | Value | |—|—:| | Vocabulary size | 20,000 words | | Stored transitions | 31,678 | | In-memory size | about 29 MB | | Saved model size | about 1.2 MB | | Held-out test sample | 10,000 tokens |

The pruned model keeps nearly the same accuracy as the larger baseline while using less than half the memory.

The App In Action

Designed for quick, visible feedback

- Type a phrase into the text box. - See the top prediction immediately. - Compare alternative next words. - Check confidence and context evidence. - Use the score chart to see whether the model is certain or uncertain.
Shiny app screenshot

Why This Product Is Ready

What makes it strong

- Self-contained Shiny app: no raw corpus needed at runtime. - Compact model file for simple deployment. - Interpretable predictions: every suggestion has context evidence. - Fast enough for interactive typing. - Clear path to improve accuracy with more data and better smoothing.
Recommendation: deploy the pruned strict-backoff model now, then improve the next version with larger training samples and smarter smoothing.

Run locally with: shiny::runApp(“shiny_app”)