napkinxc.datasets.to_csr_matrix¶
- napkinxc.datasets.to_csr_matrix(X, shape=None, sort_indices=False, dtype=numpy.float32)[source]¶
Converts sparse matrix-like data, like list of list of tuples (idx, value), to Scipy csr_matrix.
- 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
sort_indices (bool, optional) – Sort rows’ data by indices (idx), defaults to False
dtype (type, optional) – Data type of the matrix, defaults to np.float32
- Returns:
X as csr_matrix.
- Return type:
csr_matrix