【发布时间】:2022-08-24 16:31:13
【问题描述】:
阅读mleap documentation我可以看到火花 ML Imputer 是在支持的变压器列表中。
但是,当我尝试在 pyspark 中序列化管道时,我得到了java.util.NoSuchElementException: key not found: org.apache.spark.ml.feature.ImputerModel。
这是否意味着不支持 Imputer?
我找到了一个关于这个问题的ticket in mleap repo - 这是否意味着仅支持 spark Imputer 的 MLeap 版本(来自mleap-spark-extension 的那个)?如何从 pyspark 使用它? (在这种情况下,文档非常具有误导性,应该在某处提及)。
我的代码无法序列化管道(pyspark 3.0.3,mleap 0.19.0):
from pyspark.ml import Pipeline
from pyspark.ml.feature import Imputer
from pyspark.sql import SparkSession
from mleap.pyspark.spark_support import SimpleSparkSerializer
input = [
{\"a\": 0, \"b\": None},
{\"a\": None, \"b\": 0},
{\"a\": 10, \"b\": None},
{\"a\": None, \"b\": 10},
]
spark = SparkSession.builder \\
.config(\'spark.jars.packages\', \'ml.combust.mleap:mleap-spark_2.12:0.19.0\') \\
.config(\"spark.jars.excludes\", \"net.sourceforge.f2j:arpack_combined_all\") \\
.getOrCreate()
df = spark.sparkContext.parallelize(input).toDF()
pip = Pipeline(stages=[
Imputer(strategy=\"mean\", inputCols=[\"a\", \"b\"], outputCols=[\"a\", \"b\"])
])
fitted_pip = pip.fit(df)
fitted_pip.serializeToBundle(\"jar:file:/tmp/test-pip.zip\", fitted_pip.transform(df))
标签: serialization pyspark pipeline mleap