【发布时间】:2017-02-22 22:52:47
【问题描述】:
“data.clustering”数据框大小:943x2
> head(data.clustering)
age gender
2 2 1
3 6 2
4 2 1
5 2 1
6 6 2
7 6 1
当我使用 Elbow 方法找到 k 值时:
elbow.k <- function(mydata){
## determine a "good" k using elbow
dist.obj <- dist(mydata);
hclust.obj <- hclust(dist.obj);
css.obj <- css.hclust(dist.obj,hclust.obj);
elbow.obj <- elbow.batch(css.obj);
# print(elbow.obj)
k <- elbow.obj$k
return(k)
}
# find k value
start.time <- Sys.time();
k.clusters <- elbow.k(data.clustering);
end.time <- Sys.time();
cat('Time to find k using Elbow method is',(end.time - start.time),'seconds with k value:', k.clusters);
The time is so large:
Time to find k using Elbow method is 24.01472 seconds with k value: 10
谁能帮我在r中使用parallel来减少Elbow方法的时间?非常感谢。
【问题讨论】:
标签: r parallel-processing k-means