relabel: Relabel cluster IDs.

Description Usage Arguments Details Value Author(s) Examples

Description

Relabels cluster IDs of two or more cluster configurations according to the minimal distance between their centers.

Usage

1
2
relabel(cl1, cl2, ctr1, ctr2)
relabelMethods(methodNames=NULL, cls, ctrs)

Arguments

cl1

Cluster IDs of the first configuration.

cl2

Cluster IDs of the second configuration.

ctr1

Numeric matrix of cluster centers of the first configuration.

ctr2

Numeric matrix of cluster centers of the second configuration.

methodNames

Character vector of names for the different cluster methods.

cls

Numeric or character matrix of cluster outcomes for different methods.

ctrs

List of centers for the different methods.

Details

The two configurations for the method relabel do not have to have the same number of observations neither the same number of clusters. The configuration with less observations has to be put on place cl1.
relabelMethods can be used for more than two configurations. Cluster outputs must therefore be saved in a matrix cls and thus have the same number of observations. The relabeling works only correctly if the number of classes is the same. The relabeling of the methods follows the following scheme:

  1. Methods are sorted in that way that one of the two most similars is on first place.

  2. Methods are successively added in the order of the highest similarity to one of the already added methods.

  3. Once the order is fixed, the methods are relabeled after the ones they are most similar to.

Value

For method relabel:

recode

Recoding scheme of the second cluster labels cl2.

cluster

New cluster labels for cl2.

centers

Cluster centers ctrs2 in the new order.

For method relabelMethods:

allClusters

Matrix of new cluster labels.

allCenters

List of cluster centers in the new order.

fromTo

Recoding scheme of the methods.

Author(s)

Christina Yassouridis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
##Generate dataset
k <- 6
set.seed(2004)
ds <- sampleFuncy(obsNr=50, timeNrMin=3, timeNrMax=10, reg=FALSE, k=k, sd=.5)

##Cluster with different methods
res1 <- funcit(methods="fitfclust", data=Data(ds), k=k, reg=FALSE)
res2 <- funcit(methods="iterSubspace", data=Data(ds), k=k, reg=FALSE)
res3 <- funcit(methods="distclust", data=Data(ds), k=k, reg=FALSE)

##Relabel two configurations
relabel(Cluster(res3),Cluster(res1),Center(res3),Center(res1))

##Make matrix of clutser configurations
cls <- cbind(Cluster(res1),Cluster(res2),Cluster(res3))
##Make list of Centers
ctrs <- list(Center(res1), Center(res2), Center(res3))

##Relabel cluster configurations
rel <- relabelMethods(cls=cls, ctrs=ctrs)

##Compare
cls
rel$allClusters

funcy documentation built on May 2, 2019, 9:22 a.m.

Related to relabel in funcy...