Apache spark 将新安装的阶段添加到现有管道模型,而无需再次安装
我想将几个经过训练的管道连接到一个管道,这类似于 “”但是,下面的解决方案适用于PySparkApache spark 将新安装的阶段添加到现有管道模型,而无需再次安装,apache-spark,pipeline,apache-spark-ml,apache-spark-2.0,Apache Spark,Pipeline,Apache Spark Ml,Apache Spark 2.0,我想将几个经过训练的管道连接到一个管道,这类似于 “”但是,下面的解决方案适用于PySpark >pipe\u model\u new=PipelineModel(阶段=[pipe\u model,pipe\u model2]) >最终\u df=管道\u模型\u新的.transform(df1) 在ApacheSpark2.0中,“PipelineModel”的构造函数被标记为私有,因此不能在外部调用。在“Pipeline”类中,只有“fit”方法创建“PipelineModel” val
>pipe\u model\u new=PipelineModel(阶段=[pipe\u model,pipe\u model2])
>最终\u df=管道\u模型\u新的.transform(df1)
在ApacheSpark2.0中,“PipelineModel”的构造函数被标记为私有,因此不能在外部调用。在“Pipeline”类中,只有“fit”方法创建“PipelineModel”
val pipelineModel=新的管道模型(“随机UID”,trainedStages)
val df_final_full=管道模型.转换(df)
调用fit
方法没有任何错误。如果一个阶段是一个transformer
,而PipelineModel
是**,fit
的工作原理与identity类似
您可以检查:
如果存在(级、变压器):
变压器。附加(阶段)
数据集=stage.transform(数据集)
以及:
这意味着拟合过程将只验证模式并创建新的PipelineModel
对象
案例t:变压器=>
T
*唯一可能的问题是存在非惰性的
转换器
,但是,除了不推荐的OneHotEncoder
,Spark core API不提供这种功能
**在Python中:
来自pyspark.ml导入转换器,PipelineModel
ISSUB类(管道模型、变压器)
True
在斯卡拉
导入scala.reflect.runtime.universe.typeOf
导入org.apache.spark.ml_
类型[管道模型]
Error:(266, 26) constructor PipelineModel in class PipelineModel cannot be accessed in class Preprocessor
val pipelineModel = new PipelineModel("randomUID", trainedStages)
Boolean = true