我正在准备一个带有id和我的特征向量的DataFrame,以便稍后用于做预测.我在我的数据框架上做了一个groupBy,在我的groupBy中,我将几列作为列表合并到一个新列中:
def mergeFunction(...) // with 14 input variables
val myudffunction( mergeFunction ) // Spark doesn't support this
df.groupBy("id").agg(
collect_list(df(...)) as ...
... // too many of these (something like 14 of them)
).withColumn("features_labels",
myudffunction(
col(...)
, col(...) )
.select("id", "feature_labels")
Run Code Online (Sandbox Code Playgroud)
这就是我创建我的特征向量及其标签的方式.到目前为止,它一直在为我工作,但这是我第一次使用这种方法的特征向量大于数字10,这是Spark接受的最大函数udf.
我不知道我还能解决这个问题吗?Spark中udf输入的大小是否会变大,我是否理解错误,或者有更好的方法?
scala dataframe apache-spark apache-spark-sql apache-spark-mllib