Learn R Programming

mixdir (version 0.3.0)

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

Description

Predict the class of a new observation.

Usage

# S3 method for 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

Run this code
# NOT RUN {
  data("mushroom")
  X <- as.matrix(mushroom)[1:30, ]

  res <- mixdir(X)

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

Run the code above in your browser using DataLab