You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the func show below, it describe all nonzero elements become 1, while it change the the whole mat to 1 in reality, with using X.data[:] = 1 or X[:] = 1
def binarized(X, inplace=False):
"""Binarize a dense/sparse matrix. All nonzero elements become 1.
Args:
X (np.ndarray, spmatrix): input matrix to binarize
inplace (bool, optional): if True do the binarization in-place, else return a copy. Default False
Returns:
binarized X
"""
if not isinstance(X, (np.ndarray, smat.spmatrix)):
raise NotImplementedError(
"this function only support X being np.ndarray or scipy.sparse.spmatrix."
)
if not inplace:
X = X.copy()
if isinstance(X, smat.spmatrix):
X.data[:] = 1
else:
X[:] = 1
return X
References
list reference and related literature
list known implementations
The text was updated successfully, but these errors were encountered:
Description
the func show below, it describe all nonzero elements become 1, while it change the the whole mat to 1 in reality, with using X.data[:] = 1 or X[:] = 1
References
The text was updated successfully, but these errors were encountered: