diff options
author | Reza Zadeh <rizlar@gmail.com> | 2014-01-05 18:03:57 -0800 |
---|---|---|
committer | Reza Zadeh <rizlar@gmail.com> | 2014-01-05 18:03:57 -0800 |
commit | 746148bc18d5e25ea93f5ff17a6cb4da9b671b75 (patch) | |
tree | 24f7831a37b53c8035f4e34a6891137fdce9506d /docs/mllib-guide.md | |
parent | 06c0f7628a213a08ef5adeab903160b806680acf (diff) | |
download | spark-746148bc18d5e25ea93f5ff17a6cb4da9b671b75.tar.gz spark-746148bc18d5e25ea93f5ff17a6cb4da9b671b75.tar.bz2 spark-746148bc18d5e25ea93f5ff17a6cb4da9b671b75.zip |
fix docs to use SparseMatrix
Diffstat (limited to 'docs/mllib-guide.md')
-rw-r--r-- | docs/mllib-guide.md | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/mllib-guide.md b/docs/mllib-guide.md index abeb55d081..653848b6d4 100644 --- a/docs/mllib-guide.md +++ b/docs/mllib-guide.md @@ -243,18 +243,21 @@ as tuples of the form ((i,j),value) all in RDDs. Below is example usage. import org.apache.spark.SparkContext import org.apache.spark.mllib.linalg.SVD +import org.apache.spark.mllib.linalg.SparseMatrix +import org.apache.spark.mllib.linalg.MatrixEntry // Load and parse the data file val data = sc.textFile("mllib/data/als/test.data").map { line => val parts = line.split(',') - ((parts(0).toInt, parts(1).toInt), parts(2).toDouble) + MatrixEntry(parts(0).toInt, parts(1).toInt, parts(2).toDouble) } val m = 4 val n = 4 val k = 1 // recover largest singular vector -val (u, s, v) = SVD.sparseSVD(data, m, n, 1) +val decomposed = SVD.sparseSVD(SparseMatrix(data, m, n), k) +val = decomposed.S.data println("singular values = " + s.toArray.mkString) |