【发布时间】:2018-03-23 17:11:56
【问题描述】:
在this example 之后,我计算了一些文档的 TF-IDF 权重。现在我想使用RowMatrix 来计算文档相似度。但是我无法将数据拟合成正确的格式。我现在拥有的是一个 DataFrame,它的行有 (String,SparseVector) 作为两列的类型。我应该将其转换为RDD[Vector],我认为这很简单:
features.map(row => row.getAs[SparseVector](1)).rdd()
但我收到此错误:
<console>:58: error: Unable to find encoder for type stored in a
Dataset. Primitive types (Int, String, etc) and Product types (case
classes) are supported by importing spark.implicits._ Support for
serializing other types will be added in future releases.
导入spark.implicits._ 没有区别。
那么发生了什么?我很惊讶 Spark 不知道如何编码自己的向量数据类型。
【问题讨论】:
标签: apache-spark apache-spark-mllib