Learn R Programming

DrugClust (version 0.2)

KSeedsClusters: KSeedsClusters

Description

Function Implementing KSeeds. K-Seeds, firstly randomly chooses a number of drugs (renamed Seeds) equal to the number of clusters desired. Then, the other drugs are assigned to a cluster with respect to Hamming Distance between the drug and the seed of a certain cluster. Cluster seeds are not recomputed at each iteration. This allows a speed up in terms of computational complexity and the algorithm terminates when all the drugs have been assigned.

Usage

KSeedsClusters(train, num_clusters, Seed, s)

Arguments

train
train matrix of features
num_clusters
number of clusters desired
Seed
subset of drugs features matrix, with just the Seeds as rows
s
the seeds of the clusters

Value

clusters list indicating the cluster to which each drug belongs to

Examples

Run this code
r <- 8
c <- 10
m0 <- matrix(0, r, c)
num_clusters=4
features<-apply(m0, c(1,2), function(x) sample(c(0,1),1))
s<-RandomSeedGenerator(num_clusters,nrow(features))
Seed<-SeedSelection(features,num_clusters,s)
clusters<-KSeedsClusters (features,num_clusters,Seed,s)

Run the code above in your browser using DataLab