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

scala – 使用DecisionTreeModel Spark ML保存管道

发布时间:2020-12-16 18:31:27 所属栏目:安全 来源:网络整理
导读:语境: 我有一个Spark ML管道,它包含一个VectorAssembler,StringIndexer和一个DecisionTreeClassifier.使用此管道,我能够成功地拟合模型并转换我的数据框.我想存储此模型以供将来使用,但我不断收到以下错误: Pipeline write will fail on this Pipeline bec
语境:

我有一个Spark ML管道,它包含一个VectorAssembler,StringIndexer和一个DecisionTreeClassifier.使用此管道,我能够成功地拟合模型并转换我的数据框.我想存储此模型以供将来使用,但我不断收到以下错误:

Pipeline write will fail on this Pipeline because it contains a stage which does not implement Writable. 
Non-Writable stage: dtc_9c04161ed2d1 of type class org.apache.spark.ml.classification.DecisionTreeClassificationModel

我尝试过的:

val pipeline = new Pipeline().setStages(Array(assembler,labelIndexer,dt))
val model = pipeline.fit(dfIndexed)
model.write.overwrite().save("test/model/pipeline")

当我删除分类器(即dt)时,这可以正常工作.有没有一种方法可以保存DecisionTreeClassifier模型?

我的数据包含一些索引的分类值,我必须将它们映射回原始形式(我知道这需要使用IndexToString).我正在使用Spark 1.6.

解决方法

这不能像Spark 1.6那样完成.这个问题正在追踪 here.

(编辑:李大同)

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

    推荐文章
      热点阅读