在R中使用sparcl包在R中执行稀疏分级集群时,我无法获得数据的集群标签。在帮助文档,它们具有以下代码:如何获取R中HierarchicalSparseCluster()中的集群标签
# Generate 2-class data
set.seed(1)
x <- matrix(rnorm(100*50),ncol=50)
y <- c(rep(1,50),rep(2,50))
x[y==1,1:25] <- x[y==1,1:25]+2
# Do tuning parameter selection for sparse hierarchical clustering
perm.out <- HierarchicalSparseCluster.permute(x, wbounds=c(1.5,2:6), nperms = 5)
# Perform sparse hierarchical clustering
sparsehc <- HierarchicalSparseCluster(dists=perm.out$dists,
wbound=perm.out$bestw, method="complete")
现在,我怎么从对象sparsehc到簇标签是我的问题?
对于Kmeans,我们创建了一个简单的属性“cs”。例如。
## Choosing tuning parameters
km.perm <- KMeansSparseCluster.permute(data_mat, K = 10, wbounds= seq(3,7, len =
20), nperms=5)
## Performing kmean sparce clustring
sparse_data_clus <- KMeansSparseCluster(data_mat, K = 10, wbounds= km.perm$bestw)
clusterlabel <- sparse_data_clus[[1]]$Cs
我怎样才能HierarchicalSparseCluster()得到类似的标签?
谢谢!