predict.MonoClust: Predictions from a MonoClust Object

Description Usage Arguments Value Examples

View source: R/predict.monoclust.R

Description

Predict the cluster memberships of a new data set from a MonoClust object.

Usage

1
2
## S3 method for class 'MonoClust'
predict(object, newdata, type = c("centroid", "medoid"), ...)

Arguments

object

MonoClust result object.

newdata

Data frame containing the values to be predicted. If missing, the memberships of the MonoClust object are returned.

type

Type of returned cluster representatives. Either "centroid" to return the centroid values of the terminal clusters, or "medoid" to return the index of the medoid observations in the clustered data set.

...

Further arguments passed to or from other methods.

Value

A tibble of cluster index in cname and either centroid values or medoid observations index based on the value of type argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(cluster)
data(ruspini)

set.seed(1234)
test_index <- sample(1:nrow(ruspini), nrow(ruspini)/5)
train_index <- setdiff(1:nrow(ruspini), test_index)
ruspini_train <- ruspini[train_index, ]
ruspini_test <- ruspini[test_index, ]

ruspini_train_4sol <- MonoClust(ruspini_train, nclusters = 4)
predict(ruspini_train_4sol, newdata = ruspini_test)

monoClust documentation built on Feb. 15, 2021, 5:07 p.m.