Learn R Programming

RMixtComp (version 4.1.4)

predict.MixtComp: Predict using RMixtComp

Description

Predict the cluster of new samples.

Usage

# S3 method for MixtComp
predict(
  object,
  newdata = NULL,
  type = c("partition", "probabilities"),
  nClass = NULL,
  ...
)

Value

if type = "partition", it returns the estimated partition as a vector. If type = "probabilities", it returns the probabilities to belong to each class (tik) as a matrix.

Arguments

object

output of mixtCompLearn function.

newdata

a data.frame, a matrix or a named list containing the data (see Details and Data format sections in mixtCompLearn documentation). If NULL, use the data in object.

type

if "partition", returns the estimated partition. If "probabilities", returns the probabilities to belong to each class (tik).

nClass

the number of classes of the mixture model to use from object. If NULL, uses the number maximizing the criterion.

...

other parameters of mixtCompPredict function.

Author

Quentin Grimonprez

Details

This function is based on the generic method "predict". For a more complete output, use mixtCompPredict function.

See Also

mixtCompPredict

Examples

Run this code
data(iris)

model <- list(
  Sepal.Length = "Gaussian", Sepal.Width = "Gaussian",
  Petal.Length = "Gaussian", Petal.Width = "Gaussian"
)

resLearn <- mixtCompLearn(iris[-c(1, 51, 101), ], model = model, nClass = 1:3, nRun = 1)

# return the partition
predict(resLearn)

# return the tik for the 3 new irises for 2 and 3 classes
predict(resLearn, newdata = iris[c(1, 51, 101), ], type = "probabilities", nClass = 2)
predict(resLearn, newdata = iris[c(1, 51, 101), ], type = "probabilities", nClass = 3)

Run the code above in your browser using DataLab