View source: R/ClusterPredict.R
clusterPredict | R Documentation |
ClusterPredict
] classThis function predicts the best cluster each sample in data belongs to.
clusterPredict(data, model, algo = clusterAlgoPredict(), nbCore = 1)
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
|
algo |
an instance of |
nbCore |
integer defining the number of processors to use (default is 1, 0 for all). |
An instance of [ClusterPredict
] with predicted
values
Serge Iovleff
## 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])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.