View source: R/transition_predictions.R
transition_predictions | R Documentation |
This function takes sequences of elements and uses a machine learning classifier to predict the next elements in the sequence. It supports n-gram tokenization and k-fold cross-validation. Optionally, it can upsample the training data.
transition_predictions(
sequences,
classifier = "nb",
ngram = 2,
upsample = TRUE,
k = 10
)
sequences |
A list of character strings representing sequences of elements. |
classifier |
A character string specifying the classifier to use. Options are 'nb' for Naive Bayes and 'forest' for random forest. |
ngram |
An integer specifying the number of elements to consider in the n-gram tokenization. Default is 2. |
upsample |
A logical value indicating whether to upsample the training data to balance class distribution. Default is TRUE. |
k |
An integer specifying the number of folds for k-fold cross-validation. Default is 10. |
A list containing the mean accuracy, mean null accuracy, and a data frame of prediction errors.
sequences <- list("a b c", "b c d", "c d e")
result <- transition_predictions(sequences, classifier = 'nb', ngram = 2, upsample = TRUE, k = 5)
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.