本文简要介绍
pyspark.mllib.linalg.distributed.BlockMatrix.multiply
的用法。用法:
multiply(other)
Left 将此 BlockMatrix 乘以另一个 BlockMatrix
other
。该矩阵的colsPerBlock
必须等于other
的rowsPerBlock
。如果other
包含任何SparseMatrix块,则必须将它们转换为DenseMatrix块。输出BlockMatrix将仅包含DenseMatrix块。在添加对两个稀疏矩阵相乘的支持之前,这可能会导致一些性能问题。例子:
>>> dm1 = Matrices.dense(2, 3, [1, 2, 3, 4, 5, 6]) >>> dm2 = Matrices.dense(2, 3, [7, 8, 9, 10, 11, 12]) >>> dm3 = Matrices.dense(3, 2, [1, 2, 3, 4, 5, 6]) >>> dm4 = Matrices.dense(3, 2, [7, 8, 9, 10, 11, 12]) >>> sm = Matrices.sparse(3, 2, [0, 1, 3], [0, 1, 2], [7, 11, 12]) >>> blocks1 = sc.parallelize([((0, 0), dm1), ((0, 1), dm2)]) >>> blocks2 = sc.parallelize([((0, 0), dm3), ((1, 0), dm4)]) >>> blocks3 = sc.parallelize([((0, 0), sm), ((1, 0), dm4)]) >>> mat1 = BlockMatrix(blocks1, 2, 3) >>> mat2 = BlockMatrix(blocks2, 3, 2) >>> mat3 = BlockMatrix(blocks3, 3, 2)
>>> mat1.multiply(mat2).toLocalMatrix() DenseMatrix(2, 2, [242.0, 272.0, 350.0, 398.0], 0)
>>> mat1.multiply(mat3).toLocalMatrix() DenseMatrix(2, 2, [227.0, 258.0, 394.0, 450.0], 0)
相关用法
- Python pyspark BlockMatrix.add用法及代码示例
- Python pyspark BlockMatrix.colsPerBlock用法及代码示例
- Python pyspark BlockMatrix.subtract用法及代码示例
- Python pyspark BlockMatrix.toLocalMatrix用法及代码示例
- Python pyspark BlockMatrix.toIndexedRowMatrix用法及代码示例
- Python pyspark BlockMatrix.rowsPerBlock用法及代码示例
- Python pyspark BlockMatrix.numCols用法及代码示例
- Python pyspark BlockMatrix.numColBlocks用法及代码示例
- Python pyspark BlockMatrix.numRowBlocks用法及代码示例
- Python pyspark BlockMatrix.toCoordinateMatrix用法及代码示例
- Python pyspark BlockMatrix.transpose用法及代码示例
- Python pyspark BlockMatrix.numRows用法及代码示例
- Python pyspark BlockMatrix.blocks用法及代码示例
- Python pyspark BisectingKMeans用法及代码示例
- Python pyspark Bucketizer用法及代码示例
- Python pyspark BinaryClassificationEvaluator用法及代码示例
- Python pyspark BucketedRandomProjectionLSH用法及代码示例
- Python pyspark BinaryClassificationMetrics用法及代码示例
- Python pyspark BisectingKMeansModel用法及代码示例
- Python pyspark Broadcast用法及代码示例
- Python pyspark Binarizer用法及代码示例
- Python pyspark create_map用法及代码示例
- Python pyspark date_add用法及代码示例
- Python pyspark DataFrame.to_latex用法及代码示例
- Python pyspark DataStreamReader.schema用法及代码示例
注:本文由纯净天空筛选整理自spark.apache.org大神的英文原创作品 pyspark.mllib.linalg.distributed.BlockMatrix.multiply。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。