clusterPredict: Create an instance of ['ClusterPredict'] class

Description Usage Arguments Value Author(s) Examples

View source: R/ClusterPredict.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## 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])

MixAll documentation built on Sept. 12, 2019, 5:05 p.m.