DenseMatrix

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

Column-major dense matrix.

Methods

toArray()

Return a numpy.ndarray

toSparse()

Convert to SparseMatrix

Methods Documentation

toArray() → numpy.ndarray[source]

Return a numpy.ndarray

Examples

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

Convert to SparseMatrix