clusterPredict {MixAll}R Documentation

Create an instance of [ClusterPredict] class

Description

This function predicts the best cluster each sample in data belongs to.

Usage

clusterPredict(data, model, algo = clusterAlgoPredict(), nbCore = 1)

Arguments

data

dataframe or matrix containing the data. Rows correspond to observations and columns correspond to variables. If the data set contains NA values, they will be estimated during the predicting process.

model

(estimated) clustering model to use, i.e. an instance of ClusterCategorical, ClusterDiagGaussian,.. produced by clusterCategorical, clusterDiagGaussian,... learnCategorical, learnDiagGaussian, etc. functions.

algo

an instance of ClusterAlgoPredict S4 class. Will not be used if there is no missing values.

nbCore

integer defining the number of processors to use (default is 1, 0 for all).

Value

An instance of [ClusterPredict] with predicted values

Author(s)

Serge Iovleff

Examples

## A quantitative example with the famous iris data set
data(iris)
## get quantitatives 
x = as.matrix(iris[1:4])
## sample train and test data sets
indexes <- sample(1:nrow(x), nrow(x)/2)
train <- x[ indexes,]
test  <- x[-indexes,]
## estimate model (using fast strategy, results may be misleading)
model1 <- clusterDiagGaussian( data =train, nbCluster=2:3
                             , models=c( "gaussian_p_sjk")
                             )
## get summary
summary(model1)
## compute prediction and compare
model2 <- clusterPredict(test, model1)
show(model2)
as.integer(iris$Species[-indexes])


[Package MixAll version 1.5.16 Index]