DenseMatrix

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

Column-major dense matrix.

Methods

toArray()

Return a numpy.ndarray

toSparse()

Convert to SparseMatrix

Methods Documentation

toArray() → numpy.ndarray

Return a numpy.ndarray

Examples

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

Convert to SparseMatrix