napkinxc.datasets.to_np_matrix

napkinxc.datasets.to_np_matrix(X, shape=None, dtype=numpy.float32)[source]

Converts sparse matrix-like data, like list of list of tuples (idx, value), to Numpy matrix (2D array).

Parameters:
  • X (ndarray, list[list[int|str]], list[list[tuple[int, float]]) – Matrix-like object to convert to csr_matrix: ndarray or list of lists of ints or tuples of ints and floats (idx, value).

  • shape (tuple, optional) – Shape of the matrix, if None, shape will be deduce from X, defaults to None

  • dtype (type, optional) – Data type of the matrix, if None, type will be deduced from data, defaults to np.float32

Returns:

X as Numpy 2D array.

Return type:

ndarray