当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python pyspark BlockMatrix.toLocalMatrix用法及代码示例


本文简要介绍 pyspark.mllib.linalg.distributed.BlockMatrix.toLocalMatrix 的用法。

用法:

toLocalMatrix()

将驱动程序上的分布式矩阵收集为 DenseMatrix。

例子

>>> blocks = sc.parallelize([((0, 0), Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6])),
...                          ((1, 0), Matrices.dense(3, 2, [7, 8, 9, 10, 11, 12]))])
>>> mat = BlockMatrix(blocks, 3, 2).toLocalMatrix()
>>> # This BlockMatrix will have 6 effective rows, due to
>>> # having two sub-matrix blocks stacked, each with 3 rows.
>>> # The ensuing DenseMatrix will also have 6 rows.
>>> print(mat.numRows)
6
>>> # This BlockMatrix will have 2 effective columns, due to
>>> # having two sub-matrix blocks stacked, each with 2
>>> # columns. The ensuing DenseMatrix will also have 2 columns.
>>> print(mat.numCols)
2

相关用法


注:本文由纯净天空筛选整理自spark.apache.org大神的英文原创作品 pyspark.mllib.linalg.distributed.BlockMatrix.toLocalMatrix。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。