1
我下面這樣:如何將字符串數組更改爲雙精度數組?
val trainVector = trainingData.
rdd.
map { r => Vectors.dense(
r.getDouble(4),
r.getDouble(37),
r.getAs(_).toDouble(70).toArray,
r.getAs(_).toDouble(76).toArray))
我收到以下錯誤:
<console>:22: error: missing parameter type for expanded function ((x$1) => r.getAs(x$1).toDouble(70).toArray)
我怎樣才能改變字符串r.getAs(_).toDouble(70).toArray
和r.getAs(_).toDouble(76).toArray
陣列成double
array
(我可以在使用Vectors.dense
函數)?
我嘗試了以下,但它不起作用,因爲它的字符串數組。
r.getAs[Array[Double]](70)
嘗試'val trainVector = df.rdd.map(r => Vectors.dense(r.getDouble(4).asInstanceOf [Array [Double]] ++ r.getDouble(37).asInstanceOf [Array [Double] ] ++ r.getAs [Array [Double]](70)++ r.getAs [Array [Double]](76))) ' –