predict_class: Predict Class

Description Usage Arguments Examples

View source: R/bayes.R

Description

Predict class using naive Bayes classifier.

Usage

1
2
3
4
predict_class(model, data, text)

## S3 method for class '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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## 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)

## End(Not run)

news-r/textanalysis documentation built on Nov. 4, 2019, 9:40 p.m.