predict.mixdir: Predict the class of a new observation.

Description Usage Arguments Value Examples

View source: R/predict.R

Description

Predict the class of a new observation.

Usage

1
2
## S3 method for class 'mixdir'
predict(object, newdata, ...)

Arguments

object

the result from a call to mixdir(). It needs to have the fields lambda, category_prob and na_handle. lambda is a vector of probabilities for each category. category_prob a list of a list of a named vector with probabilities for each feature, latent class and possible category. na_handle must either be "ignore" or "category" depending how NA's should be handled.

newdata

a named vector with a single new observation or a data.frame with the same structure as the original data used for fitting the model. Missing features or features not encountered during training are replaced by NA.

...

currently unused

Value

A matrix of with the same number of rows as the input and one column for each latent class.

Examples

1
2
3
4
5
6
7
8
  data("mushroom")
  X <- as.matrix(mushroom)[1:30, ]

  res <- mixdir(X)

  # Predict Class
  predict(res, mushroom[40:45, ])
  predict(res, c(`gill-color`="black"))

mixdir documentation built on Sept. 20, 2019, 5:04 p.m.