Description Usage Arguments Details Value Author(s) Examples
View source: R/getClassGivenCenters.R
After obtaining centers, adhears to supervision constraints while getting class labels.
1 2 3 |
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) |
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.
clss: length n vector of class labels
Jordan Yoder
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.