
Last chance! 50% off unlimited learning
Sale ends in
predict.textmodel_nb()
implements class predictions from a fitted
Naive Bayes model. using trained Naive Bayes examples
# S3 method for textmodel_nb
predict(object, newdata = NULL, type = c("class",
"probability", "logposterior"), force = FALSE, ...)
a fitted Naive Bayes textmodel
dfm on which prediction should be made
the type of predicted values to be returned; see Value
make newdata's feature set conformant to the model terms
not used
predict.textmodel_nb
returns either a vector of class
predictions for each row of newdata
(when type = "class"
), or
a document-by-class matrix of class probabilities (when type =
"probability"
) or log posterior likelihoods (when type =
"logposterior"
).
# NOT RUN {
# application to LBG (2003) example data
(nb <- textmodel_nb(data_dfm_lbgexample, c("A", "A", "B", "C", "C", NA)))
predict(nb)
predict(nb, type = "logposterior")
# }
Run the code above in your browser using DataLab