Re: create a Row Matrix

2014-10-22 Thread Yana Kadiyska
This works for me

import org.apache.spark.mllib.linalg._
import org.apache.spark.mllib.linalg.distributed.RowMatrix

val v1=Vectors.dense(Array(1d,2d))

val v2=Vectors.dense(Array(3d,4d))

val rows=sc.parallelize(List(v1,v2))

val mat=new RowMatrix(rows)

val svd: SingularValueDecomposition[RowMatrix, Matrix] =
mat.computeSVD(2, computeU = true)

​

On Wed, Oct 22, 2014 at 1:55 AM, viola viola.wiersc...@siemens.com wrote:

 Thanks for the quick response. However, I still only get error messages. I
 am
 able to load a .txt file with entries in it and use it in sparks, but I am
 not able to create a simple matrix, for instance a 2x2 row matrix
 [1 2
 3 4]
 I tried variations such as
 val RowMatrix = Matrix(2,2,array(1,3,2,4))
 but it doesn't work..





 --
 View this message in context:
 http://apache-spark-user-list.1001560.n3.nabble.com/create-a-Row-Matrix-tp16913p16993.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: create a Row Matrix

2014-10-21 Thread Xiangrui Meng
Please check out the example code:
https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/mllib/TallSkinnySVD.scala
-Xiangrui

On Tue, Oct 21, 2014 at 5:34 AM, viola viola.wiersc...@siemens.com wrote:
 Hi,

 I am VERY new to spark and mllib and ran into a couple of problems while
 trying to reproduce some examples. I am aware that this is a very simple
 question but could somebody please give me an example
 - how to create a RowMatrix in scala with the following entries:
 [1 2
 3 4]?
 I would like to apply an SVD on it.

 Thank you very much!





 --
 View this message in context: 
 http://apache-spark-user-list.1001560.n3.nabble.com/create-a-Row-Matrix-tp16913.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


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



Re: create a Row Matrix

2014-10-21 Thread viola
Thanks for the quick response. However, I still only get error messages. I am
able to load a .txt file with entries in it and use it in sparks, but I am
not able to create a simple matrix, for instance a 2x2 row matrix
[1 2
3 4]
I tried variations such as 
val RowMatrix = Matrix(2,2,array(1,3,2,4))
but it doesn't work..





--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/create-a-Row-Matrix-tp16913p16993.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