2023-06-11

The goal of the project

  • The goal of this exercise is to create a product to highlight the prediction algorithm that you have built and to provide an interface that can be accessed by others
  1. A Shiny app that takes as input a phrase (multiple words) in a text box input and outputs a prediction of the next word.
  2. A slide deck consisting of no more than 5 slides created with R Studio Presenter

The Shiny App

The app was built using the Shiny R program (and this presentation in R Markdown). It was created to help predict the next word in a sentence using english data from SwiftKey.

Using N-Grams to make the prediction

The data was analyzed using n-grams, needing the R functions NGramTokenizer() and Weka_control(). A training data set was created and a ‘validation’ dataset was subsetted from this training data. This allowed a validation step of the training data, before being implemented on the test data.

Some Shiny code

The following was some of the server code used for the production of the product

shinyServer(function(input, output) {
    output$prediction <- renderPrint({
        result <- predictWord(input$inputText)
        output$sentence2 <- renderText({message})
        result
    });
    output$sentence1 <- renderText({
        input$inputText});
}
)