Pyspark py4j PickleException: “expected zero arguments for construction of ClassDict”

孤街浪徒 提交于 2019-11-28 12:12:20

I had the same error as I was using MLlib, and it turned out that I had returned a wrong datatype in one of my functions. It now works after a simple cast on the returned value. This might not be the answer you're seeking but it is at least a hint for the direction to follow.

Had the same issue, several times. numpy types don't have implicit conversions to pyspark.sql.types.

Make a simple explicit conversion to the native type system. In my case it was:

float(vector_a.dot(vector_b)

I received this error using Spark Version >= 2.0.

Spark is transitioning MLlib fucntionality to the newer ML namespace. As a result there are two types of SparseVector: ml.linalg.SparseVector and mllib.linalg.SparseVector

Some MLlib functions still expect the older mllib kind

from pyspark.ml.linalg import Vectors
# convert ML vector to older MLlib vector
old_vec = Vectors.fromML(new_vec)

HTH

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!