简体   繁体   English

使用DecisionTreeModel Spark ML保存管道

[英]Saving a Pipeline with DecisionTreeModel Spark ML

Context: 语境:

I have a Spark ML pipeline that contains a VectorAssembler, StringIndexer, and a DecisionTreeClassifier. 我有一个Spark ML管道,它包含一个VectorAssembler,StringIndexer和一个DecisionTreeClassifier。 Using this pipeline I am able to successfully fit the model and transform my data frame. 使用此管道,我能够成功地拟合模型并转换我的数据框。 I would like to store this model for future use, but I keep getting the following error: 我想存储此模型以供将来使用,但我不断收到以下错误:

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

What I have tried : 我尝试过的

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

This works properly when I remove the classifier (ie dt). 当我删除分类器(即dt)时,这可以正常工作。 Is there a way of saving a DecisionTreeClassifier model? 有没有一种方法可以保存DecisionTreeClassifier模型?

My data consists of some indexed categorical values that I must map back to their original form (I know this will require using IndexToString). 我的数据包含一些索引的分类值,我必须将它们映射回原始形式(我知道这需要使用IndexToString)。 I am using Spark 1.6. 我正在使用Spark 1.6。

This cannot be done as of Spark 1.6. 这不能像Spark 1.6那样完成。 The issue is being tracked here . 这个问题正在跟踪这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM