Re: Extracting an element from the feature vector in LabeledPoint

2014-08-22 Thread LPG
Hi all,

Somehow related to this question and this data structure, what is the best
way to extract features using names instead of positions? Of course, it is
previously necessary to store the names in some way...

Thanks in advance



--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/Extracting-an-element-from-the-feature-vector-in-LabeledPoint-tp0p12644.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org



Re: Extracting an element from the feature vector in LabeledPoint

2014-08-01 Thread SK
I am using 1.0.1. It does not matter to me whether it is the first or second
element. I would like to know how to extract the i-th element in the feature
vector (not the label).

data.features(i) gives the following error:

method apply in trait Vector cannot be accessed in
org.apache.spark.mllib.linalg.Vector



--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/Extracting-an-element-from-the-feature-vector-in-LabeledPoint-tp0p11181.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.


Re: Extracting an element from the feature vector in LabeledPoint

2014-08-01 Thread Sean Owen
Oh I'm sorry, I somehow misread your email as looking for the label. I
read too fast. That was pretty silly. THis works for me though:

scala val point = LabeledPoint(1,Vectors.dense(2,3,4))
point: org.apache.spark.mllib.regression.LabeledPoint = (1.0,[2.0,3.0,4.0])

scala point.features(1)
res10: Double = 3.0

On Fri, Aug 1, 2014 at 6:22 PM, SK skrishna...@gmail.com wrote:
 I am using 1.0.1. It does not matter to me whether it is the first or second
 element. I would like to know how to extract the i-th element in the feature
 vector (not the label).

 data.features(i) gives the following error:

 method apply in trait Vector cannot be accessed in
 org.apache.spark.mllib.linalg.Vector



 --
 View this message in context: 
 http://apache-spark-user-list.1001560.n3.nabble.com/Extracting-an-element-from-the-feature-vector-in-LabeledPoint-tp0p11181.html
 Sent from the Apache Spark User List mailing list archive at Nabble.com.