Vector对象可以转换为:
-
Array [Double]使用toArray。
-
使用toDense作为DenseVector的密集向量。
-
使用toSparse作为SparseVector的稀疏向量。
from pyspark.ml.linalg import Vectors
#Create a dense vector (1.0, 0.0, 3.0).
dv = Vectors.dense(1.0, 0.0, 3.0)
#Create a sparse vector (1.0, 0.0, 3.0)
#by specifying its indices and values correspondi