加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – PySpark 2:KMeans输入数据不直接缓存

发布时间:2020-12-20 11:55:40 所属栏目:Python 来源:网络整理
导读:我不知道为什么收到这条消息 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_cl
我不知道为什么收到这条消息

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不会被缓存.这就是你看警告的原因.虽然很烦人但我不会太担心它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读