我想使用h2o.kmeans
包中的h2o
函数。
这是我的代码
clust <- h2o.kmeans(data = waterM, centers = 30, key = "kmeansKey", iter.max = 1000, normalize = T, init = "none", dropNACols = F );
summary(clust@model);
输出
Length Class Mode
params 6 -none- list
centers 25560 -none- numeric
withinss 30 -none- numeric
tot.withinss 1 -none- numeric
size 30 -none- numeric
iter 1 -none- numeric
为什么没有cluster
对象包含整数向量(从1:k),它表示每个点被分配到的簇?
答案 0 :(得分:8)
运行h2o.kmeans时,只需构建模型。
您必须使用您构建的模型运行h2o.predict方法以获取所需的数据。
答案 1 :(得分:4)
有一个函数h2o.getFrame
可以通过key
获取框架。 h2o.kmeans
使用来自h2o.kmeans
+“_clusters”的键生成框架。所以这段代码得到了集群:
clusters <- h2o.getFrame( localH2O, "kmeansKey_clusters" );
答案 2 :(得分:3)
+1 Gunjan Karun的答案。
我遵循的步骤: 1.预测使用h2o.predict 2. h2o.cbind与列车数据集中的标识列,在我的例子中,客户ID