如何找到 Spark 的 StreamingKMeans 的聚类中心?
How to find cluster centers of Spark's StreamingKMeans?
当我使用 Spark 的 KMeansModel class 时,我可以使用 KMeansModel.clusterCenters()
函数轻松访问模型集群的质心。
我想使用 StreamingKMeans,但我注意到它似乎缺少 clusterCenters()
功能。有没有办法在 StreamingKMeans 中获取我的模型集群的质心?
在批处理 KMeans 中,估计器被训练一次并生成单个变换器 - 包含 clusterCenters()
方法的模型。在 StreamingKMeans 中,模型会不断更新,因此您需要在 StreamingKMeans 对象上使用 latestModel()
。
val model = new StreamingKMeans()
.setK(5)
.setDecayFactor(1.0)
.setRandomCenters(10, 0.0)
val latestModel = model.latestModel()
println(latestModel.clusterCenters)
当我使用 Spark 的 KMeansModel class 时,我可以使用 KMeansModel.clusterCenters()
函数轻松访问模型集群的质心。
我想使用 StreamingKMeans,但我注意到它似乎缺少 clusterCenters()
功能。有没有办法在 StreamingKMeans 中获取我的模型集群的质心?
在批处理 KMeans 中,估计器被训练一次并生成单个变换器 - 包含 clusterCenters()
方法的模型。在 StreamingKMeans 中,模型会不断更新,因此您需要在 StreamingKMeans 对象上使用 latestModel()
。
val model = new StreamingKMeans()
.setK(5)
.setDecayFactor(1.0)
.setRandomCenters(10, 0.0)
val latestModel = model.latestModel()
println(latestModel.clusterCenters)