predict.bnc_fit {bnclassify}R Documentation

Predicts class labels or class posterior probability distributions.

Description

Predicts class labels or class posterior probability distributions.

Usage

## S3 method for class 'bnc_fit'
predict(object, newdata, prob = FALSE, ...)

Arguments

object

A bnc_bn object.

newdata

A data frame containing observations whose class has to be predicted.

prob

A logical. Whether class posterior probability should be returned.

...

Ignored.

Details

Ties are resolved randomly. Inference is much slower if newdata contains NAs.

Value

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.

Examples

data(car)
nb <- bnc('nb', 'class', car, smooth = 1)
p <- predict(nb, car)
head(p)
p <- predict(nb, car, prob = TRUE)
head(p)

[Package bnclassify version 0.4.8 Index]