getClassGivenCenters: getClassGivenCenters

Description Usage Arguments Details Value Author(s) Examples

View source: R/getClassGivenCenters.R

Description

After obtaining centers, adhears to supervision constraints while getting class labels.

Usage

1
2
3
getClassGivenCenters(data,centers,knownLabels=NULL,trueLabels=NULL, 
                               knownCannotLink=NULL,
                               cannotLinkWithIdx=NULL)

Arguments

data

data as a matrix. Unknown if it works for 1d.

centers

list of centers of the classes

knownLabels

vector of indices of rows of x whose labels are known

trueLabels

length nrow(x) vector of true labels (only trueLabels[knownLabels] matter)

knownCannotLink

vector of indices of data with cannot link with constraints

cannotLinkWithIdx

cannotLinkWithIdx[[“i"]] = data i cannot link with these indices (in vector)

ex: Suppose cannotLinkWithIdx[[“2"]]=c(1,3). Then, 2 cannot link with 1 and 3.

Constructed with, for example:

knownCannotLink = c(3,4,5,6,7,8)

cannotLinkWithIdx = new.env()

for(i in knownCannotLink) cannotLinkWithIdx[[as.character(i)]]=c(1,2)

Details

This function was entirely internal (specialized to the case with RED and DEFINITELY NOT RED constraints). It was originally called by the ssVN() function, which sets up the (admittably strange) datastructure for cannotLinkWithIdx.

I have chosen to make it external for a bit more flexibility in my own experiments. Use at own risk.

Value

clss: length n vector of class labels

Author(s)

Jordan Yoder

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data = matrix(runif(20),nrow=10,ncol=2)
library(ssClust)
centers = kppInit(data, numGroups=3, 
knownLabels=c(1,2), trueLabels=c(0,1)) #note trueLabels are 0-indexed
knownCannotLink = c(3,4,5,6,7,8)
cannotLinkWithIdx = new.env()
for(i in knownCannotLink) cannotLinkWithIdx[[as.character(i)]]=c(1,2)
cl<-getClassGivenCenters(data,centers,knownLabels=c(1,2),trueLabels=c(0,1), 
                               knownCannotLink=c(3,4,5,6,7,8),
                               cannotLinkWithIdx=cannotLinkWithIdx)

cl[1]==0
cl[2]==1
all(cl[knownCannotLink] == 2) #must be cl2 because cannot link 
#with data1 or data2, which are cl0 and cl1, respectively

Noobivsho/ssClust documentation built on Aug. 10, 2019, 5:47 a.m.