predict.fastNaiveBayes: Predict Method for fastNaiveBayes fits

Description Usage Arguments Value See Also

View source: R/fnb.train.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## 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


fastNaiveBayes documentation built on May 4, 2020, 5:09 p.m.