predict.bnc_fit | R Documentation |
Predicts class labels or class posterior probability distributions.
## S3 method for class 'bnc_fit'
predict(object, newdata, prob = FALSE, ...)
object |
A |
newdata |
A data frame containing observations whose class has to be predicted. |
prob |
A logical. Whether class posterior probability should be returned. |
... |
Ignored. |
Ties are resolved randomly. Inference is much slower if
newdata
contains NA
s.
If prob=FALSE
, then returns a length-N
factor with the
same levels as the class variable in x
, where N
is the number
of rows in newdata
. Each element is the most likely
class for the corresponding row in newdata
. If prob=TRUE
,
returns a N
by C
numeric matrix, where C
is the number of
classes; each row corresponds to the class posterior of the instance.
data(car)
nb <- bnc('nb', 'class', car, smooth = 1)
p <- predict(nb, car)
head(p)
p <- predict(nb, car, prob = TRUE)
head(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.