spark mlib中2种局部向量:denseVector(稠密向量)和sparseVector(稀疏向量)
denseVector向量的生成方法:Vector.dense()
sparseVector向量的生成方法:
(1):Vector.sparse(向量长度,索引数组,与索引数组所对应的数值数组)
(2):Vector.sparse(向量长度,(索引,数值),(索引,数值),...(索引,数值))
例子:向量(5.2,0.0,5.5)
稠密向量:Vector.dense(5.2,0.0,5.5)
稀疏向量:Vector.sparse(3,(0,2),(5.2,5.5))或是Vector.sparse(3,(1,5.2),(3,5.5))