Description Usage Arguments Value Author(s) See Also Examples
Perform sparse weighted K-Means algorithm on observations with given weights.
1 2 3 |
x |
An n by p numeric data matrix, and n is the number of observations and p the number of features. |
K |
The number of clusters. Omitted if |
weight |
A vector of n positive elements representing weights on observations. |
wbounds |
A single L1 bound on w (the feature weights), or a vector of L1 bounds on w. If wbound is small, then few features will have non-zero weights. If wbound is large then all features will have non-zero weights. Should be greater than 1. |
nstart |
The number of initial random sets chosen from (distinct) rows in |
silent |
Print out progress? |
maxiter |
The maximum number of iterations. |
centers |
A K by p matrix indicating initial (distinct) cluster centers. |
If wbounds
is a numeric value, then the function returns a list
with elements as follows:
ws |
The p-vector of feature weights. |
Cs |
The clustering result. |
wcss |
A list of the following:
|
wbound |
The L1 bound in the current list. |
weight |
The weights on observations. |
If wbounds
is a vector, then the function returns a list with lists
(one per element of wbounds
).
Wenyu Zhang
Other sparse weighted K-Means functions: ChooseK
,
KMeansSparseCluster.permute.weight
,
kmeans.weight.tune
,
kmeans.weight
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
set.seed(1)
data("NormalDisData")
cK <- ChooseK(NormalDisData$data[-NormalDisData$noisy.label,],nClusters = 1:6)
plot(cK)
K <- cK$OptimalK
res.tuneU <- kmeans.weight.tune(x = NormalDisData$data,K = K,
noisy.lab = NormalDisData$noisy.label,weight.seq = NULL)
plot(res.tuneU)
res.tunes <- KMeansSparseCluster.permute.weight(x = NormalDisData$data,K = K,
weight = res.tuneU$bestweight)
res <- KMeansSparseCluster.weight(x = NormalDisData$data,K = K,
wbounds = res.tunes$bestw,weight = res.tuneU$bestweight)
#check the clustering result, the number of features selected and the 50 most important features
table(res[[1]]$Cs,NormalDisData$true.label)
sum(res[[1]]$ws!=0)
order(res[[1]]$ws,decreasing = TRUE)[1:50]
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.