Predict class using naive Bayes classifier.

predict_class(model, data, text)

# S3 method for naive_bayes_model
predict_class(model, data, text)

Arguments

model

A naive Bayes classifier as returned by init_naive_classifer.

data

A data.frame containing text and labels.

text

Text to train model on labels.

Examples

# NOT RUN {
init_textanalysis()
classes <- factor(c("financial", "legal"))
model <- init_naive_classifer(classes)

train <- tibble::tibble(
  text = c("this is financial doc", "this is legal doc"),
  labels = factor("financial", "legal")
)

train_naive_classifier(model, train, text, labels)

test <- tibble::tibble(
  text = "this should be predicted as a legal document"
)
predict_class(model, test, text)
# }