predict.textmodel_nb | R Documentation |
predict.textmodel_nb()
implements class predictions from a fitted
Naive Bayes model. using trained Naive Bayes examples
## S3 method for class 'textmodel_nb'
predict(
object,
newdata = NULL,
type = c("class", "probability", "logposterior"),
force = FALSE,
...
)
## S3 method for class 'textmodel_nb'
coef(object, ...)
## S3 method for class 'textmodel_nb'
coefficients(object, ...)
object |
a fitted Naive Bayes textmodel |
newdata |
dfm on which prediction should be made |
type |
the type of predicted values to be returned; see Value |
force |
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"
).
coef.textmodel_nb()
returns a matrix of estimated
word likelihoods given the class. (In earlier versions,
this was named PwGc
.)
textmodel_nb()
# application to LBG (2003) example data
(tmod <- textmodel_nb(quanteda::data_dfm_lbgexample, y = c("A", "A", "B", "C", "C", NA)))
predict(tmod)
predict(tmod, type = "logposterior")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.