我在构建一个机器学习Pipeline
时遇到了以下错误:
pyspark.sql.utils.IllegalArgumentException: 'requirement failed: Column features must be of type org.apache.spark.ml.linalg.VectorUDT@3bfc3ba7 but was actually ArrayType(DoubleType,true).'
我的features
列包含一系列浮点值。看起来我需要将它们转换为某种向量(不是稀疏向量,所以是DenseVector?)。是否可以直接在DataFrame上执行此操作或者我需要将其转换为RDD?
pyspark.ml.functions
中的array_to_vector
将数组列转换为向量类型。只有在pyspark>=3.1.0中才可用。更多细节请参见:stackoverflow.com/a/48333361/2650427。 - TrigonaMinima