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


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


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

用法:

toIndexedRowMatrix()

将此矩阵转换为 IndexedRowMatrix。

例子

>>> 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).toIndexedRowMatrix()
>>> # This BlockMatrix will have 6 effective rows, due to
>>> # having two sub-matrix blocks stacked, each with 3 rows.
>>> # The ensuing IndexedRowMatrix 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 IndexedRowMatrix will also have 2 columns.
>>> print(mat.numCols())
2

相关用法


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