From 9ecd7a897fc53f84e18c35ca605962ee54a8a554 Mon Sep 17 00:00:00 2001 From: Huangweizhe Date: Fri, 22 Jun 2018 16:42:11 +0800 Subject: [PATCH 1/2] If you want to create a dense matrix ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0)), the list should be [1, 3, 5, 2, 4, 6]. --- docs/mllib-data-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mllib-data-types.md b/docs/mllib-data-types.md index 5066bb29387dc..de73a5826cb27 100644 --- a/docs/mllib-data-types.md +++ b/docs/mllib-data-types.md @@ -317,7 +317,7 @@ Refer to the [`Matrix` Python docs](api/python/pyspark.mllib.html#pyspark.mllib. from pyspark.mllib.linalg import Matrix, Matrices # Create a dense matrix ((1.0, 2.0), (3.0, 4.0), (5.0, 6.0)) -dm2 = Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6]) +dm2 = Matrices.dense(3, 2, [1, 3, 5, 2, 4, 6]) # Create a sparse matrix ((9.0, 0.0), (0.0, 8.0), (0.0, 6.0)) sm = Matrices.sparse(3, 2, [0, 1, 3], [0, 2, 1], [9, 6, 8]) From 6c28df406900f0b16eeb3a4cc13e48f7d83c4531 Mon Sep 17 00:00:00 2001 From: Huangweizhe Date: Mon, 25 Jun 2018 14:50:51 +0800 Subject: [PATCH 2/2] The MatrixEntry here is supposed to be MatrixEntry(2, 1, 3.7) --- docs/mllib-data-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mllib-data-types.md b/docs/mllib-data-types.md index de73a5826cb27..eca101132d2e5 100644 --- a/docs/mllib-data-types.md +++ b/docs/mllib-data-types.md @@ -624,7 +624,7 @@ from pyspark.mllib.linalg.distributed import CoordinateMatrix, MatrixEntry # Create an RDD of coordinate entries. # - This can be done explicitly with the MatrixEntry class: -entries = sc.parallelize([MatrixEntry(0, 0, 1.2), MatrixEntry(1, 0, 2.1), MatrixEntry(6, 1, 3.7)]) +entries = sc.parallelize([MatrixEntry(0, 0, 1.2), MatrixEntry(1, 0, 2.1), MatrixEntry(2, 1, 3.7)]) # - or using (long, long, float) tuples: entries = sc.parallelize([(0, 0, 1.2), (1, 0, 2.1), (2, 1, 3.7)])