DenseMatrix

class pyspark.mllib.linalg.DenseMatrix(numRows: int, numCols: int, values: Union[bytes, Iterable[float]], isTransposed: bool = False)[source]

Column-major dense matrix.

Methods

asML()

Convert this matrix to the new mllib-local representation.

toArray()

Return an numpy.ndarray

toSparse()

Convert to SparseMatrix

Methods Documentation

asML()pyspark.ml.linalg.DenseMatrix[source]

Convert this matrix to the new mllib-local representation. This does NOT copy the data; it copies references.

New in version 2.0.0.

Returns
pyspark.ml.linalg.DenseMatrix
toArray() → numpy.ndarray[source]

Return an numpy.ndarray

Examples

>>> m = DenseMatrix(2, 2, range(4))
>>> m.toArray()
array([[ 0.,  2.],
       [ 1.,  3.]])
toSparse()pyspark.mllib.linalg.SparseMatrix[source]

Convert to SparseMatrix