Yes, it works! Thanks a lot Burak!
Cheers,
Dan
2015-07-14 14:34 GMT-05:00 Burak Yavuz :
> Hi Dan,
>
> You could zip the indices with the values if you like.
>
> ```
> val sVec = sparseVector(1).asInstanceOf[
> org.apache.spark.mllib.linalg.SparseVector]
> val map = sVec.indices.zip(sVec.values)
Hi Dan,
You could zip the indices with the values if you like.
```
val sVec = sparseVector(1).asInstanceOf[
org.apache.spark.mllib.linalg.SparseVector]
val map = sVec.indices.zip(sVec.values).toMap
```
Best,
Burak
On Tue, Jul 14, 2015 at 12:23 PM, Dan Dong wrote:
> Hi,
> I'm wondering how t
Hi,
I'm wondering how to access elements of a linalg.Vector, e.g:
sparseVector: Seq[org.apache.spark.mllib.linalg.Vector] =
List((3,[1,2],[1.0,2.0]), (3,[0,1,2],[3.0,4.0,5.0]))
scala> sparseVector(1)
res16: org.apache.spark.mllib.linalg.Vector = (3,[0,1,2],[3.0,4.0,5.0])
How to get the indices