cl_predict: Predict Memberships

View source: R/predict.R

cl_predictR Documentation

Predict Memberships


Predict class ids or memberships from R objects representing partitions.


cl_predict(object, newdata = NULL,
           type = c("class_ids", "memberships"), ...)



an R object representing a partition of objects.


an optional data set giving the objects to make predictions for. This must be of the same “kind” as the data set employed for obtaining the partition. If omitted, the original data are used.


a character string indicating whether class ids or memberships should be returned. May be abbreviated.


arguments to be passed to and from methods.


Many algorithms resulting in partitions of a given set of objects can be taken to induce a partition of the underlying feature space for the measurements on the objects, so that class memberships for “new” objects can be obtained from the induced partition. Examples include partitions based on assigning objects to their “closest” prototypes, or providing mixture models for the distribution of objects in feature space.

This is a generic function. The methods provided in package clue handle the partitions obtained from clustering functions in the base R distribution, as well as packages RWeka, cba, cclust, cluster, e1071, flexclust, flexmix, kernlab, mclust, movMF and skmeans (and of course, clue itself).


Depending on type, an object of class "cl_class_ids" with the predicted class ids, or of class "cl_membership" with the matrix of predicted membership values.


## Run kmeans on a random subset of the Cassini data, and predict the
## memberships for the "test" data set.
nr <- NROW(Cassini$x)
ind <- sample(nr, 0.9 * nr, replace = FALSE)
party <- kmeans(Cassini$x[ind, ], 3)
table(cl_predict(party, Cassini$x[-ind, ]),

clue documentation built on Nov. 19, 2022, 5:05 p.m.