predict.fnb.bernoulli {fastNaiveBayes} | R Documentation |
Predict Method for fastNaiveBayes fits
Description
Uses a fastNaiveBayes model and a new data set to create the classifications. This can either be the raw probabilities generated by the fastNaiveBayes model or the classes themselves.
Usage
## S3 method for class 'fnb.bernoulli'
predict(
object,
newdata,
type = c("class", "raw", "rawprob"),
sparse = FALSE,
threshold = .Machine$double.eps,
check = TRUE,
...
)
## S3 method for class 'fnb.gaussian'
predict(
object,
newdata,
type = c("class", "raw", "rawprob"),
sparse = FALSE,
threshold = .Machine$double.eps,
check = TRUE,
...
)
## S3 method for class 'fnb.multinomial'
predict(
object,
newdata,
type = c("class", "raw", "rawprob"),
sparse = FALSE,
threshold = .Machine$double.eps,
check = TRUE,
...
)
## S3 method for class 'fnb.poisson'
predict(
object,
newdata,
type = c("class", "raw", "rawprob"),
sparse = FALSE,
threshold = .Machine$double.eps,
check = TRUE,
...
)
## S3 method for class 'fastNaiveBayes'
predict(
object,
newdata,
type = c("class", "raw"),
sparse = FALSE,
threshold = .Machine$double.eps,
check = TRUE,
...
)
Arguments
object |
A fitted object of class "fnb.bernoulli", "fnb.gaussian", "fnb.multinomial" or "fastNaiveBayes". |
newdata |
A numeric matrix. A Sparse dgcMatrix is also accepted. Note: if fnb.naiveBayes or fnb.gaussian or fnb.train was used to create the model, then if newdata contains features that were not encountered in the training data, these are omitted from the prediction. Furthermore, newdata can contain fewer features than encountered in the training data. In this case, newdata will be padded with extra columns all filled with 0's. |
type |
If "raw", the conditional a-posterior probabilities for each class are returned, and the class with maximal probability else. |
sparse |
Use a sparse matrix? If true a sparse matrix will be constructed from x. It's possible to directly feed a sparse dgcMatrix as x, which will set this parameter to TRUE |
threshold |
A threshold for the minimum probability. For Bernoulli and Multinomial event models Laplace smoothing should solve this, but in the case of Gaussian event models, this ensures numerical probabilities. |
check |
Whether to perform formal checks on the input. Set to false, if this is not necessary and speed is of the essence |
... |
not used |
Value
If type = 'class', a factor with classified class levels. If type = 'raw', a matrix with the predicted probabilities of each class, where each column in the matrix corresponds to a class level.
See Also
fastNaiveBayes
for the fastNaiveBayes model