python - 派斯帕克 2 : KMeans The input data is not directly cached

标签 python apache-spark pyspark apache-spark-sql k-means

我不知道为什么会收到消息

WARN KMeans: The input data is not directly cached, which may hurt performance if its parent RDDs are also uncached.

当我尝试使用 Spark KMeans

df_Part = assembler.transform(df_Part)    
df_Part.cache()
while (k<=max_cluster) and (wssse > seuilStop):
                    kmeans = KMeans().setK(k)
                    model = kmeans.fit(df_Part)
                    wssse = model.computeCost(df_Part)
                    k=k+1

它说我的输入(Dataframe)没有被缓存!!

我尝试打印 df_Part.is_cached 并收到 True,这意味着我的数据帧已缓存,那么为什么 Spark 仍然警告我?

最佳答案

此消息由 o.a.s.mllib.clustering.KMeans 生成,如果不修补 Spark 代码,您将无能为力。

内部 o.a.s.ml.clustering.KMeans:

  • DataFrame 转换为 RDD[o.a.s.mllib.linalg.Vector]
  • 执行 o.a.s.mllib.clustering.KMeans

当你缓存 DataFrame 时,内部使用的 RDD 不会被缓存。这就是您看到警告的原因。虽然这很烦人,但我不会太担心它。

关于python - 派斯帕克 2 : KMeans The input data is not directly cached,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40406166/

相关文章:

python - Tensorboard 找不到 .runfiles 目录错误

python - 用 Pandas 重命名excel中的特定列

Python 3 - 类型错误 : 'map' object is not subscriptable

apache-spark - Spark 减少功能 : understand how it works

scala - 过滤数据帧spark scala以查找大于当前时间的日期

pyspark - 使用 PySpark 时如何将 jdbc 驱动程序添加到类路径?

python - 在没有正则表达式的python中检测字符串重复

java - 如何通过键比较两个JavaPairRDD并比较值?

apache-spark - PYSPARK:如何根据条件更新列中的值

hadoop - pyspark:如何释放资源