Scala 向量数组中的数组。密集的火花

Scala 向量数组中的数组。密集的火花,scala,apache-spark,apache-spark-mllib,predictionio,Scala,Apache Spark,Apache Spark Mllib,Predictionio,我正在尝试将特征添加为向量中的双精度数组。密集函数,但出现以下错误: templates/scala-parallel-classification/reading-custom-properties/src/main/scala/DataSource.scala:58:21: overloaded method value dense with alternatives: [INFO] [Engine$] [error] (values: Array[Double])org.apache.

我正在尝试将
特征
添加为
向量中的双精度数组。密集
函数,但出现以下错误:

templates/scala-parallel-classification/reading-custom-properties/src/main/scala/DataSource.scala:58:21: overloaded method value dense with alternatives:
[INFO] [Engine$] [error]   (values: Array[Double])org.apache.spark.mllib.linalg.Vector <and>
[INFO] [Engine$] [error]   (firstValue: Double,otherValues: Double*)org.apache.spark.mllib.linalg.Vector
[INFO] [Engine$] [error]  cannot be applied to (Array[Any])
[INFO] [Engine$] [error]             Vectors.dense(Array(


如何在
向量数组中传递数组。dense
函数?

向量。dense
只接受单个
数组[Double]
或Double作为单独的参数。在一个数组中不可能有一个数组。由于数组具有混合类型,因此会收到错误消息:

无法应用于(数组[任何])

要解决这个问题,解决方案是简单地使用第二个数组扩展数组,而不是将其作为单个元素添加。在这种情况下,将
标签点的创建更改为:

LabeledPoint(properties.get[Double]("label"),
  Vectors.dense(
    Array(
      properties.get[Double]("featureA"),
      properties.get[Double]("featureB"),
      properties.get[Double]("featureC")
    ) ++ properties.get[Array[Double]]("featureD")
  )
)
LabeledPoint(properties.get[Double]("label"),
  Vectors.dense(
    Array(
      properties.get[Double]("featureA"),
      properties.get[Double]("featureB"),
      properties.get[Double]("featureC")
    ) ++ properties.get[Array[Double]]("featureD")
  )
)