Description Usage Arguments Value Author(s) Examples
View source: R/ClusterPredict.R
This function predicts the best cluster each sample in data belongs to.
1 | 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
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])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.