Learn R Programming

quanteda (version 1.1.1)

predict.textmodel_nb: Prediction from a fitted textmodel_nb object

Description

predict.textmodel_nb() implements class predictions from a fitted Naive Bayes model. using trained Naive Bayes examples

Usage

# S3 method for textmodel_nb
predict(object, newdata = NULL, ...)

Arguments

object

a fitted Naive Bayes textmodel

newdata

dfm on which prediction should be made

...

not used

Value

predict.textmodel_nb returns a list of two data frames, named docs and words corresponding to word- and document-level predicted quantities

docs

data frame with document-level predictive quantities: nb.predicted, ws.predicted, bs.predicted, PcGw, wordscore.doc, bayesscore.doc, posterior.diff, posterior.logdiff. Note that the diff quantities are currently implemented only for two-class solutions.

words

data-frame with word-level predictive quantities: wordscore.word, bayesscore.word

Examples

Run this code
# NOT RUN {
# application to LBG (2003) example data
(nb <- textmodel_nb(data_dfm_lbgexample, c("A", "A", "B", "C", "C", NA)))
predict(nb)
# }

Run the code above in your browser using DataLab